public object ReadValue(IMemberInfoWrapper memberInfoWrapper, object configuration, Type configurationType) { var(converter, defaultConverter, typeDetailsInformation) = _iniConverterFactory.GetConverter(memberInfoWrapper.GetMemberType(), 0, memberInfoWrapper); if (typeDetailsInformation.TypeCode == TypeCode.ComplexObject) { return(converter.ParseReadValue(null, typeDetailsInformation.Type, null)); } var iniValue = new IniValue() { Section = _iniValueManager.GetSection(configurationType, memberInfoWrapper), Key = _iniValueManager.GetKey(memberInfoWrapper) }; try { var iniContext = new IniContext(memberInfoWrapper, typeDetailsInformation, iniValue, _iniParser, defaultConverter); var readValue = _iniParser.Read(iniValue.Section, iniValue.Key); return(converter.ParseReadValue(readValue, typeDetailsInformation.Type, iniContext)); } catch (FormatException) { throw new IniWrongFormatException($"Wrong format in {iniValue} expected type: {memberInfoWrapper.GetMemberType()}"); } }
public override bool Equals(object obj) { IniValue <T> value = obj as IniValue <T>; return(value != null && EqualityComparer <T> .Default.Equals(this.value, value.value)); }
/// <summary> /// Store all GreenshotControl values to the configuration /// </summary> protected void StoreFields() { bool iniDirty = false; foreach (FieldInfo field in GetCachedFields(GetType())) { Object controlObject = field.GetValue(this); if (controlObject == null) { continue; } IGreenshotConfigBindable configBindable = controlObject as IGreenshotConfigBindable; if (configBindable == null) { continue; } if (!string.IsNullOrEmpty(configBindable.SectionName) && !string.IsNullOrEmpty(configBindable.PropertyName)) { IniSection section = IniConfig.GetIniSection(configBindable.SectionName); if (section != null) { IniValue iniValue = null; if (!section.Values.TryGetValue(configBindable.PropertyName, out iniValue)) { continue; } CheckBox checkBox = controlObject as CheckBox; if (checkBox != null) { iniValue.Value = checkBox.Checked; iniDirty = true; continue; } RadioButton radioButton = controlObject as RadioButton; if (radioButton != null) { iniValue.Value = radioButton.Checked; iniDirty = true; continue; } GreenshotComboBox comboxBox = controlObject as GreenshotComboBox; if (comboxBox != null) { iniValue.Value = comboxBox.GetSelectedEnum(); iniDirty = true; continue; } } } } if (iniDirty) { //IniConfig.Save(); } }
private void AnswerDIY_Load(object sender, EventArgs e) { string path = $@"{CQSave.cq_menu.CQApi.AppDirectory}Config.ini"; textBox_OrderKC1.Text = INIhelper.IniRead("Order", "KC1", "#扩充单抽", path); textBox_OrderKC10.Text = INIhelper.IniRead("Order", "KC10", "#扩充十连", path); textBox_OrderJZ1.Text = INIhelper.IniRead("Order", "JZ1", "#精准单抽", path); textBox_OrderJZ10.Text = INIhelper.IniRead("Order", "JZ10", "#精准十连", path); textBox_OrderRegiter.Text = INIhelper.IniRead("Order", "Register", "#抽卡注册", path); textBox_OrderSign.Text = INIhelper.IniRead("Order", "Sign", "#打扫甲板", path); textBox_OrderSignReset.Text = INIhelper.IniRead("Order", "SignReset", "#甲板积灰", path); textBox_OrderQueryDiamond.Text = INIhelper.IniRead("Order", "QueryDiamond", "#我的水晶", path); textBox_OrderHelp.Text = INIhelper.IniRead("Order", "Help", "#抽卡帮助", path); textBox_OrderGetPool.Text = INIhelper.IniRead("Order", "GetPool", "#获取池子", path); textBox_AnsKC1.Text = INIhelper.IniRead("Answer", "KC1", "少女祈祷中……", path); textBox_AnsKC10.Text = INIhelper.IniRead("Answer", "KC10", "少女祈祷中……", path); textBox_AnsJZ1.Text = INIhelper.IniRead("Answer", "JZ1", "少女祈祷中……", path); textBox_AnsJZ10.Text = INIhelper.IniRead("Answer", "JZ10", "少女祈祷中……", path); textBox_AnsRegister.Text = INIhelper.IniRead("Answer", "Register", "<@>欢迎上舰,这是你的初始资源(<#>)水晶", path); textBox_AnsMutiRegister.Text = INIhelper.IniRead("Answer", "MutiRegister", "重复注册是不行的哦", path); textBox_AnsSign1.Text = INIhelper.IniRead("Answer", "Sign1", "大姐你回来了,天气这么好一起多逛逛吧", path); textBox_AnsSign2.Text = INIhelper.IniRead("Answer", "Sign2", "<@>这是你今天清扫甲板的报酬,拿好(<#>水晶)", path); textBox_AnsMutiSign.Text = INIhelper.IniRead("Answer", "MutiSign", "今天的甲板挺亮的,擦一遍就行了", path); textBox_AnsQueryDiamond.Text = INIhelper.IniRead("Answer", "QueryDiamond", "<@>你手头还有<#>水晶", path); textBox_AnsNoReg.Text = INIhelper.IniRead("Answer", "NoReg", "<@>不是清洁工吧?来输入#抽卡注册 来上舰", path); textBox_AnsLowDiamond.Text = INIhelper.IniRead("Answer", "LowDiamond", "<@>水晶不足,无法进行抽卡,你还剩余<#>水晶", path); IniObject iObject = IniObject.Load(path, Encoding.Unicode); // 从指定的文件中读取 Ini 配置项, 参数1: 文件路径, 参数2: 编码格式 [默认: ANSI] try { IniValue value1 = iObject["Answer"]["Help"]; textBox_AnsHelp.Text = value1.ToString(); } catch { textBox_AnsHelp.Text = ""; } if (textBox_AnsHelp.Text == "") { textBox_AnsHelp.Text = @"水银抽卡人 给你抽卡的自信(~ ̄▽ ̄)~ \n合成图片以及发送图片需要一些时间,请耐心等待\n单抽是没有保底的\n#抽卡注册\n#我的水晶\n#打扫甲板(签到)\n#甲板积灰(重置签到,管理员限定)\n#获取池子\n\n#精准单抽\n#扩充单抽\n#精准十连\n#扩充十连"; } textBox_SignReset1.Text = INIhelper.IniRead("Answer", "Reset1", "贝贝龙来甲板找女王♂van,把甲板弄脏了,大家又得打扫一遍", path); textBox_SignReset2.Text = INIhelper.IniRead("Answer", "Reset2", "草履虫非要给鸭子做饭,厨房爆炸了,黑紫色的东西撒了一甲板,把甲板弄脏了,大家又得打扫一遍", path); textBox_SignReset3.Text = INIhelper.IniRead("Answer", "Reset3", "你和女武神们被从深渊扔了回来,来自深渊的炉灰把甲板弄脏了,大家又得打扫一遍", path); textBox_SignReset4.Text = INIhelper.IniRead("Answer", "Reset4", "由于神秘东方村庄的诅咒,你抽卡的泪水把甲板弄脏了,大家又得打扫一遍", path); textBox_SignReset5.Text = INIhelper.IniRead("Answer", "Reset5", "理律疯狂在甲板上逮虾户,把甲板弄脏了,大家又得打扫一遍", path); textBox_SignReset6.Text = INIhelper.IniRead("Answer", "Reset6", "希儿到处找不到鸭子,里人格暴走,把甲板弄脏了,大家又得打扫一遍", path); textBox_ResisterMin.Text = INIhelper.IniRead("GetDiamond", "RegisterMin", "0", path); textBox_RegisterMax.Text = INIhelper.IniRead("GetDiamond", "RegisterMax", "14000", path); textBox_SignMin.Text = INIhelper.IniRead("GetDiamond", "SignMin", "0", path); textBox_SignMax.Text = INIhelper.IniRead("GetDiamond", "SignMax", "14000", path); }
void ReadConfig(CQGroupMessageEventArgs e) { string path = $@"{cq.CQApi.AppDirectory}Config.ini"; order_KC1 = INIhelper.IniRead("Order", "KC1", "#扩充单抽", path); order_KC10 = INIhelper.IniRead("Order", "KC10", "#扩充十连", path); order_JZ1 = INIhelper.IniRead("Order", "JZ1", "#精准单抽", path); order_JZ10 = INIhelper.IniRead("Order", "JZ10", "#精准十连", path); order_register = INIhelper.IniRead("Order", "Register", "#抽卡注册", path); order_sign = INIhelper.IniRead("Order", "Sign", "#打扫甲板", path); order_signreset = INIhelper.IniRead("Order", "SignReset", "#甲板积灰", path); order_querydiamond = INIhelper.IniRead("Order", "QueryDiamond", "#我的水晶", path); order_help = INIhelper.IniRead("Order", "Help", "#抽卡帮助", path); order_getpool = INIhelper.IniRead("Order", "GetPool", "#获取池子", path); KC1 = INIhelper.IniRead("Answer", "KC1", "少女祈祷中……", path); KC10 = INIhelper.IniRead("Answer", "KC10", "少女祈祷中……", path); JZ1 = INIhelper.IniRead("Answer", "JZ1", "少女祈祷中……", path); JZ10 = INIhelper.IniRead("Answer", "JZ10", "少女祈祷中……", path); register = INIhelper.IniRead("Answer", "Register", "<@>欢迎上舰,这是你的初始资源(<#>)水晶", path); mutiRegister = INIhelper.IniRead("Answer", "MutiRegister", "重复注册是不行的哦", path); sign1 = INIhelper.IniRead("Answer", "Sign1", "大姐你回来了,天气这么好一起多逛逛吧", path); sign2 = INIhelper.IniRead("Answer", "Sign2", "<@>这是你今天清扫甲板的报酬,拿好(<#>水晶)", path); mutiSign = INIhelper.IniRead("Answer", "MutiSign", "今天的甲板挺亮的,擦一遍就行了", path); noReg = INIhelper.IniRead("Answer", "NoReg", "<@>不是清洁工吧?来输入#抽卡注册 来上舰", path); lowDiamond = INIhelper.IniRead("Answer", "LowDiamond", "<@>水晶不足,无法进行抽卡,你还剩余<#>水晶", path); queryDiamond = INIhelper.IniRead("Answer", "QueryDiamond", "<@>你手头还有<#>水晶", path); IniObject iObject = IniObject.Load(path, Encoding.Default); // 从指定的文件中读取 Ini 配置项, 参数1: 文件路径, 参数2: 编码格式 [默认: ANSI] try { IniValue value1 = iObject["Answer"]["Help"]; help = value1.ToString().Replace("\\", @"\"); } catch { help = ""; } if (help == "") { help = "水银抽卡人 给你抽卡的自信(~ ̄▽ ̄)~ \n合成图片以及发送图片需要一些时间,请耐心等待\n单抽是没有保底的\n#抽卡注册\n#我的水晶\n#打扫甲板(签到)\n#甲板积灰(重置签到,管理员限定)\n\n#精准单抽\n#扩充单抽\n#精准十连\n#扩充十连"; } reset1 = INIhelper.IniRead("Answer", "Reset1", "贝贝龙来甲板找女王♂van,把甲板弄脏了,大家又得打扫一遍", path); reset2 = INIhelper.IniRead("Answer", "Reset2", "草履虫非要给鸭子做饭,厨房爆炸了,黑紫色的东西撒了一甲板,把甲板弄脏了,大家又得打扫一遍", path); reset3 = INIhelper.IniRead("Answer", "Reset3", "你和女武神们被从深渊扔了回来,来自深渊的炉灰把甲板弄脏了,大家又得打扫一遍", path); reset4 = INIhelper.IniRead("Answer", "Reset4", "由于神秘东方村庄的诅咒,你抽卡的泪水把甲板弄脏了,大家又得打扫一遍", path); reset5 = INIhelper.IniRead("Answer", "Reset5", "理律疯狂在甲板上逮虾户,把甲板弄脏了,大家又得打扫一遍", path); reset6 = INIhelper.IniRead("Answer", "Reset6", "希儿到处找不到鸭子,里人格暴走,把甲板弄脏了,大家又得打扫一遍", path); registermin = Convert.ToInt32(INIhelper.IniRead("GetDiamond", "RegisterMin", "0", path)); registermax = Convert.ToInt32(INIhelper.IniRead("GetDiamond", "RegisterMax", "14000", path)); signmin = Convert.ToInt32(INIhelper.IniRead("GetDiamond", "SignMin", "0", path)); signmax = Convert.ToInt32(INIhelper.IniRead("GetDiamond", "SignMax", "14000", path)); }
private void QuickSettingBoolItemChanged(object sender, EventArgs e) { ToolStripMenuSelectListItem item = ((ItemCheckedChangedEventArgs)e).Item; IniValue iniValue = item.Data as IniValue; if (iniValue != null) { iniValue.Value = item.Checked; IniConfig.Save(); } }
/// <summary> /// Fill all GreenshotControls with the values from the configuration /// </summary> protected void FillFields() { foreach (FieldInfo field in GetCachedFields(GetType())) { Object controlObject = field.GetValue(this); if (controlObject == null) { continue; } IGreenshotConfigBindable configBindable = controlObject as IGreenshotConfigBindable; if (configBindable == null) { continue; } if (!string.IsNullOrEmpty(configBindable.SectionName) && !string.IsNullOrEmpty(configBindable.PropertyName)) { IniSection section = IniConfig.GetIniSection(configBindable.SectionName); if (section != null) { IniValue iniValue = null; if (!section.Values.TryGetValue(configBindable.PropertyName, out iniValue)) { LOG.DebugFormat("Wrong property '{0}' configured for field '{1}'", configBindable.PropertyName, field.Name); continue; } CheckBox checkBox = controlObject as CheckBox; if (checkBox != null) { checkBox.Checked = (bool)iniValue.Value; checkBox.Enabled = !iniValue.IsFixed; continue; } RadioButton radíoButton = controlObject as RadioButton; if (radíoButton != null) { radíoButton.Checked = (bool)iniValue.Value; radíoButton.Enabled = !iniValue.IsFixed; continue; } GreenshotComboBox comboxBox = controlObject as GreenshotComboBox; if (comboxBox != null) { comboxBox.Populate(iniValue.ValueType); comboxBox.SetValue((Enum)iniValue.Value); comboxBox.Enabled = !iniValue.IsFixed; continue; } } } } OnFieldsFilled(); }
public IniContext(IMemberInfoWrapper memberInfoWrapper, TypeDetailsInformation typeDetailsInformation, IniValue iniValue, IIniParser iniParser, IIniConverter defaultConverter) { MemberInfoWrapper = memberInfoWrapper; TypeDetailsInformation = typeDetailsInformation; IniValue = iniValue; IniParser = iniParser; DefaultConverter = defaultConverter; }
public void SetValue(string key, string value) { if (!SortedEntries.ContainsKey(key)) { IniValue val = value; OrderedEntries.Add(new KeyValuePair <string, IniValue>(key, val)); SortedEntries[key] = val; } else { SortedEntries[key].Set(value); } }
public void SetValue(string key, string value, bool @override = true) { if (!SortedEntries.ContainsKey(key)) { IniValue val = value; OrderedEntries.Add(new KeyValuePair <string, IniValue>(key, val)); SortedEntries[key] = val; } else if (@override) { SortedEntries[key].Set(value); OrderedEntries.RemoveAll(e => e.Key == key); OrderedEntries.Add(new KeyValuePair <string, IniValue>(key, value)); } }
public SetIniPage() { InitializeComponent(); useNum = (App.Current as App).accessDB.GetUserNumber((App.Current as App).action.name); iniValue = (App.Current as App).accessDB.GetDefaultIniValue(useNum); FinancialTargetIniValueCollection.DataContext = iniValue.FinancialTargetIniValueCollection; ProductIniNum.DataContext = iniValue.ProductIniNum; ProductReaschIniStatus.DataContext = iniValue.ProductReaschIniStatus; FinanceServiceIni.DataContext = iniValue.FinanceServiceIni; ProductLineIniStatus.DataContext = iniValue.ProductLineIniStatus; MarketQuaIni.DataContext = iniValue.MarketQuaIni; UncollectibleAccountsIni.DataContext = iniValue.UncollectibleAccountsIni; RawMaterialNumIni.DataContext = iniValue.RawMaterialNumIni; }
private bool LoadValue(string line, out string key, out IniValue val) { int assignIndex = line.IndexOf('='); if (assignIndex <= 0) { key = null; val = null; return(false); } key = line.Substring(0, assignIndex).Trim(); string value = line.Substring(assignIndex + 1); val = new IniValue(value); return(true); }
}//FINISH PM_OnDataAvailable void PM_OnProcessUnknownIniParameter(IniValue param, ref bool processed) { //throw new NotImplementedException(); //GET PARAMETERS FROM INI file webAddress = ""; enableWebService = false; if (param.Name.ToUpper() == "BESCONSULTING") { try { webAddress = param.ValueOf("webserviceaddress", ""); enableWebService = param.ValueOf("enablewebservice", "").ToUpper() == "YES"; } catch (Exception ex) { param.ErrorDescription = ex.Message; throw (ex); } processed = true; } }//FINISH PM_OnProcessUnknownIniParameter
void ReadConfig() { string path = $@"{cq.CQApi.AppDirectory}Config.ini"; order_KC1 = INIhelper.IniRead("Order", "KC1", "#扩充单抽", path); order_KC10 = INIhelper.IniRead("Order", "KC10", "#扩充十连", path); order_JZ1 = INIhelper.IniRead("Order", "JZ1", "#精准单抽", path); order_JZ10 = INIhelper.IniRead("Order", "JZ10", "#精准十连", path); order_register = INIhelper.IniRead("Order", "Register", "#抽卡注册", path); order_sign = INIhelper.IniRead("Order", "Sign", "#打扫甲板", path); order_signreset = INIhelper.IniRead("Order", "SignReset", "#甲板积灰", path); order_querydiamond = INIhelper.IniRead("Order", "QueryDiamond", "#我的水晶", path); order_help = INIhelper.IniRead("Order", "Help", "#抽卡帮助", path); order_getpool = INIhelper.IniRead("Order", "GetPool", "#获取池子", path); KC1 = INIhelper.IniRead("Answer", "KC1", "少女祈祷中……", path); KC10 = INIhelper.IniRead("Answer", "KC10", "少女祈祷中……", path); JZ1 = INIhelper.IniRead("Answer", "JZ1", "少女祈祷中……", path); JZ10 = INIhelper.IniRead("Answer", "JZ10", "少女祈祷中……", path); register = INIhelper.IniRead("Answer", "Register", "<@>欢迎上舰,这是你的初始资源(<#>)水晶", path); sign1 = INIhelper.IniRead("Answer", "Sign1", "大姐你回来了,天气这么好一起多逛逛吧", path); sign2 = INIhelper.IniRead("Answer", "Sign2", "<@>这是你今天清扫甲板的报酬,拿好(<#>水晶)", path); querydiamond = INIhelper.IniRead("Answer", "QueryDiamond", "<@>你手头还有<#>水晶", path); IniObject iObject = IniObject.Load(path, Encoding.Default); // 从指定的文件中读取 Ini 配置项, 参数1: 文件路径, 参数2: 编码格式 [默认: ANSI] IniValue value1 = iObject["Answer"]["Help"]; help = value1.ToString(); reset1 = INIhelper.IniRead("Answer", "Reset1", "贝贝龙来甲板找女王♂van,把甲板弄脏了,大家又得打扫一遍", path); reset2 = INIhelper.IniRead("Answer", "Reset2", "草履虫非要给鸭子做饭,厨房爆炸了,黑紫色的东西撒了一甲板,把甲板弄脏了,大家又得打扫一遍", path); reset3 = INIhelper.IniRead("Answer", "Reset3", "你和女武神们被从深渊扔了回来,来自深渊的炉灰把甲板弄脏了,大家又得打扫一遍", path); reset4 = INIhelper.IniRead("Answer", "Reset4", "由于神秘东方村庄的诅咒,你抽卡的泪水把甲板弄脏了,大家又得打扫一遍", path); reset5 = INIhelper.IniRead("Answer", "Reset5", "理律疯狂在甲板上逮虾户,把甲板弄脏了,大家又得打扫一遍", path); reset6 = INIhelper.IniRead("Answer", "Reset6", "希儿到处找不到鸭子,里人格暴走,把甲板弄脏了,大家又得打扫一遍", path); registermin = Convert.ToInt32(INIhelper.IniRead("GetDiamond", "RegisterMin", "0", path)); registermax = Convert.ToInt32(INIhelper.IniRead("GetDiamond", "RegisterMax", "14000", path)); signmin = Convert.ToInt32(INIhelper.IniRead("GetDiamond", "SignMin", "0", path)); signmax = Convert.ToInt32(INIhelper.IniRead("GetDiamond", "SignMax", "14000", path)); }
public void WriteString(string strName, string strValue, int nLine, List <string> Comments) { IniValue v; if (m_values.TryGetValue(strName, out v)) { v.strValue = strValue; if (Comments != null) { v.m_strComment = new List <string>(Comments.ToArray()); } m_values[strName] = v; } else { v = new IniValue(strValue, nLine); if (Comments != null) { v.m_strComment = new List <string>(Comments.ToArray()); } m_values[strName] = v; } }
public void SaveValue(IMemberInfoWrapper memberInfoWrapper, object configuration) { var value = memberInfoWrapper.GetValue(configuration); var defaultIniValue = new IniValue() { Section = _iniValueManager.GetSection(configuration.GetType(), memberInfoWrapper), Key = _iniValueManager.GetKey(memberInfoWrapper), }; var(converter, defaultConverter, typeDetailsInformation) = _iniConverterFactory.GetConverter(memberInfoWrapper.GetMemberType(), value, memberInfoWrapper); var iniContext = new IniContext(memberInfoWrapper, typeDetailsInformation, defaultIniValue, _iniParser, defaultConverter); var valueToSave = converter.FormatToWrite(value, iniContext); if (valueToSave?.Value == null) { return; } _iniParser.Write(valueToSave.Section, valueToSave.Key, valueToSave.Value); }
protected bool Equals(IniValue other) { return(string.Equals(value, other.value)); }
public PsdSection() : base(nameof(PsdSection), true) { LayerOrder = BindString(nameof(LayerOrder), "name"); Reversed = BindInt32(nameof(Reversed), 0); }
public AtlasSection() : base(nameof(AtlasSection), true) { TotalAtlases = BindInt32(nameof(TotalAtlases), 1); TileSize = BindInt32(nameof(TileSize), 32); AtlasSide = BindInt32(nameof(AtlasSide), 2048); }