public static object GetConfigurableData(string sectionName, Type configurableDataType) { object configurableData = null; IConfigSection configSection = ConfigData.Machine.GetSection(sectionName); if (configSection != null) { try { configurableData = configSection.LoadFromXml(); } catch (Exception exc) { Log.WriteInfo( "Failed loading contents of [{0}] section in configuration data, {1}", sectionName, exc.Message); } } if (configurableData == null) { try { configurableData = Activator.CreateInstance(configurableDataType); } catch (Exception exc) { Log.WriteInfo( "Failed instantiating of configurable data type [{0}]. Details : [{1}]", configurableDataType.Name, exc.Message); return(null); } try { if (configSection == null) { configSection = ConfigData.Machine.GetOrCreateSection(sectionName); } configSection.StoreAsXml(configurableData); ConfigData.Machine.SaveAllSections(); } catch (Exception exc) { Log.WriteInfo( "Failed saving contents of [{0}] section in configuration data, {1}", sectionName, exc.Message); } } return(configurableData); }