Example #1
0
        /// <summary>
        /// Removes the APGenSectionGroup object whose name is specified from this APGenSectionGroupCollection object.
        /// </summary>
        /// <param name="name">The name of the section group to be removed.</param>
        public void Remove(string name)
        {
            SectionGroupInfo secData = _groupInfo.Groups[name] as SectionGroupInfo;

            if (secData != null)
            {
                _gen.RemoveGenInfo(secData);
            }
        }
Example #2
0
        internal APGenSectionGroup GetSectionGroupInstance(SectionGroupInfo groupInfo)
        {
            APGenSectionGroup sectionGroup = groupInfo.CreateInstance() as APGenSectionGroup;

            if (sectionGroup != null)
            {
                sectionGroup.Initialize(this, groupInfo);
            }
            return(sectionGroup);
        }
Example #3
0
        internal void Initialize(APGen gen, SectionGroupInfo groupInfo)
        {
            if (_initialized)
            {
                throw new SystemException(APResource.GetString(APResource.APGen_SectionInitTwice, GetType()));
            }

            _initialized = true;
            _gen         = gen;
            _groupInfo   = groupInfo;
        }
Example #4
0
 /// <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);
     }
 }
Example #5
0
        internal void CreateSection(SectionGroupInfo groupInfo, string name, APGenSection section)
        {
            if (groupInfo.HasChild(name))
            {
                throw new APGenException(APResource.GetString(APResource.APGen_SectionAlreadyExists, name));
            }

            if (section.SectionInformation.Type == null)
            {
                section.SectionInformation.Type = GenHost.GetGenTypeName(section.GetType());
            }

            SectionInfo sectionInfo = new SectionInfo(name, section.SectionInformation);

            sectionInfo.StreamName = _streamName;
            sectionInfo.GenHost    = GenHost;
            groupInfo.AddChild(sectionInfo);
            _elementData[sectionInfo] = section;
        }
Example #6
0
        internal void Init(string virtualPath)
        {
            _genPath                  = virtualPath;
            _streamName               = _host.GetStreamName(virtualPath);
            _rootGroupInfo            = new SectionGroupInfo();
            _rootGroupInfo.StreamName = _streamName;

            if (!String.IsNullOrEmpty(_streamName))
            {
                using (XmlTextReader reader = new XmlTextReader(_host.OpenStreamForRead(_streamName)))
                {
                    ReadGenFile(reader, _streamName);
                }
            }

            _codeCompileUnit = new CodeCompileUnit();
            CodeNamespace defaultNamespace = new CodeNamespace(_rootNamespace);

            _namespace.Add(_rootNamespace, defaultNamespace);
            _codeCompileUnit.Namespaces.Add(defaultNamespace);
        }
Example #7
0
        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);
        }
Example #8
0
        private GenInfo GetGenInfo(XmlReader reader, SectionGroupInfo current)
        {
            GenInfo data = null;

            if (current._sections != null)
            {
                data = current._sections[reader.LocalName];
            }
            if (data != null)
            {
                return(data);
            }

            if (current._groups != null)
            {
                data = current._groups[reader.LocalName];
            }
            if (data != null)
            {
                return(data);
            }

            if (current._groups == null)
            {
                return(null);
            }

            foreach (string key in current._groups.AllKeys)
            {
                data = GetGenInfo(reader, (SectionGroupInfo)current._groups[key]);
                if (data != null)
                {
                    return(data);
                }
            }

            return(null);
        }
Example #9
0
        public override void ReadGen(APGen gen, string streamName, XmlTextReader reader)
        {
            StreamName = streamName;
            GenHost    = gen.GenHost;

            if (reader.LocalName != "genSections")
            {
                while (reader.MoveToNextAttribute())
                {
                    if (reader.Name == "name")
                    {
                        Name = reader.Value;
                    }
                    else if (reader.Name == "type")
                    {
                        TypeName = reader.Value;
                        Type     = null;
                    }
                    else
                    {
                        ThrowException(APResource.GetString(APResource.APGen_UnrecognizedAttribute, ""), reader);
                    }
                }

                if (Name == null)
                {
                    ThrowException(APResource.GetString(APResource.APGen_MissingRequiredAttribute, "sectionGroup", "name"), reader);
                }
            }

            if (TypeName == null)
            {
                TypeName = typeof(APGenSectionGroup).FullName;
            }

            if (reader.IsEmptyElement)
            {
                reader.Skip();
                return;
            }

            reader.ReadStartElement();
            reader.MoveToContent();

            while (reader.NodeType != XmlNodeType.EndElement)
            {
                if (reader.NodeType != XmlNodeType.Element)
                {
                    reader.Skip();
                    continue;
                }

                string  name = reader.LocalName;
                GenInfo info = null;

                if (name == "section")
                {
                    info = new SectionInfo();
                }
                else if (name == "sectionGroup")
                {
                    info = new SectionGroupInfo();
                }
                else
                {
                    ThrowException(APResource.GetString(APResource.APGen_UnrecognizedElement, reader.Name), reader);
                }


                info.ReadGen(gen, streamName, reader);
                GenInfo actInfo = Groups[info.Name];
                if (actInfo == null)
                {
                    actInfo = Sections[info.Name];
                }

                if (actInfo != null)
                {
                    if (actInfo.GetType() != info.GetType())
                    {
                        ThrowException(APResource.GetString(APResource.APGen_SectionNameAlreadyExists, info.Name), reader);
                    }

                    actInfo.StreamName = streamName;
                }
                else
                {
                    AddChild(info);
                }
            }

            reader.ReadEndElement();
        }
