public static void LoadFpml(ILogger logger, ICoreCache targetClient) { Assembly assembly = Assembly.GetExecutingAssembly(); const string prefix = "Orion.Configuration.Config.FpMLCodes"; Dictionary <string, string> chosenFiles = ResourceHelper.GetResources(assembly, prefix, "xml"); if (chosenFiles.Count == 0) { throw new InvalidOperationException("Missing FpML Code Lists"); } foreach (var file in chosenFiles) { var data = XmlSerializerHelper.DeserializeFromString <CodeListDocument>(file.Value); string classDefName = GetClassDefName(data.Identification.ShortName); // determine primary key string primaryKey = null; foreach (Key key in data.ColumnSet.Key) { if (key.Id == "PrimaryKey") { if (primaryKey != null) { throw new ApplicationException("PrimaryKey defined more than once!"); } primaryKey = key.ColumnRef[0].Ref; } } if (primaryKey == null) { throw new ApplicationException("PrimaryKey is not defined!"); } // load rows IFpMLCodeScheme scheme = FpMLCodeSchemeFactory.CreateCodeScheme(classDefName); foreach (Row row in data.SimpleCodeList.Row) { IFpMLCodeValue codeValue = scheme.CreateCodeValue(row); if (scheme is DayCountFractionScheme) { var dcfValue = (DayCountFractionValue)codeValue; if (dcfValue.HLClassName == null) { dcfValue.HLClassName = "DefaultClassName"; } } scheme.AddCodeValue(codeValue); } targetClient.SaveTypedObject(scheme.GetType(), scheme, scheme.GetItemName(null), scheme.GetItemProps()); } // foreach file logger.LogDebug("Loaded FpML code lists."); }