private void ConvertPropertyNamesToCamelCase(ValidatorRules validatorRules) { // Workaround as System.Text.Json in ASP.NET 3 cannot serialise property keys. // Although unnecessary for ASP.NET Core 2.2, it's too expensive to check! var newValidatorList = new SerialisableDictionary <string, SerialisableDictionary <string, object> >(); foreach (var item in validatorRules.ValidatorList) { newValidatorList.Add(item.Key.ToCamelCase(), validatorRules.ValidatorList[item.Key]); } var newErrorList = new SerialisableDictionary <string, SerialisableDictionary <string, string> >(); foreach (var item in validatorRules.ErrorList) { newErrorList.Add(item.Key.ToCamelCase(), validatorRules.ErrorList[item.Key]); } var newTypeList = new SerialisableDictionary <string, string>(); foreach (var item in validatorRules.TypeList) { newTypeList.Add(item.Key.ToCamelCase(), validatorRules.TypeList[item.Key]); } validatorRules.ValidatorList = newValidatorList; validatorRules.ErrorList = newErrorList; validatorRules.TypeList = newTypeList; }
public Configuration() { Authentication = new AuthenticationProfile(); Proxy = new ProxyProfile(); ServerProfiles = new List<ServerProfile>(); ChampionNames = new SerialisableDictionary<int, string>(); }
public Configuration() { Authentication = new AuthenticationProfile(); Proxy = new ProxyProfile(); ServerProfiles = new List <ServerProfile>(); ChampionNames = new SerialisableDictionary <int, string>(); }
public void DeserialiseAppearanceList() { var directory = Directory.GetCurrentDirectory(); var listFilePath = Path.Combine(directory, "DigimonAppearances.xml"); var fileStream = new FileStream(listFilePath, FileMode.OpenOrCreate); using (fileStream) { AppearanceValues = new XmlSerializer(typeof(SerialisableDictionary <string, AppearanceOptions>)).Deserialize(fileStream) as SerialisableDictionary <string, AppearanceOptions>; } }
private void SetDictionariesCaseInsensitive(List <ArmourChart> armourCharts) { foreach (var armourChart in armourCharts) { var dictionary = new SerialisableDictionary <string, string>(StringComparer.OrdinalIgnoreCase); foreach (var digivolution in armourChart.DigimentalDigivolution) { dictionary.Add(digivolution.Key, digivolution.Value); } armourChart.DigimentalDigivolution = dictionary; } }
static void Main(string[] args) { SerialisableDictionary sd = new SerialisableDictionary(); XmlSerializer x = new XmlSerializer(sd.GetType()); using (StreamReader sr = new StreamReader(@"XMLFile1.xml")) { sd = (SerialisableDictionary)x.Deserialize(sr); } foreach (var kvp in sd) { Console.WriteLine(kvp.Key + " = " + kvp.Value); } Console.WriteLine("Done."); Console.ReadKey(); }
public static SerialisableDictionary CreateConfigDictionary(object[,] ConfigMatrix) { SerialisableDictionary cd = new SerialisableDictionary(); int r = ConfigMatrix.GetLength(0); int c = ConfigMatrix.GetLength(1); if (c == 2) { for (int x = 0; x < r; ++x) { if (!ConfigMatrix[x, 0].Equals(ExcelDna.Integration.ExcelEmpty.Value)) { if (XLOM.Contains(ConfigMatrix[x, 1].ToString(), true)) { cd[ConfigMatrix[x, 0].ToString()] = XLOM.Get(ConfigMatrix[x, 1].ToString()); } else { cd[ConfigMatrix[x, 0].ToString()] = ConfigMatrix[x, 1]; } } } } else if (c > 2) { for (int cc = 1; cc < c; ++cc) { string colName = ConfigMatrix[0, cc].ToString(); Dictionary <string, object> cdd = new Dictionary <string, object>(); for (int x = 1; x < r; ++x) { cdd[ConfigMatrix[x, 0].ToString()] = ConfigMatrix[x, cc]; } cd.Add(colName, cdd); } } return(cd); }
private void SetAppearanceNames() { var uniques = AppearanceValues.Where(x => string.Equals(x.Key, AppearanceValues.FirstOrDefault(y => y.Value.Value == x.Value.Value).Key, StringComparison.OrdinalIgnoreCase)); AppearanceNames = new SerialisableDictionary <float, string>(uniques.ToDictionary(x => x.Value.Value, x => x.Key)); }
public ArmourChart() { DigimentalDigivolution = new SerialisableDictionary <string, string>(StringComparer.OrdinalIgnoreCase); }