C# MemoryStream.GetType的代码示例

通过代码示例来学习C# MemoryStream.GetType方法

通过代码示例来学习编程是非常高效的。
1. 代码示例提供了一个具体而直观的学习环境,使初学者能够立即看到编程概念和语法的实际应用。
2. 通过分析和模仿现有的代码实例,初学者可以更好地理解编程逻辑和算法的工作原理。
3. 代码实例往往涵盖了多种编程技巧和最佳实践,通过学习和模仿这些实例,学习者可以逐步掌握如何编写高效、可读性强和可维护的代码。这对于初学者来说,是一种快速提升编程水平的有效途径。


MemoryStream.GetType是C#的System.IO命名空间下中的一个方法, 小编为大家找了一些网络大拿们常见的代码示例,源码中的MemoryStream.GetType() 已经帮大家高亮显示了,大家可以重点学习MemoryStream.GetType() 方法的写法,从而快速掌握该方法的应用。

MemoryStream.GetType的代码示例1 - CheckFileFormatType()

    using System.IO;

        public static Type CheckFileFormatType(string FileName, Type[] FileTypes, byte[] data = null)
        {
            //Todo. Create a compression list like IFileFormat to decompress via an Identiy method
            data = CheckCompression(FileName, data);

            Stream stream;
            if (data != null)
                stream = new MemoryStream(data);
            else
                stream = File.OpenRead(FileName);

            foreach (IFileFormat fileFormat in FileManager.GetFileFormats())
            {
                fileFormat.FileName = Path.GetFileName(FileName);

                foreach (Type type in FileTypes)
                {
                    if (fileFormat.Identify(stream) && fileFormat.GetType() == type)
                        return type;
                }
            }

            return typeof(IFileFormat);
        }
    

开发者ID:KillzXGaming,项目名称:Switch-Toolbox,代码行数:26,代码来源:STFileLoader.cs

在CheckFileFormatType()方法中,MemoryStream的代码示例类中的GetType的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞

MemoryStream.GetType的代码示例2 - FindMatch()

    using System.IO;

        private string FindMatch(byte[] f, string FileName)
        {
            foreach (IFileFormat fileFormat in FileManager.GetFileFormats())
            {
                fileFormat.FileName = FileName;

                if (fileFormat.Identify(new MemoryStream(f)) && fileFormat.GetType() != typeof(GFBMDL))
                {
                    return fileFormat.Extension[0].Replace("*", "");
                }
            }
            return "";
        }
    

开发者ID:KillzXGaming,项目名称:Switch-Toolbox,代码行数:15,代码来源:TRPAK.cs

在FindMatch()方法中,MemoryStream的代码示例类中的GetType的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞

MemoryStream.GetType的代码示例3 - ToText()

    using System.IO;

        internal static string ToText(object rec, ChoCSVRecordConfiguration configuration, Encoding encoding, int bufferSize, TraceSwitch traceSwitch = null)
        {
            if (rec is DataTable)
            {
                StringBuilder csv = new StringBuilder();
                configuration = configuration == null ? new ChoCSVRecordConfiguration().Configure(c => c.WithFirstLineHeader()) : configuration;
                using (var w = new ChoCSVWriter(csv, configuration))
                    w.Write(rec as DataTable);
                return csv.ToString();
            }
            else if (rec is IDataReader)
            {
                StringBuilder csv = new StringBuilder();
                configuration = configuration == null ? new ChoCSVRecordConfiguration().Configure(c => c.WithFirstLineHeader()) : configuration;
                using (var w = new ChoCSVWriter(csv, configuration))
                    w.Write(rec as IDataReader);
                return csv.ToString();
            }

            ChoCSVRecordWriter writer = new ChoCSVRecordWriter(rec.GetType(), configuration);
            writer.TraceSwitch = traceSwitch == null ? ChoETLFramework.TraceSwitchOff : traceSwitch;

            using (var stream = new MemoryStream())
            using (var reader = new StreamReader(stream))
            using (var sw = new StreamWriter(stream, configuration.Encoding, configuration.BufferSize))
            {
                writer.WriteTo(sw, new object[] { rec }).Loop();
                sw.Flush();
                stream.Position = 0;

                return reader.ReadToEnd();
            }
        }
    

开发者ID:Cinchoo,项目名称:ChoETL,代码行数:35,代码来源:ChoCSVWriter.cs

在ToText()方法中,MemoryStream的代码示例类中的GetType的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞

