private void BuildProfileProperty()
 {
     if (ProfileManager.Enabled)
     {
         CodeMemberProperty property;
         string             profileClassName = ProfileBase.GetProfileClassName();
         property = new CodeMemberProperty {
             Attributes = property.Attributes & ~MemberAttributes.AccessMask,
             Attributes = property.Attributes & ~MemberAttributes.ScopeMask,
             Attributes = property.Attributes | (MemberAttributes.Family | MemberAttributes.Final),
             Name       = "Profile"
         };
         if (this._designerMode)
         {
             this.ApplyEditorBrowsableCustomAttribute(property);
         }
         property.Type = new CodeTypeReference(profileClassName);
         CodePropertyReferenceExpression targetObject = new CodePropertyReferenceExpression(new CodeThisReferenceExpression(), "Context");
         targetObject = new CodePropertyReferenceExpression(targetObject, "Profile");
         property.GetStatements.Add(new CodeMethodReturnStatement(new CodeCastExpression(profileClassName, targetObject)));
         this._intermediateClass.Members.Add(property);
     }
 }
Ejemplo n.º 2
0
        /*
         * Build the Profile property
         */
        private void BuildProfileProperty()
        {
            if (!ProfileManager.Enabled)
            {
                return;
            }

            CodeMemberProperty prop;
            string             typeName = ProfileBase.GetProfileClassName();

            prop             = new CodeMemberProperty();
            prop.Attributes &= ~MemberAttributes.AccessMask;
            prop.Attributes &= ~MemberAttributes.ScopeMask;
            prop.Attributes |= MemberAttributes.Final | MemberAttributes.Family;
            prop.Name        = "Profile";

            if (_designerMode)
            {
                ApplyEditorBrowsableCustomAttribute(prop);
            }

            //if (ProfileBase.GetPropertiesForCompilation().Count == 0)
            //    typeName = "System.Web.Profile.DefaultProfile";
            //else
            //    typeName = "ASP.Profile";
            prop.Type = new CodeTypeReference(typeName);

            CodePropertyReferenceExpression propRef = new CodePropertyReferenceExpression(
                new CodeThisReferenceExpression(), "Context");

            propRef = new CodePropertyReferenceExpression(propRef, "Profile");

            prop.GetStatements.Add(new CodeMethodReturnStatement(new CodeCastExpression(
                                                                     typeName, propRef)));
            _intermediateClass.Members.Add(prop);
        }