private void uninstallEvent(CustomSetting setting)
 {
     if (setting != null)
     {
         setting.DataChanged -= Setting_DataChanged;
     }
 }
Exemple #2
0
        private void AddHooks(object obj)
        {
            if (navInstance == null)
            {
                navInstance = Resources.FindObjectsOfTypeAll <SettingsNavigationController>().First();
            }
            Action <FinishAction> del = null;

            needsInit.Add(obj as CustomSetting);
            del = delegate(FinishAction finishAction){
                if (obj is CustomSetting)
                {
                    CustomSetting customSetting = (obj as CustomSetting);
                    if (finishAction == FinishAction.Apply || finishAction == FinishAction.Ok)
                    {
                        customSetting.ApplySettings();
                    }
                    if (finishAction == FinishAction.Cancel)
                    {
                        customSetting.CancelSettings();
                    }
                    navInstance.didFinishEvent -= del;
                }
            };
            navInstance.didFinishEvent += del;
        }
Exemple #3
0
        private void AddHooks(object obj)
        {
            if (navInstance == null)
            {
                navInstance = Resources.FindObjectsOfTypeAll <SettingsNavigationController>().First();
            }
            Action <FinishAction> del = null;

            needsInit.Add(obj as CustomSetting);
            del = delegate(FinishAction finishAction)
            {
                try
                {
                    if (obj is CustomSetting)
                    {
                        CustomSetting customSetting = (obj as CustomSetting);
                        if (finishAction == FinishAction.Apply || finishAction == FinishAction.Ok)
                        {
                            customSetting.ApplySettings();
                        }
                        if (finishAction == FinishAction.Cancel)
                        {
                            customSetting.CancelSettings();
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"[SettingsUI] Crash when trying to apply or cancel settings UI! Exception: {ex.ToString()}");
                }
                navInstance.didFinishEvent -= del;
            };
            navInstance.didFinishEvent += del;
        }
Exemple #4
0
        public void Save()
        {
            Source.Settings.Addins.Addin.Clear();
            foreach (IAddin addin in ConfiguredAddins)
            {
                AddinElement addinElement = new AddinElement();
                addinElement.ReferenceName = addin.ReferenceName.ToString();
                addinElement.FriendlyName  = addin.FriendlyName;

                Dictionary <string, FieldValuePairViewModel> fieldVMs;
                m_addinConfigurations.TryGetValue(addin, out fieldVMs);
                if (addin.CustomSettingKeys != null)
                {
                    foreach (string str in addin.CustomSettingKeys)
                    {
                        FieldValuePairViewModel currentVM;
                        fieldVMs.TryGetValue(str, out currentVM);
                        if (currentVM != null)
                        {
                            CustomSetting customSetting = new CustomSetting();
                            customSetting.SettingKey   = str;
                            customSetting.SettingValue = currentVM.FieldValue;
                            addinElement.CustomSettings.CustomSetting.Add(customSetting);
                        }
                    }
                }

                Source.Settings.Addins.Addin.Add(addinElement);
            }
        }
Exemple #5
0
 void AddCustomSerializer()
 {
     // 自定义Serializer以避免ProtoBuf反射
     CustomSetting.AddCustomSerializer(typeof(ntf_battle_frame_data), new NtfBattleFrameDataDecorator());
     CustomSetting.AddCustomSerializer(typeof(ntf_battle_frame_data.one_slot), new OneSlotDecorator());
     CustomSetting.AddCustomSerializer(typeof(ntf_battle_frame_data.cmd_with_frame), new CmdWithFrameDecorator());
     CustomSetting.AddCustomSerializer(typeof(one_cmd), new OneCmdDecorator());
 }
Exemple #6
0
 //导入用户设置
 public void LoadCustomSetting()
 {
     //..
     if (CustomSetting.HasKey("IsMusicOn"))
     {
         cb_MusicSwitch.IsChecked = CustomSetting.GetBool("IsMusicOn");
         AudioPlayer.instance.Pause();
     }
 }
Exemple #7
0
        public void EscapeText(string input, char escape, string expected)
        {
            CustomSetting setting;

            setting        = new CustomSetting();
            setting.Escape = escape;

            this.AssertRender(input, expected, setting, (s) => {}, (d) => {});
        }
Exemple #8
0
        public void TextTrim(string value, string pattern, string replacement, string expected)
        {
            CustomSetting setting;

            setting         = new CustomSetting();
            setting.Trimmer = (s) => Regex.Replace(s, pattern, replacement);

            this.AssertRender(value, expected, setting, (s) => {}, (d) => {});
        }
        /// <summary>
        /// 获取催办任务提醒设置
        /// </summary>
        /// <returns>催办任务提醒设置</returns>
        private Notice GetUrgencyNotice()
        {
            Notice notice = new Notice();

            notice.NotificationTitle        = Engine.SettingManager.GetCustomSetting(CustomSetting.Setting_UrgencyNotificationTitle);
            notice.Details                  = Engine.SettingManager.GetCustomSetting(CustomSetting.Setting_EmailUrgencyContent);
            notice.WetherSend               = GetBoolSetting(CustomSetting.Setting_NotifyUrgency);
            notice.NewTaskArrivedNotifyType = CustomSetting.GetNotifyType(Engine.SettingManager, CustomSetting.Setting_UrgencyNotifyType).ToString();
            return(notice);
        }
 public ScriptResolver(Dictionary <string, Script> scripts)
 {
     random = new Random();
     if (scripts != null)
     {
         this.scripts = scripts;
     }
     setting         = new CustomSetting();
     setting.Trimmer = BuiltinTrimmers.CollapseBlankCharacters;
 }
Exemple #11
0
        public static void CustomActions_DisableBypassRulesOnTarget(Configuration config)
        {
            MigrationSource target           = config.SessionGroup.MigrationSources.MigrationSource[1];
            var             enableBypassRule = new CustomSetting();

            enableBypassRule.SettingKey   = "EnableBypassRuleDataSubmission";
            enableBypassRule.SettingValue = "false";

            target.CustomSettings.CustomSetting.Add(enableBypassRule);
        }
        /// <summary>
        /// 获取超时提醒策略1
        /// </summary>
        /// <returns>超时提醒策略1</returns>
        private Notice GetOvertimePolicy1()
        {
            Notice notice = new Notice();

            notice.NotificationTitle        = Engine.SettingManager.GetCustomSetting(CustomSetting.Setting_RemindPolicy1Title);
            notice.Details                  = Engine.SettingManager.GetCustomSetting(CustomSetting.Setting_RemindPolicy1Content);
            notice.NewTaskArrivedNotifyType = CustomSetting.GetNotifyType(Engine.SettingManager, CustomSetting.Setting_RemindPolicy1NotifyType).ToString();
            notice.TimeInterval             = Engine.SettingManager.GetCustomSetting(CustomSetting.Setting_RemindPolicy1PostInterval);
            notice.RemindPostAction         = Engine.SettingManager.GetCustomSetting(CustomSetting.Setting_RemindPolicy1PostAction) ?? InitRemindPostAction().FirstOrDefault().Value;
            return(notice);
        }
Exemple #13
0
 public ScriptResolver(Dictionary <string, Script> scripts)
 {
     dataProviderService = new DataProviderService();
     bgsService          = new BgsService();
     random       = new Random();
     this.scripts = scripts ?? new Dictionary <string, Script>();
     setting      = new CustomSetting
     {
         Trimmer = BuiltinTrimmers.CollapseBlankCharacters
     };
 }
Exemple #14
0
        public static void CustomActions_DisableBypassRulesOnTarget(MigrationTestEnvironment env, Configuration config)
        {
            var enableBypassRule = new CustomSetting();

            enableBypassRule.SettingKey   = "EnableBypassRuleDataSubmission";
            enableBypassRule.SettingValue = "false";

            MigrationSource target = env.GetTargetMigrationSource(config);

            target.CustomSettings.CustomSetting.Add(enableBypassRule);
        }
Exemple #15
0
 //保存用户设置
 public void SaveCustomSetting()
 {
     if (cb_MusicSwitch.IsChecked != dv_musicSwitch)
     {
         CustomSetting.SetBool("IsMusicOn", cb_MusicSwitch.IsChecked);
     }
     else
     {
         CustomSetting.DeleteProperty("IsMusicOn");
     }
 }
        public void SetCustomSettings(int dayBegin, int dayEnd, int viewDays)
        {
            CustomSetting customSetting = new CustomSetting
            {
                ViewDays     = viewDays,
                WorkDayBegin = dayBegin,
                WorkDayEnd   = dayEnd
            };

            _customSettingRepository.SetCustomSettings(customSetting);
        }
Exemple #17
0
        public void TestAmbiguous()
        {
            CustomSetting setting;

            setting               = new CustomSetting();
            setting.BlockBegin    = "<|";
            setting.BlockContinue = "<>";
            setting.BlockEnd      = "|>";

            this.AssertRender("<|1 || 0|>", "true", setting, (s) => {}, (d) => {});
        }
        public IActionResult UpdateSetting([FromBody] CustomSetting setting)
        {
            //update instance
            var success = _settings.UpdateSetting(setting);

            if (success)
            {
                return(Ok(new { Message = "Setting updated." }));
            }
            return(Ok(new { Message = "Setting not updated." }));
        }
Exemple #19
0
        public static bool GetBooleanSettingValueDefaultToTrue(CustomSetting setting)
        {
            bool val;

            if (!bool.TryParse(setting.SettingValue, out val))
            {
                val = true;
            }

            return(val);
        }
Exemple #20
0
        private ISetting SettingCreate()
        {
            CustomSetting setting;

            setting               = new CustomSetting();
            setting.BlockBegin    = this.parameters.BlockBegin;
            setting.BlockContinue = this.parameters.BlockContinue;
            setting.BlockEnd      = this.parameters.BlockEnd;
            setting.Trimmer       = TrimmerCollection.GetTrimmer(this.parameters.TrimmerIndex);

            return(setting);
        }
Exemple #21
0
        private static string ValidateAndNormalizeDynamicViewRoot(CustomSetting setting)
        {
            string dynamicViewRoot = setting.SettingValue;
            // dynamicViewRoot should be stored in the form "<driveletter>:\", but we will accept value such as "m" or "n:"
            bool invalidDynamicViewRoot = false;

            if (dynamicViewRoot.Length < 1 || dynamicViewRoot.Length > 3)
            {
                invalidDynamicViewRoot = true;
            }
            else
            {
                char[] chars = dynamicViewRoot.ToCharArray();
                if (!Char.IsLetter(chars[0]))
                {
                    invalidDynamicViewRoot = true;
                }
                else
                {
                    if (chars.Length == 1)
                    {
                        dynamicViewRoot += ":\\";
                    }
                    else if (chars.Length == 2)
                    {
                        if (chars[1] != ':')
                        {
                            invalidDynamicViewRoot = true;
                        }
                        else
                        {
                            dynamicViewRoot += "\\";
                        }
                    }
                    else if (chars[1] != ':' || chars[2] != '\\')
                    {
                        invalidDynamicViewRoot = true;
                    }
                }
            }
            if (invalidDynamicViewRoot)
            {
                throw new MigrationException(String.Format(CultureInfo.InvariantCulture,
                                                           CCResources.InvalidDynamicViewRoot, setting.SettingKey, setting.SettingValue));
            }
            if (!Directory.Exists(dynamicViewRoot))
            {
                throw new MigrationException(String.Format(CultureInfo.InvariantCulture,
                                                           CCResources.DynamicViewRootDoesNotExist, setting.SettingKey, setting.SettingValue));
            }
            return(dynamicViewRoot);
        }
Exemple #22
0
        private static bool CustomSerializerHook(Type targetType, int fieldNumber, ref IProtoSerializer serializer)
        {
            ICustomProtoSerializer customSerializer = CustomSetting.TryGetCustomSerializer(targetType);

            if (customSerializer == null)
            {
                return(false);
            }

            serializer = Activator.CreateInstance(typeof(CustomDecorator),
                                                  new object[] { targetType, customSerializer, fieldNumber, serializer }) as IProtoSerializer;
            return(true);
        }
Exemple #23
0
        public void OptimizeReturn()
        {
            CustomSetting setting;

            setting          = new CustomSetting();
            setting.Optimize = false;

            this.AssertRender("X{return 1}Y", "X", setting, (s) => {}, (d) => {});

            setting.Optimize = true;

            this.AssertRender("X{return 1}Y", "X", setting, (s) => {}, (d) => {});
        }
Exemple #24
0
        public void OptimizeConstantMap()
        {
            CustomSetting setting;

            setting          = new CustomSetting();
            setting.Optimize = false;

            this.AssertRender("{['X', 'Y', 'Z'][0]}", "X", setting, (s) => {}, (d) => {});

            setting.Optimize = true;

            this.AssertRender("{['X', 'Y', 'Z'][0]}", "X", setting, (s) => {}, (d) => {});
        }
Exemple #25
0
        //解析完成规则
        private List <XElement> ParseFinishRuleDefinition(CustomSetting customSetting)
        {
            var scriptItems = new List <XElement>();

            if (customSetting.FinishRule != null)
            {
                customSetting.FinishRule.Scripts.ToList().ForEach(e =>
                {
                    scriptItems.Add(new XElement("line", new XAttribute("name", e.Key), new XCData(e.Value)));
                });
            }
            return(scriptItems);
        }
        static long HardDiskInf = (long)10 * 1024 * 1024 * 1024;//硬盘分区大小最小为10G
        private void initDefaultDownloadPath(CustomSetting setting)
        {
            DirectoryInfo root = new DirectoryInfo(setting.DownloadPath).Root;

            if (root.Exists)
            {
                var di = CenterStorageCmd.HardDiskSpaceManager.GetHardDiskSpace(root.FullName);
                if (di > HardDiskInf)
                {
                    return;
                }
            }
            setting.DownloadPath = getDefaultDownloadPath();
        }
    //从本地文件读取用户设置
    public static CustomSetting GetCustomSettingFromFile()
    {
        string path = Path.Combine(Application.dataPath, CustomSetting.path);

        try
        {
            string jsonData = File.ReadAllText(path);
            instance = JsonConvert.DeserializeObject <CustomSetting>(jsonData);
            return(instance);
        }
        catch (Exception e)
        {
            Debug.Log(e.Message);
            return(null);
        }
    }
Exemple #28
0
        public static void CustomActions_DisableCSSNodeCreationOnTarget(Configuration config)
        {
            MigrationSource target = config.SessionGroup.MigrationSources.MigrationSource[1];
            var             disableAreaPathCreation = new CustomSetting();

            disableAreaPathCreation.SettingKey = "DisableAreaPathAutoCreation";
            //disableAreaPathCreation.SettingValue = string.Empty;

            var disableIterationPathCreation = new CustomSetting();

            disableIterationPathCreation.SettingKey = "DisableIterationPathAutoCreation";
            //disableIterationPathCreation.SettingValue = string.Empty;

            target.CustomSettings.CustomSetting.Add(disableAreaPathCreation);
            target.CustomSettings.CustomSetting.Add(disableIterationPathCreation);
        }
Exemple #29
0
        //解析开始规则
        private XElement ParseStartRuleDefinition(CustomSetting customSetting)
        {
            XElement startRule;

            if (customSetting.StartRule == null)
            {
                startRule = new XElement("start", new XAttribute("at", ""), new XAttribute("after", ""), new XAttribute("zone", ""));
            }
            else
            {
                startRule = new XElement("start"
                                         , new XAttribute("at", customSetting.StartRule.At != null ? customSetting.StartRule.At.ToString() : string.Empty)
                                         , new XAttribute("after", customSetting.StartRule.AfterMinutes.HasValue ? customSetting.StartRule.AfterMinutes.ToString() : string.Empty)
                                         , new XAttribute("zone", customSetting.StartRule.TimeZone != null ? customSetting.StartRule.TimeZone.Name : string.Empty));
            }
            return(startRule);
        }
        /// <summary>
        /// Make changes to a custom setting.
        /// </summary>
        /// <param name="setting"></param>
        /// <returns></returns>
        public bool UpdateSetting(CustomSetting setting)
        {
            var dbSetting = (from p in _huapidbcontext.HUAPISettings where p.Name == setting.Name select p).SingleOrDefault();

            if (dbSetting == null)
            {
                return(false);
            }

            dbSetting.Value = setting.Value;    //update the single record read from the database and write it back
            _huapidbcontext.HUAPISettings.Update(dbSetting);
            _huapidbcontext.SaveChanges();

            Settings[setting.Name] = setting.Value;  //update value in memory instead of reading from database again (dangerous??)

            return(true);
        }
Exemple #31
0
 //解析开始规则
 private XElement ParseStartRuleDefinition(CustomSetting customSetting)
 {
     XElement startRule;
     if (customSetting.StartRule == null)
         startRule = new XElement("start", new XAttribute("at", ""), new XAttribute("after", ""), new XAttribute("zone", ""));
     else
         startRule = new XElement("start"
         , new XAttribute("at", customSetting.StartRule.At != null ? customSetting.StartRule.At.ToString() : string.Empty)
         , new XAttribute("after", customSetting.StartRule.AfterMinutes.HasValue ? customSetting.StartRule.AfterMinutes.ToString() : string.Empty)
         , new XAttribute("zone", customSetting.StartRule.TimeZone != null ? customSetting.StartRule.TimeZone.Name : string.Empty));
     return startRule;
 }
Exemple #32
0
 //解析完成规则
 private List<XElement> ParseFinishRuleDefinition(CustomSetting customSetting)
 {
     var scriptItems = new List<XElement>();
     if(customSetting.FinishRule != null)
         customSetting.FinishRule.Scripts.ToList().ForEach(e =>
         {
             scriptItems.Add(new XElement("line", new XAttribute("name", e.Key), new XCData(e.Value)));
         });
     return scriptItems;
 }