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


C# IConfigService.GetConfigItemValue方法代码示例

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


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

示例1: Main

        static void Main(string[] args)
        {
            //启动框架
            AdhesiveFramework.Start();
            _configService = LocalServiceLocator.GetService<IConfigService>();

            //获取 全局配置 > TradingConfig > SearchConfig 下名为EnableNewEditionSearch配置项,默认值为false
            bool enableNewEditionSearch = _configService.GetConfigItemValue("TradingConfig",
                                                                        "SearchConfig",
                                                                        "EnableNewEditionSearch",
                                                                        false,
                                                                        EnableNewEditionSearch_ConfigItemValueUpdateCallback);
            Console.WriteLine(string.Format("全局配置 > TradingConfig > SearchConfig > EnableNewEditionSearch:{0}",
                                              enableNewEditionSearch));

            //获取 全局配置 > TradingConfig > SearchConfig 下名为Games列表,默认值为  List<string> {"魔兽世界","冒险岛"}
            List<string> games = _configService.GetConfigItemValue("TradingConfig",
                                                                    "SearchConfig",
                                                                    "Games",
                                                                    new List<string>
                                                                    {
                                                                        "魔兽世界",
                                                                        "冒险岛"
                                                                    },
                                                                    Games_ConfigItemValueUpdateCallback);
            Console.WriteLine("全局配置 > TradingConfig > SearchConfig > Games:");
            foreach (var game in games)
            {

                Console.WriteLine(game);
            }
            //获取 全局配置 > TradingConfig > SearchConfig 下名为Switches的字典,默认值为  new Dictionary<string,bool> {{"Equipment",true},{"Card",false} }
            Dictionary<string, bool> switches = _configService.GetConfigItemValue("TradingConfig",
                                                                                   "SearchConfig",
                                                                                   "Switches",
                                                                                   new Dictionary<string, bool>
                                                                                       {
                                                                                           { "Equipment", true }, { "Card", false }
                                                                                       },
                                                                                   Switches_ConfigItemValueUpdateCallback);
            Console.WriteLine("全局配置 > TradingConfig > SearchConfig > Switches:");
            foreach (var de in switches)
            {
                Console.WriteLine("物品类型:{0},是否开启该业务:{1}",de.Key,de.Value);
            }

            //获取 AdhesiveTest 下名为 BizOfferPromotionConfig 的自定义实体,被动获取
            new Thread(delegate()
                       {
                           while (true)
                           {
                               BizOfferPromotionConfig defaultBizOfferPromotionConfig = new BizOfferPromotionConfig();
                               BizOfferPromotionConfig bizOfferPromotionConfig = _configService.GetConfigItemValue(false,
                                                                             "BizOfferPromotionConfig",
                                                                             defaultBizOfferPromotionConfig);
                               Console.WriteLine("AdhesiveTest > BizOfferPromotionConfig:");
                               Console.WriteLine("OnOff:" + bizOfferPromotionConfig.OnOff);
                               Console.WriteLine("PromotionUrl :" + bizOfferPromotionConfig.PromotionUrl);
                               Console.WriteLine("PromotionUsers :");
                               foreach (var promotionUser in bizOfferPromotionConfig.PromotionUsers)
                               {
                                   Console.ForegroundColor = ConsoleColor.Yellow;
                                   Console.WriteLine(promotionUser);
                                   Console.ResetColor();
                               }
                               Console.WriteLine("PromotionPrice:");
                               Console.WriteLine("PromotionPrice.Game:" + bizOfferPromotionConfig.PromotionPrice.Game);
                               Console.WriteLine("PromotionPrice.BizOfferType: " + bizOfferPromotionConfig.PromotionPrice.BizOfferType);
                               Console.WriteLine("PromotionTimes[0]:");
                               Console.ForegroundColor = ConsoleColor.Yellow;
                               Console.WriteLine(bizOfferPromotionConfig.PromotionTimes[0]);
                               Console.ResetColor();
                               Console.WriteLine("UserGrades:");
                               foreach (var userGrade in bizOfferPromotionConfig.UserGrades)
                               {
                                   Console.ForegroundColor = ConsoleColor.Yellow;
                                   Console.WriteLine(userGrade);
                                   Console.ResetColor();
                               }
                               Thread.Sleep(3000);
                           }
                       }).Start();

            new Thread(delegate()
            {
                while (true)
                {
                    Stopwatch sw = Stopwatch.StartNew();
                    AppInfoCenterConfig defConfig = new AppInfoCenterConfig();
                    Console.WriteLine("默认值:" + new Common().MemoryQueueMaxCount);
                    AppInfoCenterConfig aicConfig = _configService.GetConfigItemValue<AppInfoCenterConfig>(false, typeof(AppInfoCenterConfig).FullName, defConfig);
                    sw.Stop();
                    Console.WriteLine(string.Format("获取配置:{0}ms", sw.ElapsedMilliseconds));
                    Console.WriteLine("TimeSpan:" + aicConfig.CommonField.TimeSpanField);
                    Console.WriteLine("MemoryQueueMaxCount:" + aicConfig.CommonField.MemoryQueueMaxCount);
                    Console.WriteLine("commonDico:k1:" + aicConfig.commonDico["k1"]);
                    Console.WriteLine("DateTime:" + aicConfig.CommonField.DateTime);
                    Console.WriteLine("Styles:" + aicConfig.CommonField.styles);
                    Console.WriteLine("ts:" + aicConfig.CommonField.ts);
                    Console.WriteLine("StringField:" + (aicConfig.CommonField.StringField == string.Empty ? "空" : aicConfig.CommonField.StringField));
//.........这里部分代码省略.........
开发者ID:yhhno,项目名称:Adhesive,代码行数:101,代码来源:Program.cs


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