当前位置: 首页>>代码示例>>C#>>正文


C# Encoding.GetEncoding方法代码示例

本文整理汇总了C#中System.Text.Encoding.GetEncoding方法的典型用法代码示例。如果您正苦于以下问题:C# Encoding.GetEncoding方法的具体用法?C# Encoding.GetEncoding怎么用?C# Encoding.GetEncoding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Text.Encoding的用法示例。


在下文中一共展示了Encoding.GetEncoding方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TmphAppSetting

        static TmphAppSetting()
        {
#if MONO
            settings = new NameValueCollection();
            ConfigPath = LogPath = Laurent.Lee.CLB.pub.ApplicationPath;
            ConfigIncludeName = defaultConfigIncludeName;
            MaxLogSize = 1 << 20;
            MaxLogCacheCount = 1 << 10;
            JsonDepth = 64;
            JavascriptMinTime = new DateTime(1970, 1, 1, 8, 0, 0);
            Encoding = Encoding.UTF8;
            TinyThreadStackSize = 128 << 10;
            ThreadStackSize = 1 << 20;
            PoolSize = 4;
            StreamBufferSize = 4 << 10;
#else
            try
            {
                Settings = ConfigurationManager.AppSettings;

                ConfigFile = Settings["configFile"];
                if (ConfigFile == null)
                {
                    ConfigFile = (ConfigPath = CLB.TmphPub.ApplicationPath) + DefaultConfigFile;
                }
                else if (ConfigFile.IndexOf(':') == -1)
                {
                    ConfigFile = (ConfigPath = CLB.TmphPub.ApplicationPath) + ConfigFile;
                }
                else ConfigPath = new FileInfo(ConfigFile).Directory.fullName().ToLower();

                ConfigIncludeName = Settings["configIncludeName"];
                if (ConfigIncludeName == null) ConfigIncludeName = DefaultConfigIncludeName;

                LogPath = Settings["logPath"];
                if (LogPath == null || !TmphDirectory.Create(LogPath = LogPath.pathSuffix().ToLower()))
                    LogPath = CLB.TmphPub.ApplicationPath;

                var maxLogSize = Settings["maxLogSize"];
                if (!int.TryParse(maxLogSize, out MaxLogSize)) MaxLogSize = 1 << 20;

                var maxLogCacheCount = Settings["maxLogCacheCount"];
                if (!int.TryParse(maxLogCacheCount, out MaxLogCacheCount)) MaxLogCacheCount = 1 << 10;

                var jsonParseDepth = Settings["jsonDepth"];
                if (!int.TryParse(jsonParseDepth, out JsonDepth)) JsonDepth = 64;

                var javascriptMinTimeString = Settings["javascriptMinTime"];
                if (!DateTime.TryParse(javascriptMinTimeString, out JavascriptMinTime))
                {
                    JavascriptMinTime = new DateTime(1970, 1, 1, 8, 0, 0);
                }

                if (Settings["isLogConsole"] != null) IsLogConsole = true;
                if (Settings["isErrorLog"] != null) IsErrorLog = true;

                var encoding = Settings["encoding"];
                if (encoding != null)
                {
                    try
                    {
                        Encoding = Encoding.GetEncoding(encoding);
                    }
                    catch (Exception error)
                    {
                        Console.WriteLine(error.ToString());
                        Encoding = Encoding.UTF8;
                    }
                }
                if (Encoding == null) Encoding = Encoding.UTF8;

                var tinyThreadStackSize = Settings["tinyThreadStackSize"];
                if (!int.TryParse(tinyThreadStackSize, out TinyThreadStackSize)) TinyThreadStackSize = 128 << 10;

                var threadStackSize = Settings["threadStackSize"];
                if (!int.TryParse(threadStackSize, out ThreadStackSize)) ThreadStackSize = 1 << 20;

                var poolSize = Settings["poolSize"];
                if (!int.TryParse(poolSize, out PoolSize)) PoolSize = 4;

                if (Settings["isPoolDebug"] != null) IsPoolDebug = true;

                var streamBufferSize = Settings["streamBufferSize"];
                if (!int.TryParse(streamBufferSize, out StreamBufferSize)) StreamBufferSize = 4 << 10;

                if (Settings["isCheckMemory"] != null) IsCheckMemory = true;
            }
            catch (Exception error)
            {
                Settings = new NameValueCollection();
                ConfigPath = LogPath = CLB.TmphPub.ApplicationPath;
                ConfigIncludeName = DefaultConfigIncludeName;
                MaxLogSize = 1 << 20;
                MaxLogCacheCount = 1 << 10;
                JsonDepth = 64;
                JavascriptMinTime = new DateTime(1970, 1, 1, 8, 0, 0);
                Encoding = Encoding.UTF8;
                TinyThreadStackSize = 128 << 10;
                ThreadStackSize = 1 << 20;
                PoolSize = 4;
//.........这里部分代码省略.........
开发者ID:LaurentLeeJS,项目名称:Laurent.Lee.Framework,代码行数:101,代码来源:TmphAppSetting.cs


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