/// <see cref="ConfigObjectContents.Load_i"/> protected override void Load_i(XElement rootElem) { IEnumerable <XElement> constElems = rootElem.Elements(CONSTANT_ELEM); foreach (XElement constElem in constElems) { XAttribute constNamespace = constElem.Attribute(NAMESPACE_ATTR); XAttribute constName = constElem.Attribute(NAME_ATTR); XAttribute constType = constElem.Attribute(TYPE_ATTR); if (constNamespace != null && constName != null && constType != null) { string newConstName = string.Format("{0}.{1}", constNamespace.Value, constName.Value); ConstantsTable.Add(newConstName, constElem.Value, constType.Value); } else { /// Error: no namespace, name or type defined throw new ConfigurationException("No namespace, name or type defined for constant!"); } } return; }
/// <summary> /// Initializes the ConfigurationManager with an absolute path to the file that describes the root /// configuration node. /// </summary> /// <param name="rootPath"> /// The absolute path to the file that describes the root configuration node. /// </param> /// <exception cref="ConfigurationException"> /// If the ConfigurationManager has already been initialized. /// In case of any error during the initialization process. /// </exception> public static void Initialize(string rootPath) { if (rootPath == null || rootPath.Length == 0) { throw new ArgumentNullException("rootPath"); } if (isInitialized) { throw new ConfigurationException("The ConfigurationManager has already been initialized."); } ConfigurationObject.UnregisterAllConfigObjects(); RCPackageFormatMap.Clear(); ConstantsTable.Clear(); TraceManager.UnregisterAllTraceFilters(); currentContext = new ConfigurationContext(); FileInfo rootNodeFile = new FileInfo(rootPath); rootNode = new ConfigurationNode(rootNodeFile); rootNode.LoadConfigObjects(currentContext); isInitialized = true; }