예제 #1
0
        private void InitCache()
        {
            #region init request
            var requestConfig = EmulatorHelper.LoadXml <RequestConfigEntity>(EmulatorHelper.ApiConfigFileName);
            RequestApiDic  = new Dictionary <string, Dictionary <string, Dictionary <string, RequestConfigParameterEntity> > >();
            ModuleCombo    = new List <KeyValueComboBoxItem>();
            ActionComboDic = new Dictionary <string, List <KeyValueComboBoxItem> >();
            ActionDic      = new Dictionary <string, Dictionary <string, RequestConfigActionEntity> >();
            ModuleDic      = new Dictionary <string, RequestConfigModuleEntity>();

            foreach (var module in requestConfig.Modules)
            {
                ModuleDic.Add(module.Name, module);
                RequestApiDic.Add(module.Name, new Dictionary <string, Dictionary <string, RequestConfigParameterEntity> >());
                ModuleCombo.Add(new KeyValueComboBoxItem(module.Name, BuildContent(module.Name, module.Description)));
                ActionDic.Add(module.Name, new Dictionary <string, RequestConfigActionEntity>());
                ActionComboDic.Add(module.Name, new List <KeyValueComboBoxItem>());
                foreach (var action in module.Actions)
                {
                    ActionDic[module.Name].Add(action.Name, action);
                    RequestApiDic[module.Name].Add(action.Name, new Dictionary <string, RequestConfigParameterEntity>());

                    ActionComboDic[module.Name].Add(new KeyValueComboBoxItem(action.Name, BuildContent(action.Name, action.Description)));
                    foreach (var parameter in action.Parameters)
                    {
                        RequestApiDic[module.Name][action.Name].Add(parameter.Name, parameter);
                    }
                }
            }
            #endregion

            #region init Message config
            var messageConfig = EmulatorHelper.LoadConfig <MessageConfigEntity>(EmulatorHelper.MessageFileName);
            if (messageConfig == null)
            {
                messageConfig = DataExport.ExportMesseageConfig();
                EmulatorHelper.SaveConfig <MessageConfigEntity>(messageConfig, EmulatorHelper.MessageFileName);
            }

            RefreshMessage(messageConfig);
            #endregion

            #region init Formation config
            FormationConfig = EmulatorHelper.LoadConfig <FormationConfigEntity>(EmulatorHelper.FormationFileName);
            if (FormationConfig == null)
            {
            }

            #endregion

            #region init Description config
            DescriptionConfig = EmulatorHelper.LoadConfig <DescriptionConfigEntity>(EmulatorHelper.DescriptionDicFileName);
            if (DescriptionConfig == null)
            {
            }
            #endregion
        }
예제 #2
0
        public static string BuildPropertyPlus(PropertyPlusEntity plusEntity)
        {
            string pName = EmulatorHelper.GetPropertyStr(plusEntity.PropertyId);

            if (plusEntity.PlusType == (int)EnumPlusType.Abs)
            {
                return(string.Format("{0} +{1}", pName, plusEntity.PlusValue));
            }
            return(string.Format("{0} +{1}%", pName, plusEntity.PlusValue));
        }
예제 #3
0
        public static RequestConfigEntity ExportRequestConfig(bool isDebug)
        {
            var      requestConfig = EmulatorHelper.LoadXml <RequestConfigEntity>(EmulatorHelper.ApiConfigFileName);
            Assembly assembly      = Assembly.Load("Games.NBall.Entity");
            var      summaryDic    = BuildSummaryDic(assembly);

            Dictionary <string, string> responseNameDic = new Dictionary <string, string>();

            foreach (var exportedType in assembly.ExportedTypes)
            {
                string key = "";
                if (exportedType.GenericTypeArguments.Length == 1)
                {
                    key = exportedType.Name + "[" + exportedType.GenericTypeArguments[0].Name + "]";
                }

                else
                {
                    key = exportedType.Name;
                }
                if (!responseNameDic.ContainsKey(key))
                {
                    responseNameDic.Add(key, exportedType.FullName);
                }
            }
            if (isDebug)
            {
                string fullName = string.Empty;
                foreach (var module in requestConfig.Modules)
                {
                    if (module.Actions != null)
                    {
                        foreach (var action in module.Actions)
                        {
                            if (!string.IsNullOrEmpty(action.Response))
                            {
                                if (GetFullName(action.Response, out fullName, responseNameDic))
                                {
                                    Type    type = assembly.GetType(fullName);
                                    dynamic t    = Activator.CreateInstance(type);
                                    ActivatorCreateType(type, t);
                                    JsonConvert.EntitySummaryDic = null;
                                    action.Eg = JsonConvert.SerializeObject(t);
                                    JsonConvert.EntitySummaryDic = summaryDic;
                                    action.EgMemo = JsonConvert.SerializeObject(t);
                                    JsonConvert.EntitySummaryDic = null;
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                foreach (var module in requestConfig.Modules)
                {
                    module.Description = "";
                    module.Status      = 0;
                    if (module.Actions != null)
                    {
                        foreach (var action in module.Actions)
                        {
                            action.Memo        = "";
                            action.Response    = "";
                            action.Eg          = "";
                            action.EgMemo      = "";
                            action.Description = "";
                            if (action.Parameters != null)
                            {
                                foreach (var parameter in action.Parameters)
                                {
                                    parameter.Description = "";
                                }
                            }
                        }
                    }
                }
            }
            return(requestConfig);
        }