コード例 #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
ファイル: SectionInfo.cs プロジェクト: fankluo/APQuery.net
		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());
 }
コード例 #7
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));
			}
		}
コード例 #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
ファイル: SectionInfo.cs プロジェクト: fankluo/APQuery.net
		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
ファイル: GenInfo.cs プロジェクト: fankluo/APQuery.net
		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
ファイル: SectionInfo.cs プロジェクト: fankluo/APQuery.net
		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)));
 }
コード例 #26
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);
				}
			}
		}
コード例 #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
ファイル: APGenSection.cs プロジェクト: fankluo/APQuery.net
		/// <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;
 }
コード例 #33
0
		/// <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
ファイル: SectionInfo.cs プロジェクト: fankluo/APQuery.net
		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();
		}
コード例 #36
0
		/// <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);
			}
		}
コード例 #37
0
		internal APGenSectionGroupCollection(APGen gen, SectionGroupInfo groupInfo)
			: base(StringComparer.Ordinal)
		{
			_gen = gen;
			_groupInfo = groupInfo;
		}
コード例 #38
0
		/// <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
ファイル: GenInfo.cs プロジェクト: fankluo/APQuery.net
		public abstract void ReadGen(APGen gen, string streamName, XmlTextReader reader);
コード例 #45
0
ファイル: GenInfo.cs プロジェクト: fankluo/APQuery.net
		public abstract bool HasDataContent(APGen gen);
コード例 #46
0
ファイル: APGenSection.cs プロジェクト: fankluo/APQuery.net
		/// <summary>
		/// Synchronize data.
		/// </summary>
		/// <param name="gen">The specified APGen object.</param>
		public virtual void SyncData(APGen gen)
		{
		}
コード例 #47
0
ファイル: GenInfo.cs プロジェクト: fankluo/APQuery.net
		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
ファイル: SectionInfo.cs プロジェクト: fankluo/APQuery.net
		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
ファイル: APGenSection.cs プロジェクト: fankluo/APQuery.net
		/// <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)));
		}