示例#1
0
        public override void ReadGen(APGen gen, string streamName, XmlTextReader reader)
        {
            StreamName = streamName;
            GenHost    = gen.GenHost;

            while (reader.MoveToNextAttribute())
            {
                switch (reader.Name)
                {
                case "type": TypeName = reader.Value; break;

                case "name": Name = reader.Value; break;

                default: ThrowException(APResource.GetString(APResource.APGen_UnrecognizedAttribute, reader.Name), reader); break;
                }
            }

            if (Name == null || TypeName == null)
            {
                ThrowException(APResource.GetString(APResource.APGen_MissingRequiredAttribute, "section", "name or type"), reader);
            }

            reader.MoveToElement();
            reader.Skip();
        }
示例#2
0
		public override void WriteGen(APGen gen, XmlWriter writer)
		{
			writer.WriteStartElement("section");
			writer.WriteAttributeString("name", Name);
			writer.WriteAttributeString("type", TypeName);
			writer.WriteEndElement();
		}
示例#3
0
        public override void WriteData(APGen gen, XmlWriter writer)
        {
            string xml;

            APGenSection section = gen.GetSectionInstance(this, false);

            if (section != null)
            {
                xml = section.SerializeSection(Name);

                string externalDataXml = section.ExternalDataXml;
                string filePath        = gen.FileName;

                if (!String.IsNullOrEmpty(filePath) && !String.IsNullOrEmpty(externalDataXml))
                {
                    using (StreamWriter sw = new StreamWriter(filePath))
                    {
                        sw.Write(externalDataXml);
                    }
                }
            }
            else
            {
                xml = gen.GetSectionXml(this);
            }

            if (xml != null)
            {
                writer.WriteRaw(xml);
            }
        }
示例#4
0
 public override void WriteGen(APGen gen, XmlWriter writer)
 {
     writer.WriteStartElement("section");
     writer.WriteAttributeString("name", Name);
     writer.WriteAttributeString("type", TypeName);
     writer.WriteEndElement();
 }
示例#5
0
        public override void WriteGen(APGen gen, XmlWriter writer)
        {
            if (Name != null)
            {
                writer.WriteStartElement("sectionGroup");
                writer.WriteAttributeString("name", Name);
                if (TypeName != null && TypeName != "" && TypeName != "Symber.Web.Compilation.Gen.APGenSectionGroup")
                {
                    writer.WriteAttributeString("type", TypeName);
                }
            }
            else
            {
                writer.WriteStartElement("genSections");
            }

            foreach (GenInfoCollection col in new object[] { Sections, Groups })
            {
                foreach (string key in col)
                {
                    GenInfo info = col[key];
                    if (info.HasDataContent(gen))
                    {
                        info.WriteGen(gen, writer);
                    }
                }
            }

            writer.WriteEndElement();
        }
示例#6
0
 public override void ReadData(APGen gen, XmlTextReader reader)
 {
     if (gen.GetSectionXml(this) != null)
     {
         ThrowException(APResource.GetString(APResource.APGen_RedefinedSection, Name), reader);
     }
     gen.SetSectionXml(this, reader.ReadOuterXml());
 }
		/// <summary>
		/// Generate code.
		/// </summary>
		/// <param name="gen">The specified APGen generation object.</param>
		public override void Generate(APGen gen)
		{
			CodeNamespace cns = gen.GetCodeNamespace(gen.DefaultNamespace);

			foreach (APGenNamespace ns in Namespaces)
			{
				cns.Imports.Add(new CodeNamespaceImport(ns.Import));
			}
		}
示例#8
0
        /// <summary>
        /// Generate code.
        /// </summary>
        /// <param name="gen">The specified APGen generation object.</param>
        public override void Generate(APGen gen)
        {
            CodeNamespace cns = gen.GetCodeNamespace(gen.DefaultNamespace);

            foreach (APGenNamespace ns in Namespaces)
            {
                cns.Imports.Add(new CodeNamespaceImport(ns.Import));
            }
        }
