System.Web.Compilation.TemplateControlCompiler.CreateControlVariable C# (CSharp) Method

CreateControlVariable() private method

private CreateControlVariable ( Type type, ControlBuilder builder, CodeMemberMethod method, CodeTypeReference ctrlTypeRef ) : CodeStatement
type System.Type
builder System.Web.UI.ControlBuilder
method System.CodeDom.CodeMemberMethod
ctrlTypeRef System.CodeDom.CodeTypeReference
return System.CodeDom.CodeStatement
		CodeStatement CreateControlVariable (Type type, ControlBuilder builder, CodeMemberMethod method, CodeTypeReference ctrlTypeRef)
		{
			CodeObjectCreateExpression newExpr = new CodeObjectCreateExpression (ctrlTypeRef);

			object [] atts = type != null ? type.GetCustomAttributes (typeof (ConstructorNeedsTagAttribute), true) : null;
			if (atts != null && atts.Length > 0) {
				ConstructorNeedsTagAttribute att = (ConstructorNeedsTagAttribute) atts [0];
				if (att.NeedsTag)
					newExpr.Parameters.Add (new CodePrimitiveExpression (builder.TagName));
			} else if (builder is DataBindingBuilder) {
				newExpr.Parameters.Add (new CodePrimitiveExpression (0));
				newExpr.Parameters.Add (new CodePrimitiveExpression (1));
			}

			method.Statements.Add (new CodeVariableDeclarationStatement (ctrlTypeRef, "__ctrl"));
			CodeAssignStatement assign = new CodeAssignStatement ();
			assign.Left = ctrlVar;
			assign.Right = newExpr;

			return assign;
		}
		
TemplateControlCompiler