MemoryStream.GetType的代码示例4 - ToText()

    using System.IO;

        internal static string ToText(object rec, ChoFixedLengthRecordConfiguration configuration, Encoding encoding, int bufferSize, TraceSwitch traceSwitch = null)
        {
            if (rec is DataTable)
            {
                StringBuilder text = new StringBuilder();
                configuration = configuration == null ? new ChoFixedLengthRecordConfiguration().Configure(c => c.WithFirstLineHeader()) : configuration;
                using (var w = new ChoFixedLengthWriter(text, configuration))
                    w.Write(rec as DataTable);
                return text.ToString();
            }
            else if (rec is IDataReader)
            {
                StringBuilder text = new StringBuilder();
                configuration = configuration == null ? new ChoFixedLengthRecordConfiguration().Configure(c => c.WithFirstLineHeader()) : configuration;
                using (var w = new ChoFixedLengthWriter(text, configuration))
                    w.Write(rec as IDataReader);
                return text.ToString();
            }

            ChoFixedLengthRecordWriter writer = new ChoFixedLengthRecordWriter(rec.GetType(), configuration);
            writer.TraceSwitch = traceSwitch == null ? ChoETLFramework.TraceSwitchOff : traceSwitch;

            using (var stream = new MemoryStream())
            using (var reader = new StreamReader(stream))
            using (var sw = new StreamWriter(stream, configuration.Encoding, configuration.BufferSize))
            {
                writer.WriteTo(sw, new object[] { rec }).Loop();
                sw.Flush();
                stream.Position = 0;

                return reader.ReadToEnd();
            }
        }
    

开发者ID:Cinchoo,项目名称:ChoETL,代码行数:35,代码来源:ChoFixedLengthWriter.cs

在ToText()方法中,MemoryStream的代码示例类中的GetType的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞

MemoryStream.GetType的代码示例5 - ToText()

    using System.IO;

        internal static string ToText(object rec, ChoJSONRecordConfiguration configuration, Encoding encoding, int bufferSize, TraceSwitch traceSwitch = null)
        {
            if (rec is DataTable)
            {
                StringBuilder json = new StringBuilder();
                using (var w = new ChoJSONWriter(json, configuration))
                {
                    w.Write(rec as DataTable);
                }
                return json.ToString();
            }
            else if (rec is IDataReader)
            {
                StringBuilder json = new StringBuilder();
                using (var w = new ChoJSONWriter(json, configuration))
                {
                    w.Write(rec as IDataReader);
                }
                return json.ToString();
            }

            ChoJSONRecordWriter writer = new ChoJSONRecordWriter(rec.GetType(), configuration);
            writer.TraceSwitch = traceSwitch == null ? ChoETLFramework.TraceSwitchOff : traceSwitch;

            using (var stream = new MemoryStream())
            using (var reader = new StreamReader(stream))
            using (var sw = new StreamWriter(stream, configuration.Encoding, configuration.BufferSize))
            {
                writer.WriteTo(sw, new object[] { rec }).Loop();
                sw.Flush();
                stream.Position = 0;

                return reader.ReadToEnd();
            }
        }
    

开发者ID:Cinchoo,项目名称:ChoETL,代码行数:37,代码来源:ChoJSONWriter.cs

在ToText()方法中,MemoryStream的代码示例类中的GetType的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞

MemoryStream.GetType的代码示例6 - DumpAsJson()

    using System.IO;

        public static string DumpAsJson(this object target, Encoding encoding, DataContractJsonSerializerSettings jsonSettings)
        {
            if (target == null)
                return String.Empty;

            encoding = encoding == null ? Encoding.UTF8 : encoding;

            if (target is IEnumerable)
                target = ((IEnumerable)target).OfType().ToArray();

            using (MemoryStream ms = new MemoryStream())
            {
                using (var writer = JsonReaderWriterFactory.CreateJsonWriter(
                   ms, encoding, true, true, "  "))
                {
                    DataContractJsonSerializer serializer = new DataContractJsonSerializer(target.GetType(), jsonSettings == null ? _jsonSettings : jsonSettings);

                    //if (target.GetType().IsDynamicType())
                    //    serializer = new DataContractJsonSerializer(typeof(IDictionary), jsonSettings);

                    serializer.WriteObject(writer, target);
                    writer.Flush();
                    byte[] json = ms.ToArray();
                    return encoding.GetString(json, 0, json.Length);
                }
            }
        }
    

开发者ID:Cinchoo,项目名称:ChoETL,代码行数:29,代码来源:ChoUtility.cs