Example #10
0
		internal void Initialize(APGen gen, SectionGroupInfo groupInfo)
		{
			if (_initialized)
				throw new SystemException(APResource.GetString(APResource.APGen_SectionInitTwice, GetType()));

			_initialized = true;
			_gen = gen;
			_groupInfo = groupInfo;
		}
		internal APGenSectionGroupCollection(APGen gen, SectionGroupInfo groupInfo)
			: base(StringComparer.Ordinal)
		{
			_gen = gen;
			_groupInfo = groupInfo;
		}
Example #12
0
 internal APGenSectionCollection(APGen gen, SectionGroupInfo group)
     : base(StringComparer.Ordinal)
 {
     _gen   = gen;
     _group = group;
 }
Example #13
0
		private GenInfo GetGenInfo(XmlReader reader, SectionGroupInfo current)
		{
			GenInfo data = null;

			if (current._sections != null)
				data = current._sections[reader.LocalName];
			if (data != null)
				return data;

			if (current._groups != null)
				data = current._groups[reader.LocalName];
			if (data != null)
				return data;

			if (current._groups == null)
				return null;

			foreach (string key in current._groups.AllKeys)
			{
				data = GetGenInfo(reader, (SectionGroupInfo)current._groups[key]);
				if (data != null)
					return data;
			}

			return null;
		}
Example #14
0
		public override void ReadGen(APGen gen, string streamName, XmlTextReader reader)
		{
			StreamName = streamName;
			GenHost = gen.GenHost;

			if (reader.LocalName != "genSections")
			{
				while (reader.MoveToNextAttribute())
				{
					if (reader.Name == "name")
					{
						Name = reader.Value;
					}
					else if (reader.Name == "type")
					{
						TypeName = reader.Value;
						Type = null;
					}
					else
					{
						ThrowException(APResource.GetString(APResource.APGen_UnrecognizedAttribute, ""), reader);
					}
				}

				if (Name == null)
					ThrowException(APResource.GetString(APResource.APGen_MissingRequiredAttribute, "sectionGroup", "name"), reader);
			}

			if (TypeName == null)
				TypeName = typeof(APGenSectionGroup).FullName;

			if (reader.IsEmptyElement)
			{
				reader.Skip();
				return;
			}

			reader.ReadStartElement();
			reader.MoveToContent();

			while (reader.NodeType != XmlNodeType.EndElement)
			{
				if (reader.NodeType != XmlNodeType.Element)
				{
					reader.Skip();
					continue;
				}

				string name = reader.LocalName;
				GenInfo info = null;

				if (name == "section")
					info = new SectionInfo();
				else if (name == "sectionGroup")
					info = new SectionGroupInfo();
				else
					ThrowException(APResource.GetString(APResource.APGen_UnrecognizedElement, reader.Name), reader);


				info.ReadGen(gen, streamName, reader);
				GenInfo actInfo = Groups[info.Name];
				if (actInfo == null)
					actInfo = Sections[info.Name];

				if (actInfo != null)
				{
					if (actInfo.GetType() != info.GetType())
						ThrowException(APResource.GetString(APResource.APGen_SectionNameAlreadyExists, info.Name), reader);

					actInfo.StreamName = streamName;
				}
				else
					AddChild(info);
			}

			reader.ReadEndElement();
		}
Example #15
0
        /// <summary>
        /// Removes the APGenSectionGroup object whose index is specified from this APGenSectionGroupCollection object.
        /// </summary>
        /// <param name="index">The index of the section group to be removed.</param>
        public void RemoveAt(int index)
        {
            SectionGroupInfo secData = _groupInfo.Groups[index] as SectionGroupInfo;

            _gen.RemoveGenInfo(secData);
        }
Example #16
0
		internal void Init(string virtualPath)
		{
			_genPath = virtualPath;
			_streamName = _host.GetStreamName(virtualPath);
			_rootGroupInfo = new SectionGroupInfo();
			_rootGroupInfo.StreamName = _streamName;

			if (!String.IsNullOrEmpty(_streamName))
			{
				using (XmlTextReader reader = new XmlTextReader(_host.OpenStreamForRead(_streamName)))
				{
					ReadGenFile(reader, _streamName);
				}
			}

			_codeCompileUnit = new CodeCompileUnit();
			CodeNamespace defaultNamespace = new CodeNamespace(_rootNamespace);
			_namespace.Add(_rootNamespace, defaultNamespace);
			_codeCompileUnit.Namespaces.Add(defaultNamespace);
		}
Example #17
0
		internal void CreateSection(SectionGroupInfo groupInfo, string name, APGenSection section)
		{
			if (groupInfo.HasChild(name))
				throw new APGenException(APResource.GetString(APResource.APGen_SectionAlreadyExists, name));

			if (section.SectionInformation.Type == null)
				section.SectionInformation.Type = GenHost.GetGenTypeName(section.GetType());

			SectionInfo sectionInfo = new SectionInfo(name, section.SectionInformation);
			sectionInfo.StreamName = _streamName;
			sectionInfo.GenHost = GenHost;
			groupInfo.AddChild(sectionInfo);
			_elementData[sectionInfo] = section;
		}
Example #18
0
		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);
		}
Example #19
0
		internal APGenSectionGroup GetSectionGroupInstance(SectionGroupInfo groupInfo)
		{
			APGenSectionGroup sectionGroup = groupInfo.CreateInstance() as APGenSectionGroup;
			if (sectionGroup != null)
				sectionGroup.Initialize(this, groupInfo);
			return sectionGroup;
		}