示例#9
0
 internal void InitData(APGen gen)
 {
     foreach (APGenSection section in Sections)
     {
         section.InitData(gen);
     }
     for (int i = 0; i < SectionGroups.Count; i++)
     {
         SectionGroups[i].InitData(gen);
     }
 }
示例#10
0
 internal void Generate(APGen gen)
 {
     foreach (APGenSection section in Sections)
     {
         section.Generate(gen);
     }
     for (int i = 0; i < SectionGroups.Count; i++)
     {
         SectionGroups[i].Generate(gen);
     }
 }
示例#11
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;
        }
示例#12
0
 internal void WriteContent(XmlWriter writer, APGen gen, bool writeElement)
 {
     foreach (GenInfoCollection col in new object[] { Sections, Groups })
     {
         foreach (string key in col)
         {
             GenInfo info = col[key];
             if (info.HasDataContent(gen))
             {
                 info.WriteData(gen, writer);
             }
         }
     }
 }
示例#13
0
 public override bool HasDataContent(APGen gen)
 {
     foreach (GenInfoCollection col in new object[] { Sections, Groups })
     {
         foreach (string key in col)
         {
             GenInfo info = col[key];
             if (info.HasDataContent(gen))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
示例#14
0
 public override void ReadData(APGen gen, XmlTextReader reader)
 {
     reader.MoveToContent();
     if (!reader.IsEmptyElement)
     {
         reader.ReadStartElement();
         ReadContent(reader, gen, false);
         reader.MoveToContent();
         reader.ReadEndElement();
     }
     else
     {
         reader.Read();
     }
 }
示例#15
0
        public void ReadContent(XmlTextReader reader, APGen gen, bool root)
        {
            while (reader.NodeType != XmlNodeType.EndElement && reader.NodeType != XmlNodeType.None)
            {
                if (reader.NodeType != XmlNodeType.Element)
                {
                    reader.Skip();
                    continue;
                }

                GenInfo data = GetGenInfo(reader, this);
                if (data != null)
                {
                    data.ReadData(gen, reader);
                }
                else
                {
                    ThrowException(APResource.GetString(APResource.APGen_UnrecognizedSection, reader.LocalName), reader);
                }
            }
        }
示例#16
0
		public override void ReadGen(APGen gen, string streamName, XmlTextReader reader)
		{
			StreamName = streamName;
			GenHost = gen.GenHost;

			while (reader.MoveToNextAttribute())
			{
				switch (reader.Name)
				{
					case "type": TypeName = reader.Value; break;
					case "name": Name = reader.Value; break;
					default: ThrowException(APResource.GetString(APResource.APGen_UnrecognizedAttribute, reader.Name), reader); break;
				}
			}

			if (Name == null || TypeName == null)
				ThrowException(APResource.GetString(APResource.APGen_MissingRequiredAttribute, "section", "name or type"), reader);

			reader.MoveToElement();
			reader.Skip();
		}
示例#17
0
        /// <summary>
        /// Generate the code from .apgen file.
        /// </summary>
        /// <param name="assemblyBuilder">AssemblyBuilder</param>
        public override void GenerateCode(AssemblyBuilder assemblyBuilder)
        {
            if (!flag && BuildManager.CodeAssemblies != null && getProfileMethodCount > 0)
            {
                getProfileMethodCount = 0;
                flag = true;
            }

            string path = Path.Combine(
                HttpRuntime.AppDomainAppPath,
                VirtualPath.Substring(HttpRuntime.AppDomainAppVirtualPath.Length + (HttpRuntime.AppDomainAppVirtualPath.Length == 1 ? 0 : 1)));

            using (TextWriter writer = assemblyBuilder.CreateCodeFile(this))
            {
                APGen           gen      = APGenManager.OpenGenDocument(path);
                CodeDomProvider provider = assemblyBuilder.CodeDomProvider;
                provider.GenerateCodeFromCompileUnit(gen.Generate(), writer, null);

                writer.Flush();
                writer.Close();
            }
        }
示例#18
0
		public abstract void WriteData(APGen gen, XmlWriter writer);
示例#19
0
 internal void WriteRootData(XmlWriter writer, APGen gen)
 {
     WriteContent(writer, gen, false);
 }
示例#20
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;
		}
示例#21
0
		public override void ReadData(APGen gen, XmlTextReader reader)
		{
			if (gen.GetSectionXml(this) != null)
				ThrowException(APResource.GetString(APResource.APGen_RedefinedSection, Name), reader);
			gen.SetSectionXml(this, reader.ReadOuterXml());
		}
示例#22
0
 public abstract bool HasDataContent(APGen gen);
示例#23
0
 public abstract void ReadData(APGen gen, XmlTextReader reader);
示例#24
0
		public override void ReadData(APGen gen, XmlTextReader reader)
		{
			reader.MoveToContent();
			if (!reader.IsEmptyElement)
			{
				reader.ReadStartElement();
				ReadContent(reader, gen, false);
				reader.MoveToContent();
				reader.ReadEndElement();
			}
			else
				reader.Read();
		}
示例#25
0
 /// <summary>
 /// Generate code.
 /// </summary>
 /// <param name="gen">The specified APGen object.</param>
 public virtual void Generate(APGen gen)
 {
     gen.GetCodeNamespace(gen.DefaultNamespace)
     .Comments
     .Add(Comment(APResource.GetString(APResource.APGen_DefaultGenerated, GetType().FullName)));
 }
		/// <summary>
		/// Generate code.
		/// </summary>
		/// <param name="gen">The specified APGen generation object.</param>
		public override void Generate(APGen gen)
		{
			if (!Enabled)
				return;



			CodeNamespace cns = gen.GetCodeNamespace(gen.DefaultNamespace);
			cns.Imports.Add(new CodeNamespaceImport("Symber.Web.Data"));



			foreach (APGenEnum em in Enums)
			{
				if (em.Enabled)
				{
					// Create a enum
					string enumComment = String.IsNullOrEmpty(em.Comment) ? em.Name : em.Comment;

					CodeTypeDeclaration enumImp = NewEnum(em.Name, TypeAttributes.Public, enumComment);


					if (em.IsFlags)
						enumImp.CustomAttributes.Add(AttrDecl(TypeRef("Flags")));


					// Fields

					int value = 1;
					foreach (APGenEnumItem item in em.EnumItems)
					{
						string comment = String.IsNullOrEmpty(item.Comment) ? item.Name : item.Comment;
						if (em.IsFlags && item.DefaultValue == null)
							enumImp.Members.Add(NewEnumItem(item.Name, comment, string.Format("0x{0:x2}", value)));
						else
							enumImp.Members.Add(NewEnumItem(item.Name, comment, item.DefaultValue));
						value = value * 2;
					}
					cns.Types.Add(enumImp);


					// Create dictionary

					CodeTypeDeclaration dicImp = NewClass(em.Name + "APEnumDictionary", TypeAttributes.Public, enumComment + " APEnumDictionary");
					dicImp.IsPartial = true;
					CodeMemberField field = NewMemberField("Dictionary", TypeTRef("APEnumDictionary", TypeRef(em.Name)), MemberAttributes.Public | MemberAttributes.Static, null);
					CodeMethodInvokeExpression create = MethodInvoke(new CodeTypeReferenceExpression(TypeTRef("APEnumDictionary", TypeRef(em.Name))), "Create");
					foreach (APGenEnumItem item in em.EnumItems)
					{
						string comment = String.IsNullOrEmpty(item.Comment) ? item.Name : item.Comment;
						CodeMemberField nameField = NewMemberField(item.Name + "Name", TypeRef(typeof(string)), MemberAttributes.Public | MemberAttributes.Const, comment);
						nameField.InitExpression = Const(item.DictionaryName == "" ? item.Name : item.DictionaryName);
						dicImp.Members.Add(nameField);
						create.Parameters.Add(New(new CodeTypeReference("KeyValuePair", TypeRef(em.Name), TypeRef(typeof(string))), PropRef(TypeRefExp(em.Name), item.Name), FieldRef(item.Name + "Name") /*Const(item.DictionaryName)*/));
					}
					field.InitExpression = create;
					dicImp.Members.Add(field);
					cns.Types.Add(dicImp);
				}
			}
		}
示例#27
0
        /// <summary>
        /// Generate code.
        /// </summary>
        /// <param name="gen">The specified APGen generation object.</param>
        public override void Generate(APGen gen)
        {
            if (!Enabled)
            {
                return;
            }



            CodeNamespace cns = gen.GetCodeNamespace(gen.DefaultNamespace);

            cns.Imports.Add(new CodeNamespaceImport("Symber.Web.Data"));



            foreach (APGenEnum em in Enums)
            {
                if (em.Enabled)
                {
                    // Create a enum
                    string enumComment = String.IsNullOrEmpty(em.Comment) ? em.Name : em.Comment;

                    CodeTypeDeclaration enumImp = NewEnum(em.Name, TypeAttributes.Public, enumComment);


                    if (em.IsFlags)
                    {
                        enumImp.CustomAttributes.Add(AttrDecl(TypeRef("Flags")));
                    }


                    // Fields

                    int value = 1;
                    foreach (APGenEnumItem item in em.EnumItems)
                    {
                        string comment = String.IsNullOrEmpty(item.Comment) ? item.Name : item.Comment;
                        if (em.IsFlags && item.DefaultValue == null)
                        {
                            enumImp.Members.Add(NewEnumItem(item.Name, comment, string.Format("0x{0:x2}", value)));
                        }
                        else
                        {
                            enumImp.Members.Add(NewEnumItem(item.Name, comment, item.DefaultValue));
                        }
                        value = value * 2;
                    }
                    cns.Types.Add(enumImp);


                    // Create dictionary

                    CodeTypeDeclaration dicImp = NewClass(em.Name + "APEnumDictionary", TypeAttributes.Public, enumComment + " APEnumDictionary");
                    dicImp.IsPartial = true;
                    CodeMemberField            field  = NewMemberField("Dictionary", TypeTRef("APEnumDictionary", TypeRef(em.Name)), MemberAttributes.Public | MemberAttributes.Static, null);
                    CodeMethodInvokeExpression create = MethodInvoke(new CodeTypeReferenceExpression(TypeTRef("APEnumDictionary", TypeRef(em.Name))), "Create");
                    foreach (APGenEnumItem item in em.EnumItems)
                    {
                        string          comment   = String.IsNullOrEmpty(item.Comment) ? item.Name : item.Comment;
                        CodeMemberField nameField = NewMemberField(item.Name + "Name", TypeRef(typeof(string)), MemberAttributes.Public | MemberAttributes.Const, comment);
                        nameField.InitExpression = Const(item.DictionaryName == "" ? item.Name : item.DictionaryName);
                        dicImp.Members.Add(nameField);
                        create.Parameters.Add(New(new CodeTypeReference("KeyValuePair", TypeRef(em.Name), TypeRef(typeof(string))), PropRef(TypeRefExp(em.Name), item.Name), FieldRef(item.Name + "Name") /*Const(item.DictionaryName)*/));
                    }
                    field.InitExpression = create;
                    dicImp.Members.Add(field);
                    cns.Types.Add(dicImp);
                }
            }
        }
示例#28
0
 public override bool HasDataContent(APGen gen)
 {
     return(gen.GetSectionInstance(this, false) != null || gen.GetSectionXml(this) != null);
 }
示例#29
0
 /// <summary>
 /// Initialize data.
 /// </summary>
 /// <param name="gen">The specified APGen object.</param>
 public virtual void InitData(APGen gen)
 {
 }
示例#30
0
 /// <summary>
 /// Synchronize data.
 /// </summary>
 /// <param name="gen">The specified APGen object.</param>
 public virtual void SyncData(APGen gen)
 {
 }
示例#31
0
		/// <summary>
		/// Initialize data.
		/// </summary>
		/// <param name="gen">The specified APGen object.</param>
		public virtual void InitData(APGen gen)
		{
		}
示例#32
0
 internal APGenSectionCollection(APGen gen, SectionGroupInfo group)
     : base(StringComparer.Ordinal)
 {
     _gen   = gen;
     _group = group;
 }
		/// <summary>
		/// Initialize data.
		/// </summary>
		/// <param name="gen">The specified APGen object.</param>
		public override void InitData(APGen gen)
		{
			if (Enabled && AutoInitDatabase)
			{
				string ns = Namespace ?? gen.DefaultNamespace;
				Type type = APTypeHelper.LoadType(string.IsNullOrEmpty(ns) ? DBDefName : ns + "." + DBDefName);
				if (type != null)
				{
					type.InvokeMember("InitData", BindingFlags.InvokeMethod, null, null, new object[] { });
				}
			}
		}
示例#34
0
		public override void WriteData(APGen gen, XmlWriter writer)
		{
			string xml;

			APGenSection section = gen.GetSectionInstance(this, false);

			if (section != null)
			{
				xml = section.SerializeSection(Name);

				string externalDataXml = section.ExternalDataXml;
				string filePath = gen.FileName;

				if (!String.IsNullOrEmpty(filePath) && !String.IsNullOrEmpty(externalDataXml))
				{
					using (StreamWriter sw = new StreamWriter(filePath))
					{
						sw.Write(externalDataXml);
					}
				}
			}
			else
			{
				xml = gen.GetSectionXml(this);
			}

			if (xml != null)
			{
				writer.WriteRaw(xml);
			}
		}
示例#35
0
		public override void WriteData(APGen gen, XmlWriter writer)
		{
			writer.WriteStartElement(Name);
			WriteContent(writer, gen, true);
			writer.WriteEndElement();
		}
		/// <summary>
		/// Synchronize data.
		/// </summary>
		/// <param name="gen">The specified APGen object.</param>
		public override void SyncData(APGen gen)
		{
			if (Enabled && AutoSyncDatabase)
			{
				InitPrefix();
				ProviderInstance.Sync(this);
			}
		}
		internal APGenSectionGroupCollection(APGen gen, SectionGroupInfo groupInfo)
			: base(StringComparer.Ordinal)
		{
			_gen = gen;
			_groupInfo = groupInfo;
		}
		/// <summary>
		/// Generate source code and database with the business modes.
		/// </summary>
		/// <param name="gen">The specified APGen generation object.</param>
		public override void Generate(APGen gen)
		{
			if (!Enabled)
				return;

			InitPrefix();



			CodeNamespace cns = gen.GetCodeNamespace(Namespace ?? gen.DefaultNamespace);
			cns.Imports.Add(new CodeNamespaceImport("System"));
			cns.Imports.Add(new CodeNamespaceImport("System.Collections"));
			cns.Imports.Add(new CodeNamespaceImport("System.Collections.Generic"));
			cns.Imports.Add(new CodeNamespaceImport("System.Data"));
			cns.Imports.Add(new CodeNamespaceImport("System.ComponentModel.DataAnnotations"));
			cns.Imports.Add(new CodeNamespaceImport("Symber.Web.Data"));



			// class APDBDef
			CreateDatabaseDef(cns);
			// class APDalDef
			CodeTypeDeclaration dalDef = CreateDalDef(cns);
			// class APBplDef
			CodeTypeDeclaration bplDef = CreateBplDef(cns);

			foreach (APGenTable table in Tables)
			{
				// class a Data
				CreateData(cns, table, false);

				// class a Dal
				CreateDal(dalDef, table, false);

				// class a Bpl
				CreateBpl(bplDef, table, false);
			}

			foreach (APGenTable view in Views)
			{
				// class a Data
				CreateData(cns, view, true);

				// class a Dal
				CreateDal(dalDef, view, true);

				// class a Bpl
				CreateBpl(bplDef, view, true);
			}
		}
示例#39
0
 public abstract void ReadGen(APGen gen, string streamName, XmlTextReader reader);
示例#40
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();
        }
示例#41
0
 public abstract void WriteData(APGen gen, XmlWriter writer);
示例#42
0
		internal void InitData(APGen gen)
		{
			foreach (APGenSection section in Sections)
				section.InitData(gen);
			for (int i = 0; i < SectionGroups.Count; i++)
				SectionGroups[i].InitData(gen);
		}
示例#43
0
		internal void Generate(APGen gen)
		{
			foreach (APGenSection section in Sections)
				section.Generate(gen);
			for (int i = 0; i < SectionGroups.Count; i++)
				SectionGroups[i].Generate(gen);
		}
示例#44
0
		public abstract void ReadGen(APGen gen, string streamName, XmlTextReader reader);
示例#45
0
		public abstract bool HasDataContent(APGen gen);
示例#46
0
		/// <summary>
		/// Synchronize data.
		/// </summary>
		/// <param name="gen">The specified APGen object.</param>
		public virtual void SyncData(APGen gen)
		{
		}
示例#47
0
		public abstract void ReadData(APGen gen, XmlTextReader reader);
示例#48
0
		internal void WriteContent(XmlWriter writer, APGen gen, bool writeElement)
		{
			foreach (GenInfoCollection col in new object[] { Sections, Groups })
			{
				foreach (string key in col)
				{
					GenInfo info = col[key];
					if (info.HasDataContent(gen))
						info.WriteData(gen, writer);
				}
			}
		}
示例#49
0
 public void ReadRootData(XmlTextReader reader, APGen gen)
 {
     reader.MoveToContent();
     ReadContent(reader, gen, true);
 }
示例#50
0
		public override bool HasDataContent(APGen gen)
		{
			foreach (GenInfoCollection col in new object[] { Sections, Groups })
			{
				foreach (string key in col)
				{
					GenInfo info = col[key];
					if (info.HasDataContent(gen))
						return true;
				}
			}
			return false;
		}
示例#51
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();
		}
