Exemple #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();
        }
Exemple #2
0
		public override void WriteGen(APGen gen, XmlWriter writer)
		{
			writer.WriteStartElement("section");
			writer.WriteAttributeString("name", Name);
			writer.WriteAttributeString("type", TypeName);
			writer.WriteEndElement();
		}
Exemple #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);
            }
        }
Exemple #4
0
 public override void WriteGen(APGen gen, XmlWriter writer)
 {
     writer.WriteStartElement("section");
     writer.WriteAttributeString("name", Name);
     writer.WriteAttributeString("type", TypeName);
     writer.WriteEndElement();
 }
Exemple #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();
        }
Exemple #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));
			}
		}
Exemple #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));
            }
        }
Exemple #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);
     }
 }
Exemple #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);
     }
 }
Exemple #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;
        }
Exemple #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);
             }
         }
     }
 }
Exemple #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);
 }
Exemple #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();
     }
 }
Exemple #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);
                }
            }
        }
Exemple #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();
		}
Exemple #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();
            }
        }
Exemple #18
0
		public abstract void WriteData(APGen gen, XmlWriter writer);
Exemple #19
0
 internal void WriteRootData(XmlWriter writer, APGen gen)
 {
     WriteContent(writer, gen, false);
 }
		internal void Initialize(APGen gen, SectionGroupInfo groupInfo)
		{
			if (_initialized)
				throw new SystemException(APResource.GetString(APResource.APGen_SectionInitTwice, GetType()));

			_initialized = true;
			_gen = gen;
			_groupInfo = groupInfo;
		}
Exemple #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());
		}
Exemple #22
0
 public abstract bool HasDataContent(APGen gen);
Exemple #23
0
 public abstract void ReadData(APGen gen, XmlTextReader reader);
		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();
		}
Exemple #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);
				}
			}
		}
Exemple #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);
                }
            }
        }
Exemple #28
0
 public override bool HasDataContent(APGen gen)
 {
     return(gen.GetSectionInstance(this, false) != null || gen.GetSectionXml(this) != null);
 }
Exemple #29
0
 /// <summary>
 /// Initialize data.
 /// </summary>
 /// <param name="gen">The specified APGen object.</param>
 public virtual void InitData(APGen gen)
 {
 }
Exemple #30
0
 /// <summary>
 /// Synchronize data.
 /// </summary>
 /// <param name="gen">The specified APGen object.</param>
 public virtual void SyncData(APGen gen)
 {
 }
Exemple #31
0
		/// <summary>
		/// Initialize data.
		/// </summary>
		/// <param name="gen">The specified APGen object.</param>
		public virtual void InitData(APGen gen)
		{
		}
Exemple #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[] { });
				}
			}
		}
Exemple #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);
			}
		}
		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);
			}
		}
Exemple #39
0
 public abstract void ReadGen(APGen gen, string streamName, XmlTextReader reader);
Exemple #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();
        }
Exemple #41
0
 public abstract void WriteData(APGen gen, XmlWriter writer);
		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);
		}
		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);
		}
Exemple #44
0
		public abstract void ReadGen(APGen gen, string streamName, XmlTextReader reader);
Exemple #45
0
		public abstract bool HasDataContent(APGen gen);
Exemple #46
0
		/// <summary>
		/// Synchronize data.
		/// </summary>
		/// <param name="gen">The specified APGen object.</param>
		public virtual void SyncData(APGen gen)
		{
		}
Exemple #47
0
		public abstract void ReadData(APGen gen, XmlTextReader reader);
		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);
				}
			}
		}
Exemple #49
0
 public void ReadRootData(XmlTextReader reader, APGen gen)
 {
     reader.MoveToContent();
     ReadContent(reader, gen, true);
 }
		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;
		}
		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();
		}
		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();
		}
		public void ReadRootData(XmlTextReader reader, APGen gen)
		{
			reader.MoveToContent();
			ReadContent(reader, gen, true);
		}
Exemple #54
0
		public override bool HasDataContent(APGen gen)
		{
			return gen.GetSectionInstance(this, false) != null || gen.GetSectionXml(this) != null;
		}
		internal void WriteRootData(XmlWriter writer, APGen gen)
		{
			WriteContent(writer, gen, false);
		}
		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);
			}
		}
Exemple #57
0
 public override void WriteData(APGen gen, XmlWriter writer)
 {
     writer.WriteStartElement(Name);
     WriteContent(writer, gen, true);
     writer.WriteEndElement();
 }
Exemple #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)));
		}