当前位置: 首页>>代码示例>>C#>>正文


C# ControlBuilder.ProcessGeneratedCode方法代码示例

本文整理汇总了C#中System.Web.UI.ControlBuilder.ProcessGeneratedCode方法的典型用法代码示例。如果您正苦于以下问题:C# ControlBuilder.ProcessGeneratedCode方法的具体用法?C# ControlBuilder.ProcessGeneratedCode怎么用?C# ControlBuilder.ProcessGeneratedCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.UI.ControlBuilder的用法示例。


在下文中一共展示了ControlBuilder.ProcessGeneratedCode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateControlTree

		protected void CreateControlTree (ControlBuilder builder, bool inTemplate, bool childrenAsProperties)
		{
			EnsureID (builder);
			bool isTemplate = builder.IsTemplate;
			
			if (!isTemplate && !inTemplate) {
				CreateField (builder, true);
			} else if (!isTemplate) {
				bool doCheck = false;				
				bool singleInstance = false;
				ControlBuilder pb = builder.ParentBuilder;
				TemplateBuilder tpb;
				while (pb != null) {
					tpb = pb as TemplateBuilder;
					if (tpb == null) {
						pb = pb.ParentBuilder;
						continue;
					}
					
					if (tpb.TemplateInstance == TemplateInstance.Single)
						singleInstance = true;
					break;
				}
				
				if (!singleInstance)
					builder.ID = builder.GetNextID (null);
				else
					doCheck = true;

				CreateField (builder, doCheck);
			}

			InitMethod (builder, isTemplate, childrenAsProperties);
			if (!isTemplate || builder.GetType () == typeof (RootBuilder))
				CreateAssignStatementsFromAttributes (builder);

			if (builder.Children != null && builder.Children.Count > 0) {
				StringBuilder sb = new StringBuilder ();
				foreach (object b in builder.Children) {
					if (b is string) {
						sb.Append ((string) b);
						continue;
					}

					FlushText (builder, sb);
					if (b is ObjectTagBuilder) {
						ProcessObjectTag ((ObjectTagBuilder) b);
					} else if (b is StringPropertyBuilder) {
						StringPropertyBuilder pb = b as StringPropertyBuilder;
						if (pb.Children != null && pb.Children.Count > 0) {
							StringBuilder asb = new StringBuilder ();
							foreach (string s in pb.Children)
								asb.Append (s);
							CodeMemberMethod method = builder.Method;
							CodeAssignStatement assign = new CodeAssignStatement ();
							assign.Left = new CodePropertyReferenceExpression (ctrlVar, pb.PropertyName);
							assign.Right = new CodePrimitiveExpression (asb.ToString ());
							method.Statements.Add (AddLinePragma (assign, builder));
						}
					} else if (b is ContentBuilderInternal) {
						ContentBuilderInternal cb = (ContentBuilderInternal) b;
						CreateControlTree (cb, false, true);
						AddContentTemplateInvocation (cb, builder.Method, cb.Method.Name);
						continue;
					}

					// Ignore TemplateBuilders - they are processed in InitMethod
					else if (b is TemplateBuilder) {
					} else if (b is CodeRenderBuilder) {
						AddCodeRender (builder, (CodeRenderBuilder) b);
					} else if (b is DataBindingBuilder) {
						AddDataBindingLiteral (builder, (DataBindingBuilder) b);
					} else if (b is ControlBuilder) {
						ControlBuilder child = (ControlBuilder) b;
						CreateControlTree (child, inTemplate, builder.ChildrenAsProperties);
						AddChildCall (builder, child);
						continue;
					} else
						throw new Exception ("???");

					ControlBuilder bldr = b as ControlBuilder;
					bldr.ProcessGeneratedCode (CompileUnit, BaseType, DerivedType, bldr.Method, bldr.DataBindingMethod);
				}

				FlushText (builder, sb);
			}

			ControlBuilder defaultPropertyBuilder = builder.DefaultPropertyBuilder;
			if (defaultPropertyBuilder != null) {
				CreateControlTree (defaultPropertyBuilder, false, true);
				AddChildCall (builder, defaultPropertyBuilder);
			}
			
			if (builder.HasAspCode) {
				CodeMemberMethod renderMethod = builder.RenderMethod;
				CodeMethodReferenceExpression m = new CodeMethodReferenceExpression ();
				m.TargetObject = thisRef;
				m.MethodName = renderMethod.Name;

				CodeDelegateCreateExpression create = new CodeDelegateCreateExpression ();
//.........这里部分代码省略.........
开发者ID:nlhepler,项目名称:mono,代码行数:101,代码来源:TemplateControlCompiler.cs

示例2: BuildSourceDataTreeFromBuilder

        protected virtual void BuildSourceDataTreeFromBuilder(ControlBuilder builder,
                                                    bool fInTemplate, bool topLevelControlInTemplate,
                                                    PropertyEntry pse) {

            // Don't do anything for Code blocks
            if (builder is CodeBlockBuilder || builder is CodeStatementBuilder)
                return;

            // Is the current builder for a template?
            bool fTemplate = (builder is TemplateBuilder);

            // For the control name in the compiled code, we use the
            // ID if one is available (but don't use the ID inside a template)
            // Otherwise, we generate a unique name.
            if (builder.ID == null || fInTemplate) {
                // Increase the control count to generate unique ID's
                _controlCount++;

                builder.ID = "__control" + _controlCount.ToString(NumberFormatInfo.InvariantInfo);
                builder.IsGeneratedID = true;
            }

            // Process the children
            if (builder.SubBuilders != null) {
                foreach (object child in builder.SubBuilders) {
                    if (child is ControlBuilder) {
                        // Do not treat it as top level control in template if the control is at top-level of a file.
                        bool isTopLevelCtrlInTemplate =
                            fTemplate && typeof(Control).IsAssignableFrom(((ControlBuilder)child).ControlType) && !(builder is RootBuilder);
                        BuildSourceDataTreeFromBuilder((ControlBuilder)child, fInTemplate, isTopLevelCtrlInTemplate, null);
                    }
                }
            }

            foreach (TemplatePropertyEntry entry in builder.TemplatePropertyEntries) {
                bool inTemplate = true;

                // If the template container does not allow multiple instances,
                // treat the controls as if not in templates.
                if (entry.PropertyInfo != null) {
                    inTemplate = entry.IsMultiple;
                }

                BuildSourceDataTreeFromBuilder(((TemplatePropertyEntry)entry).Builder, inTemplate, false /*topLevelControlInTemplate*/, entry);
            }

            foreach (ComplexPropertyEntry entry in builder.ComplexPropertyEntries) {
                // Don't create a build method for inner property strings
                if (!(entry.Builder is StringPropertyBuilder)) {
                    BuildSourceDataTreeFromBuilder(((ComplexPropertyEntry)entry).Builder, fInTemplate, false /*topLevelControlInTemplate*/, entry);
                }
            }

            // Build a field declaration for the control if ID is defined on the control.
            // (Not a generated ID)
            if (!builder.IsGeneratedID)
                BuildFieldDeclaration(builder);

            CodeMemberMethod buildMethod = null;
            CodeMemberMethod dataBindingMethod = null;

            // Skip the rest if we're only generating the intermediate class
            if (_sourceDataClass != null) {

                if (!_designerMode) {
                    // Build a Build method for the control
                    buildMethod = BuildBuildMethod(builder, fTemplate, fInTemplate, topLevelControlInTemplate, pse, false);
                }

                // Build a Render method for the control, unless it has no code
                if (builder.HasAspCode) {
                    BuildRenderMethod(builder, fTemplate);
                }

                // Build a method to extract values from the template
                BuildExtractMethod(builder);

                // Build a property binding method for the control
                dataBindingMethod = BuildPropertyBindingMethod(builder, false);
            }

            // Give the ControlBuilder a chance to look at and modify the tree
            builder.ProcessGeneratedCode(_codeCompileUnit, _intermediateClass,
                _sourceDataClass, buildMethod, dataBindingMethod);

            if (Parser.ControlBuilderInterceptor != null) {
                Parser.ControlBuilderInterceptor.OnProcessGeneratedCode(builder, _codeCompileUnit,
                    _intermediateClass, _sourceDataClass, buildMethod, dataBindingMethod, builder.AdditionalState);
            }

            // Give the ParseRecorder a chance to look at and modify the tree
            Parser.ParseRecorders.ProcessGeneratedCode(builder, _codeCompileUnit,
                _intermediateClass, _sourceDataClass, buildMethod, dataBindingMethod);
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:94,代码来源:BaseTemplateCodeDomTreeGenerator.cs

示例3: VerifyProcessGeneratedCode

 public void VerifyProcessGeneratedCode(ControlBuilder builder) {
     CodeCompileUnit ccu = new CodeCompileUnit();
     ccu.Namespaces.Add(new CodeNamespace());
     builder.ProcessGeneratedCode(ccu, null, null, null, null);
     VerifyDefaultNameSpaces(ccu);
 }
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:6,代码来源:WebPageSurrogateControlBuilderTest.cs

示例4: BuildSourceDataTreeFromBuilder

 protected virtual void BuildSourceDataTreeFromBuilder(ControlBuilder builder, bool fInTemplate, bool topLevelControlInTemplate, PropertyEntry pse)
 {
     if (!(builder is CodeBlockBuilder))
     {
         bool fTemplate = builder is TemplateBuilder;
         if ((builder.ID == null) || fInTemplate)
         {
             this._controlCount++;
             builder.ID = "__control" + this._controlCount.ToString(NumberFormatInfo.InvariantInfo);
             builder.IsGeneratedID = true;
         }
         if (builder.SubBuilders != null)
         {
             foreach (object obj2 in builder.SubBuilders)
             {
                 if (obj2 is ControlBuilder)
                 {
                     bool flag2 = (fTemplate && typeof(Control).IsAssignableFrom(((ControlBuilder) obj2).ControlType)) && !(builder is RootBuilder);
                     this.BuildSourceDataTreeFromBuilder((ControlBuilder) obj2, fInTemplate, flag2, null);
                 }
             }
         }
         foreach (TemplatePropertyEntry entry in builder.TemplatePropertyEntries)
         {
             bool isMultiple = true;
             if (entry.PropertyInfo != null)
             {
                 isMultiple = entry.IsMultiple;
             }
             this.BuildSourceDataTreeFromBuilder(entry.Builder, isMultiple, false, entry);
         }
         foreach (ComplexPropertyEntry entry2 in builder.ComplexPropertyEntries)
         {
             if (!(entry2.Builder is StringPropertyBuilder))
             {
                 this.BuildSourceDataTreeFromBuilder(entry2.Builder, fInTemplate, false, entry2);
             }
         }
         if (!builder.IsGeneratedID)
         {
             this.BuildFieldDeclaration(builder);
         }
         CodeMemberMethod buildMethod = null;
         CodeMemberMethod dataBindingMethod = null;
         if (base._sourceDataClass != null)
         {
             if (!base._designerMode)
             {
                 buildMethod = this.BuildBuildMethod(builder, fTemplate, fInTemplate, topLevelControlInTemplate, pse, false);
             }
             if (builder.HasAspCode)
             {
                 this.BuildRenderMethod(builder, fTemplate);
             }
             this.BuildExtractMethod(builder);
             dataBindingMethod = this.BuildPropertyBindingMethod(builder, false);
         }
         builder.ProcessGeneratedCode(base._codeCompileUnit, base._intermediateClass, base._sourceDataClass, buildMethod, dataBindingMethod);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:60,代码来源:BaseTemplateCodeDomTreeGenerator.cs


注:本文中的System.Web.UI.ControlBuilder.ProcessGeneratedCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。