示例#52
0
		public override void WriteGen(APGen gen, XmlWriter writer)
		{
			if (Name != null)
			{
				writer.WriteStartElement("sectionGroup");
				writer.WriteAttributeString("name", Name);
				if (TypeName != null && TypeName != "" && TypeName != "Symber.Web.Compilation.Gen.APGenSectionGroup")
					writer.WriteAttributeString("type", TypeName);
			}
			else
				writer.WriteStartElement("genSections");

			foreach (GenInfoCollection col in new object[] { Sections, Groups })
			{
				foreach (string key in col)
				{
					GenInfo info = col[key];
					if (info.HasDataContent(gen))
						info.WriteGen(gen, writer);
				}
			}

			writer.WriteEndElement();
		}
示例#53
0
		public void ReadRootData(XmlTextReader reader, APGen gen)
		{
			reader.MoveToContent();
			ReadContent(reader, gen, true);
		}
示例#54
0
		public override bool HasDataContent(APGen gen)
		{
			return gen.GetSectionInstance(this, false) != null || gen.GetSectionXml(this) != null;
		}
示例#55
0
		internal void WriteRootData(XmlWriter writer, APGen gen)
		{
			WriteContent(writer, gen, false);
		}
示例#56
0
		public void ReadContent(XmlTextReader reader, APGen gen, bool root)
		{
			while (reader.NodeType != XmlNodeType.EndElement && reader.NodeType != XmlNodeType.None)
			{
				if (reader.NodeType != XmlNodeType.Element)
				{
					reader.Skip();
					continue;
				}

				GenInfo data = GetGenInfo(reader, this);
				if (data != null)
					data.ReadData(gen, reader);
				else
					ThrowException(APResource.GetString(APResource.APGen_UnrecognizedSection, reader.LocalName), reader);
			}
		}
示例#57
0
 public override void WriteData(APGen gen, XmlWriter writer)
 {
     writer.WriteStartElement(Name);
     WriteContent(writer, gen, true);
     writer.WriteEndElement();
 }
示例#58
0
		/// <summary>
		/// Generate code.
		/// </summary>
		/// <param name="gen">The specified APGen object.</param>
		public virtual void Generate(APGen gen)
		{
			gen.GetCodeNamespace(gen.DefaultNamespace)
				.Comments
				.Add(Comment(APResource.GetString(APResource.APGen_DefaultGenerated, GetType().FullName)));
		}