System.Web.Compilation.BaseCompiler.CreateConstructor C# (CSharp) Method

CreateConstructor() protected method

protected CreateConstructor ( CodeStatementCollection localVars, CodeStatementCollection trueStmt ) : void
localVars System.CodeDom.CodeStatementCollection
trueStmt System.CodeDom.CodeStatementCollection
return void
		protected virtual void CreateConstructor (CodeStatementCollection localVars,
							  CodeStatementCollection trueStmt)
		{
			CodeConstructor ctor = new CodeConstructor ();
			ctor.Attributes = MemberAttributes.Public;
			mainClass.Members.Add (ctor);

			if (localVars != null)
				ctor.Statements.AddRange (localVars);

			AssignAppRelativeVirtualPath (ctor);

			CodeFieldReferenceExpression initialized = GetMainClassFieldReferenceExpression ("__initialized");
			
			CodeBinaryOperatorExpression bin;
			bin = new CodeBinaryOperatorExpression (initialized,
								CodeBinaryOperatorType.ValueEquality,
								new CodePrimitiveExpression (false));

			CodeAssignStatement assign = new CodeAssignStatement (initialized,
									      new CodePrimitiveExpression (true));

			CodeConditionStatement cond = new CodeConditionStatement ();
			cond.Condition = bin;
			
			if (trueStmt != null)
				cond.TrueStatements.AddRange (trueStmt);
			cond.TrueStatements.Add (assign);
			ctor.Statements.Add (cond);
			AddStatementsToConstructor (ctor);
		}