在DumpAsJson()方法中,MemoryStream的代码示例类中的GetType的代码示例方法一共出现了2次, 见黄色背景高亮显示的地方,欢迎大家点赞

MemoryStream.GetType的代码示例7 - ToText()

    using System.IO;

        public static string ToText(TRec record, ChoXmlRecordConfiguration configuration = null, TraceSwitch traceSwitch = null, string xpath = null)
            where TRec : class
        {
            if (record is DataTable)
            {
                StringBuilder xml = new StringBuilder();
                using (var w = new ChoXmlWriter(xml, configuration))
                    w.Write(record as DataTable);
                return xml.ToString();
            }
            else if (record is IDataReader)
            {
                StringBuilder xml = new StringBuilder();
                using (var w = new ChoXmlWriter(xml, configuration))
                    w.Write(record as IDataReader);
                return xml.ToString();
            }

            if (configuration == null)
            {
                configuration = new ChoXmlRecordConfiguration(typeof(TRec));
                configuration.IgnoreRootName = true;
                configuration.RootName = null;
                configuration.IgnoreNodeName = false;
            }

            if (record != null)
            {
                if (configuration.NodeName.IsNullOrWhiteSpace())
                {
                    ChoDynamicObject rec1 = record as ChoDynamicObject;
                    if (rec1 != null)
                    {
                        if (rec1.DynamicObjectName != ChoDynamicObject.DefaultName)
                        {
                            configuration.NodeName = rec1.DynamicObjectName;
                        }
                        else
                        {
                            //configuration.IgnoreNodeName = true;
                            //configuration.NodeName = null;
                        }
                    }
                    else
                    {
                        XmlRootAttribute root = ChoType.GetCustomAttribute(record.GetType(), false);
                        string nodeName = "XElement";
                        if (root != null && !root.ElementName.IsNullOrWhiteSpace())
                            nodeName = root.ElementName.Trim();
                        else
                            nodeName = record.GetType().Name;

                        configuration.NodeName = nodeName;
                    }
                }
            }

            using (var stream = new MemoryStream())
            using (var reader = new StreamReader(stream))
            using (var writer = new StreamWriter(stream))
            using (var parser = new ChoXmlWriter(writer, configuration) { TraceSwitch = traceSwitch == null ? ChoETLFramework.TraceSwitch : traceSwitch })
            {
                //parser.Configuration.XPath = xpath;

                if (record != null)
                    parser.Write(ChoEnumerable.AsEnumerable(record));

                parser.Close();

                writer.Flush();
                stream.Position = 0;

                return reader.ReadToEnd();
            }
        }
    

开发者ID:Cinchoo,项目名称:ChoETL,代码行数:77,代码来源:ChoXmlWriter.cs

在ToText()方法中,MemoryStream的代码示例类中的GetType的代码示例方法一共出现了2次, 见黄色背景高亮显示的地方,欢迎大家点赞

MemoryStream.GetType的代码示例8 - ToText()

    using System.IO;

        internal static string ToText(object rec, ChoYamlRecordConfiguration configuration, Encoding encoding, int bufferSize, TraceSwitch traceSwitch = null)
        {
            if (rec is DataTable)
            {
                StringBuilder json = new StringBuilder();
                using (var w = new ChoYamlWriter(json, configuration))
                {
                    w.Write(rec as DataTable);
                }
                return json.ToString();
            }
            else if (rec is IDataReader)
            {
                StringBuilder json = new StringBuilder();
                using (var w = new ChoYamlWriter(json, configuration))
                {
                    w.Write(rec as IDataReader);
                }
                return json.ToString();
            }

            ChoYamlRecordWriter writer = new ChoYamlRecordWriter(rec.GetType(), configuration);
            writer.TraceSwitch = traceSwitch == null ? ChoETLFramework.TraceSwitchOff : traceSwitch;

            using (var stream = new MemoryStream())
            using (var reader = new StreamReader(stream))
            using (var sw = new StreamWriter(stream, configuration.Encoding, configuration.BufferSize))
            {
                writer.WriteTo(sw, new object[] { rec }).Loop();
                sw.Flush();
                stream.Position = 0;

                return reader.ReadToEnd();
            }
        }
    

开发者ID:Cinchoo,项目名称:ChoETL,代码行数:37,代码来源:ChoYamlWriter.cs

在ToText()方法中,MemoryStream的代码示例类中的GetType的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞

本文中的MemoryStream.GetType方法示例由csref.cn整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。