void CreateApplicationInstance ()
{
CodeMemberProperty prop = new CodeMemberProperty ();
Type appType = typeof (HttpApplication);
prop.Type = new CodeTypeReference (appType);
prop.Name = "ApplicationInstance";
prop.Attributes = MemberAttributes.Family | MemberAttributes.Final;
CodePropertyReferenceExpression propRef = new CodePropertyReferenceExpression (thisRef, "Context");
propRef = new CodePropertyReferenceExpression (propRef, "ApplicationInstance");
CodeCastExpression cast = new CodeCastExpression (appType.FullName, propRef);
prop.GetStatements.Add (new CodeMethodReturnStatement (cast));
if (partialClass != null)
partialClass.Members.Add (prop);
else
mainClass.Members.Add (prop);
}