public void read() { MemoryStream stream = new MemoryStream(sampleData, false); VarConfig cfg = VarConfig.ReadNew(stream); testConfig(cfg); }
public void convert(string name, ParameterParser args, Stream from, Stream to) { var obj = VarConfig.ReadNew(from); byte[] buffer = Encoding.Default.GetBytes(Utils.convertToJSON(obj)); to.Write(buffer, 0, buffer.Length); }
internal static VarConfig.VariableRow CopyVariableFromAnotherConfig(VarConfig varConfig, VarConfig.VariableRow originalVar) { VarConfig.VariableRow variableRow = varConfig.Variable.AddVariableRow(originalVar.ID, originalVar.Name, originalVar.Monetary, originalVar.HHLevel, originalVar.AutoLabel); foreach (VarConfig.CountryLabelRow originalLabel in originalVar.GetCountryLabelRows()) { varConfig.CountryLabel.AddCountryLabelRow(originalLabel.ID, variableRow, originalLabel.Country, originalLabel.Label); } return(variableRow); }
/// <summary> /// 根据名称记录一个值,带保存 /// </summary> /// <param name="name"></param> /// <param name="value"></param> /// <returns></returns> public static void SetValue(string name, string value) { try { VarConfig.SetValue(name, value); VarConfig.Save(); } catch (Exception ex) { LogException(ex); } }
internal VariablesApplyAdministrator(MergeAdministrator mergeAdministrator, VariablesMergeForm mergeForm, VarConfigFacade vcFacLocal, VarConfigFacade vcFacRemote) { _mergeAdministrator = mergeAdministrator; _vcFacLocal = vcFacLocal; _vcLocal = _vcFacLocal.GetVarConfig(); _vcFacRemote = vcFacRemote; _vcRemote = _vcFacRemote.GetVarConfig(); _mergeForm = mergeForm; _mcVariables = _mergeForm.GetMergeControlByName(VariablesMergeForm.VARIABLES); _mcAcronyms = _mergeForm.GetMergeControlByName(VariablesMergeForm.ACRONYMS); _mcCountryLabels = _mergeForm.GetMergeControlByName(VariablesMergeForm.COUNTRY_LABELS); _mcSwitchablePolicies = _mergeForm.GetMergeControlByName(VariablesMergeForm.SWITCHABLE_POLICIES); }
public override void Run(System.Collections.Generic.Dictionary <string, object> arguments = null) { try { string varPath = Path.Combine(UISessionInfo.GetEuromodFilesFolder(), @"XMLParam\Config\VarConfig.xml"); varData = new VarConfig(); using (StreamReader streamReader = new StreamReader(varPath, DefGeneral.DEFAULT_ENCODING)) varData.ReadXml(streamReader); (new VariablesCheckerForm()).ShowDialog(); } catch (Exception exception) { MessageBox.Show(exception.Message); } }
public void write() { MemoryStream readStream = new MemoryStream(sampleData, false); VarConfig cfg = VarConfig.ReadNew(readStream); MemoryStream writeStream = new MemoryStream(); cfg.Write(writeStream); MemoryStream rereadStream = new MemoryStream(writeStream.ToArray(), false); VarConfig rereadCfg = VarConfig.ReadNew(rereadStream); testConfig(rereadCfg); }
/// <summary> /// 根据名字读取一个值 /// </summary> /// <param name="name"></param> /// <returns></returns> public static string GetValueString(string name) { try { string value = VarConfig.GetValue(name); if (!string.IsNullOrEmpty(value)) { return value; } } catch (Exception ex) { LogException(ex); } return string.Empty; }
internal bool LoadVarConfig() { try { if (_varConfig == null) { _varConfig = new VarConfig(); using (StreamReader streamReader = new StreamReader(_pathVarConfig, DefGeneral.DEFAULT_ENCODING)) _varConfig.ReadXml(streamReader); _varConfig.AcceptChanges(); } return(true); } catch (Exception exception) { Tools.UserInfoHandler.ShowException(exception); return(false); } }
private void testConfig(VarConfig cfg) { Assert.AreEqual(new byte[] { 0xc0, 0xff, 0xee }, cfg.header); Assert.AreEqual(1.0f, cfg.firstValue.floatValue, TOLERANCE); Assert.AreEqual("", cfg.firstValue.stringValue); Assert.AreEqual(3, cfg.variables.Count); Assert.True(cfg.variables.ContainsKey("MY_FLOAT_VAR")); Assert.AreEqual(2.0f, cfg.variables["MY_FLOAT_VAR"].floatValue, TOLERANCE); Assert.AreEqual("", cfg.variables["MY_FLOAT_VAR"].stringValue); Assert.True(cfg.variables.ContainsKey("MY_STRING_VAR")); Assert.AreEqual(0.0f, cfg.variables["MY_STRING_VAR"].floatValue, TOLERANCE); Assert.AreEqual("Zanzarah", cfg.variables["MY_STRING_VAR"].stringValue); Assert.True(cfg.variables.ContainsKey("MY_BOTH_VAR")); Assert.AreEqual(3.0f, cfg.variables["MY_BOTH_VAR"].floatValue); Assert.AreEqual("Hello", cfg.variables["MY_BOTH_VAR"].stringValue); }
internal static VarConfig.SwitchablePolicyRow CopySwitchPolicyFromAnotherConfig(VarConfig varConfig, VarConfig.SwitchablePolicyRow originalSP) { return(varConfig.SwitchablePolicy.AddSwitchablePolicyRow(originalSP.ID, originalSP.NamePattern, originalSP.LongName)); }