internal APGenSectionGroup GetSectionGroupInstance(SectionGroupInfo groupInfo) { APGenSectionGroup sectionGroup = groupInfo.CreateInstance() as APGenSectionGroup; if (sectionGroup != null) { sectionGroup.Initialize(this, groupInfo); } return(sectionGroup); }
/// <summary> /// Get a config section group by path. /// </summary> /// <param name="path">The path to get section group.</param> /// <returns>Config section group.</returns> public APGenSectionGroup GetSectionGroup(string path) { string[] parts = path.Split('/'); APGenSectionGroup group = SectionGroups[parts[0]]; for (int i = 1; group != null && i < parts.Length; i++) { group = group.SectionGroups[parts[i]]; } return(group); }
/// <summary> /// Gets or sets a APGenSectionGroup object contained in this APGenSectionGroupCollection object. /// </summary> /// <param name="name">The name of the APGenSectionGroup object to be returned.</param> /// <returns>The APGenSectionGroup object with the specified name.</returns> public APGenSectionGroup this[string name] { get { APGenSectionGroup section = BaseGet(name) as APGenSectionGroup; if (section == null) { SectionGroupInfo sectionInfo = _groupInfo.Groups[name] as SectionGroupInfo; if (sectionInfo == null) { return(null); } section = _gen.GetSectionGroupInstance(sectionInfo); BaseSet(name, section); } return(section); } }
internal void CreateSectionGroup(SectionGroupInfo parentGroup, string name, APGenSectionGroup section) { if (parentGroup.HasChild(name)) { throw new APGenException(APResource.GetString(APResource.APGen_SectionAlreadyExists, name)); } if (section.Type == null) { section.Type = GenHost.GetGenTypeName(section.GetType()); } section.SetName(name); SectionGroupInfo sectionInfo = new SectionGroupInfo(name, section.Type); sectionInfo.StreamName = _streamName; sectionInfo.GenHost = GenHost; parentGroup.AddChild(sectionInfo); _elementData[sectionInfo] = section; section.Initialize(this, sectionInfo); }
/// <summary> /// Get a config section by path. /// </summary> /// <param name="path">The path to get section.</param> /// <returns>Config section.</returns> public APGenSection GetSection(string path) { string[] parts = path.Split('/'); if (parts.Length == 1) { return(Sections[parts[0]]); } APGenSectionGroup group = SectionGroups[parts[0]]; for (int i = 1; group != null && i < parts.Length - 1; i++) { group = group.SectionGroups[parts[i]]; } if (group != null) { return(group.Sections[parts[parts.Length - 1]]); } else { return(null); } }
/// <summary> /// Adds a APGenSectionGroup object to this APGenSectionGroupCollection object. /// </summary> /// <param name="name">The name of the APGenSectionGroup object to be added.</param> /// <param name="sectionGroup">The APGenSectionGroup object to be added.</param> public void Add(string name, APGenSectionGroup sectionGroup) { _gen.CreateSectionGroup(_groupInfo, name, sectionGroup); }
/// <summary> /// Copies this APGenSectionGroupCollection object to an array. /// </summary> /// <param name="array">The array to copy the object to.</param> /// <param name="index">The index location at which to begin copying.</param> public void CopyTo(APGenSectionGroup[] array, int index) { for (int n = 0; n < _groupInfo.Groups.Count; n++) array[n + index] = this[n]; }
internal void CreateSectionGroup(SectionGroupInfo parentGroup, string name, APGenSectionGroup section) { if (parentGroup.HasChild(name)) throw new APGenException(APResource.GetString(APResource.APGen_SectionAlreadyExists, name)); if (section.Type == null) section.Type = GenHost.GetGenTypeName(section.GetType()); section.SetName(name); SectionGroupInfo sectionInfo = new SectionGroupInfo(name, section.Type); sectionInfo.StreamName = _streamName; sectionInfo.GenHost = GenHost; parentGroup.AddChild(sectionInfo); _elementData[sectionInfo] = section; section.Initialize(this, sectionInfo); }