Esempio n. 1
0
        private void InitializePersonalizableProperties()
        {
            this._propertyEntries = new HybridDictionary(false);
            BindingFlags bindingAttr = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;

            PropertyInfo[] properties = this._type.GetProperties(bindingAttr);
            Array.Sort(properties, new DeclaringTypeComparer());
            if ((properties != null) && (properties.Length != 0))
            {
                for (int i = 0; i < properties.Length; i++)
                {
                    PropertyInfo            element = properties[i];
                    string                  name    = element.Name;
                    PersonalizableAttribute attr    = Attribute.GetCustomAttribute(element, PersonalizableAttribute.PersonalizableAttributeType, true) as PersonalizableAttribute;
                    if ((attr == null) || !attr.IsPersonalizable)
                    {
                        this._propertyEntries.Remove(name);
                    }
                    else
                    {
                        ParameterInfo[] indexParameters = element.GetIndexParameters();
                        if (((indexParameters != null) && (indexParameters.Length > 0)) || ((element.GetGetMethod() == null) || (element.GetSetMethod() == null)))
                        {
                            throw new HttpException(System.Web.SR.GetString("PersonalizableTypeEntry_InvalidProperty", new object[] { name, this._type.FullName }));
                        }
                        this._propertyEntries[name] = new PersonalizablePropertyEntry(element, attr);
                    }
                }
            }
        }
 static PersonalizableAttribute()
 {
     Default              = new PersonalizableAttribute(false);
     NotPersonalizable    = Default;
     Personalizable       = new PersonalizableAttribute(PersonalizationScope.User, false);
     SharedPersonalizable = new PersonalizableAttribute(PersonalizationScope.Shared, false);
     UserPersonalizable   = new PersonalizableAttribute(PersonalizationScope.User, false);
 }
Esempio n. 3
0
		static PersonalizableAttribute ()
		{
			Default = new PersonalizableAttribute (false);
			NotPersonalizable = Default;
			Personalizable = new PersonalizableAttribute (PersonalizationScope.User, false);
			SharedPersonalizable = new PersonalizableAttribute (PersonalizationScope.Shared, false);
			UserPersonalizable = new PersonalizableAttribute (PersonalizationScope.User, false);
		}
        public override bool Match(object obj)
        {
            PersonalizableAttribute attr = obj as PersonalizableAttribute;

            if (obj == null)
            {
                return(false);
            }
            return(this.isPersonalizable == attr.IsPersonalizable);
        }
        public override bool Match(object obj)
        {
            if (obj == this)
            {
                return(true);
            }
            PersonalizableAttribute attribute = obj as PersonalizableAttribute;

            return((attribute != null) && (attribute.IsPersonalizable == this.IsPersonalizable));
        }
        public override bool Equals(object obj)
        {
            PersonalizableAttribute attr = obj as PersonalizableAttribute;

            if (attr == null)
            {
                return(false);
            }

            return(this.isPersonalizable == attr.IsPersonalizable &&
                   this.isSensitive == attr.IsSensitive &&
                   this.scope == attr.Scope);
        }
        public override bool Equals(object obj)
        {
            if (obj == this)
            {
                return(true);
            }
            PersonalizableAttribute attribute = obj as PersonalizableAttribute;

            if (attribute == null)
            {
                return(false);
            }
            return(((attribute.IsPersonalizable == this.IsPersonalizable) && (attribute.Scope == this.Scope)) && (attribute.IsSensitive == this.IsSensitive));
        }
Esempio n. 8
0
        /// <internalonly/>
        public override bool Match(object obj)
        {
            if (obj == this)
            {
                return(true);
            }

            PersonalizableAttribute other = obj as PersonalizableAttribute;

            if (other != null)
            {
                return(other.IsPersonalizable == IsPersonalizable);
            }

            return(false);
        }
        private void InitializePersonalizableProperties()
        {
            _propertyEntries = new HybridDictionary(/* caseInsensitive */ false);

            // Get all public and non-public instance properties, including those declared on
            // base types.
            BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

            PropertyInfo[] props = _type.GetProperties(flags);

            // Sorts PropertyInfos according to their DeclaringType.  Base types appear before derived types.
            Array.Sort(props, new DeclaringTypeComparer());

            // For each PropertyInfo, add it to the dictionary if it is personalizable, else remove
            // it from the dictionary.  We need to remove it from the dictionary, in case the base
            // type declared a valid personalizable property of the same name (VSWhidbey 237437).
            if ((props != null) && (props.Length != 0))
            {
                for (int i = 0; i < props.Length; i++)
                {
                    PropertyInfo pi   = props[i];
                    string       name = pi.Name;

                    // Get the PersonalizableAttribute (and include any inherited metadata)
                    PersonalizableAttribute pa = Attribute.GetCustomAttribute(pi,
                                                                              PersonalizableAttribute.PersonalizableAttributeType, true) as PersonalizableAttribute;

                    // If the property is not personalizable, remove it from the dictionary
                    if (pa == null || !pa.IsPersonalizable)
                    {
                        _propertyEntries.Remove(name);
                        continue;
                    }

                    // If the property has parameters, or does not have a public get or set
                    // accessor, throw an exception.
                    ParameterInfo[] paramList = pi.GetIndexParameters();
                    if ((paramList != null && paramList.Length > 0) || pi.GetGetMethod() == null || pi.GetSetMethod() == null)
                    {
                        throw new HttpException(SR.GetString(SR.PersonalizableTypeEntry_InvalidProperty, name, _type.FullName));
                    }

                    // Add the property to the dictionary
                    _propertyEntries[name] = new PersonalizablePropertyEntry(pi, pa);
                }
            }
        }
Esempio n. 10
0
        /// <internalonly/>
        public override bool Equals(object obj)
        {
            if (obj == this)
            {
                return(true);
            }

            PersonalizableAttribute other = obj as PersonalizableAttribute;

            if (other != null)
            {
                return((other.IsPersonalizable == IsPersonalizable) &&
                       (other.Scope == Scope) &&
                       (other.IsSensitive == IsSensitive));
            }

            return(false);
        }
 public override bool IsDefaultAttribute()
 {
     return(PersonalizableAttribute.Equals(this, Default));
 }
 public PersonalizablePropertyEntry(PropertyInfo pi, PersonalizableAttribute attr)
 {
     _propertyInfo = pi;
     _scope        = attr.Scope;
     _isSensitive  = attr.IsSensitive;
 }
 public PersonalizablePropertyEntry(System.Reflection.PropertyInfo pi, PersonalizableAttribute attr)
 {
     this._propertyInfo = pi;
     this._scope        = attr.Scope;
     this._isSensitive  = attr.IsSensitive;
 }
 public PersonalizablePropertyEntry(System.Reflection.PropertyInfo pi, PersonalizableAttribute attr)
 {
     this._propertyInfo = pi;
     this._scope = attr.Scope;
     this._isSensitive = attr.IsSensitive;
 }
 public PersonalizablePropertyEntry(PropertyInfo pi, PersonalizableAttribute attr) {
     _propertyInfo = pi;
     _scope = attr.Scope;
     _isSensitive = attr.IsSensitive;
 }
        internal static IDictionary SetPersonalizedProperties(Control control, IDictionary propertyState)
        {
            IDictionary personalizablePropertyEntries = PersonalizableAttribute.GetPersonalizablePropertyEntries(control.GetType());

            return(SetPersonalizedProperties(control, personalizablePropertyEntries, propertyState, System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared));
        }
        internal static IDictionary GetPersonalizedProperties(Control control, System.Web.UI.WebControls.WebParts.PersonalizationScope scope)
        {
            IDictionary personalizablePropertyEntries = PersonalizableAttribute.GetPersonalizablePropertyEntries(control.GetType());

            return(GetPersonalizedProperties(control, personalizablePropertyEntries, null, null, scope));
        }
        private void ApplyPersonalization(Control control, string personalizationID, bool isWebPartManager, System.Web.UI.WebControls.WebParts.PersonalizationScope extractScope, GenericWebPart genericWebPart)
        {
            if (this._personalizedControls == null)
            {
                this._personalizedControls = new HybridDictionary(false);
            }
            else if (this._personalizedControls.Contains(personalizationID))
            {
                throw new InvalidOperationException(System.Web.SR.GetString("BlobPersonalizationState_CantApply", new object[] { personalizationID }));
            }
            IDictionary personalizablePropertyEntries = PersonalizableAttribute.GetPersonalizablePropertyEntries(control.GetType());

            if (this.SharedState == null)
            {
                throw new InvalidOperationException(System.Web.SR.GetString("BlobPersonalizationState_NotLoaded"));
            }
            PersonalizationInfo       sharedInfo              = (PersonalizationInfo)this.SharedState[personalizationID];
            PersonalizationInfo       userInfo                = null;
            IDictionary               dictionary2             = null;
            IDictionary               dictionary3             = null;
            PersonalizationDictionary customInitialProperties = null;
            ControlInfo               info3 = new ControlInfo {
                _allowSetDirty = false
            };

            this._personalizedControls[personalizationID] = info3;
            if (((sharedInfo != null) && sharedInfo._isStatic) && !sharedInfo.IsMatchingControlType(control))
            {
                sharedInfo = null;
                if (this.PersonalizationScope == System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared)
                {
                    this.SetControlDirty(control, personalizationID, isWebPartManager, true);
                }
            }
            IPersonalizable         personalizable  = control as IPersonalizable;
            ITrackingPersonalizable personalizable2 = control as ITrackingPersonalizable;
            WebPart hasDataWebPart = null;

            if (!isWebPartManager)
            {
                if (genericWebPart != null)
                {
                    hasDataWebPart = genericWebPart;
                }
                else
                {
                    hasDataWebPart = (WebPart)control;
                }
            }
            try
            {
                if (personalizable2 != null)
                {
                    personalizable2.BeginLoad();
                }
                if (this.PersonalizationScope == System.Web.UI.WebControls.WebParts.PersonalizationScope.User)
                {
                    if (this.UserState == null)
                    {
                        throw new InvalidOperationException(System.Web.SR.GetString("BlobPersonalizationState_NotLoaded"));
                    }
                    userInfo = (PersonalizationInfo)this.UserState[personalizationID];
                    if (((userInfo != null) && userInfo._isStatic) && !userInfo.IsMatchingControlType(control))
                    {
                        userInfo = null;
                        this.SetControlDirty(control, personalizationID, isWebPartManager, true);
                    }
                    if (personalizable != null)
                    {
                        PersonalizationDictionary state = this.MergeCustomProperties(sharedInfo, userInfo, isWebPartManager, hasDataWebPart, ref customInitialProperties);
                        if (state != null)
                        {
                            info3._allowSetDirty = true;
                            personalizable.Load(state);
                            info3._allowSetDirty = false;
                        }
                    }
                    if (!isWebPartManager)
                    {
                        IDictionary dictionary6 = null;
                        IDictionary dictionary7 = null;
                        if (sharedInfo != null)
                        {
                            IDictionary propertyState = sharedInfo._properties;
                            if ((propertyState != null) && (propertyState.Count != 0))
                            {
                                hasDataWebPart.SetHasSharedData(true);
                                dictionary6 = SetPersonalizedProperties(control, personalizablePropertyEntries, propertyState, System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
                            }
                        }
                        dictionary2 = GetPersonalizedProperties(control, personalizablePropertyEntries, null, null, extractScope);
                        if (userInfo != null)
                        {
                            IDictionary dictionary9 = userInfo._properties;
                            if ((dictionary9 != null) && (dictionary9.Count != 0))
                            {
                                hasDataWebPart.SetHasUserData(true);
                                dictionary7 = SetPersonalizedProperties(control, personalizablePropertyEntries, dictionary9, extractScope);
                            }
                            if ((personalizable2 == null) || !personalizable2.TracksChanges)
                            {
                                dictionary3 = dictionary9;
                            }
                        }
                        if ((dictionary6 != null) || (dictionary7 != null))
                        {
                            IVersioningPersonalizable personalizable3 = control as IVersioningPersonalizable;
                            if (personalizable3 != null)
                            {
                                IDictionary unknownProperties = null;
                                if (dictionary6 != null)
                                {
                                    unknownProperties = dictionary6;
                                    if (dictionary7 != null)
                                    {
                                        foreach (DictionaryEntry entry in dictionary7)
                                        {
                                            unknownProperties[entry.Key] = entry.Value;
                                        }
                                    }
                                }
                                else
                                {
                                    unknownProperties = dictionary7;
                                }
                                info3._allowSetDirty = true;
                                personalizable3.Load(unknownProperties);
                                info3._allowSetDirty = false;
                            }
                            else
                            {
                                this.SetControlDirty(control, personalizationID, isWebPartManager, true);
                            }
                        }
                    }
                }
                else
                {
                    if (personalizable != null)
                    {
                        PersonalizationDictionary dictionary11 = this.MergeCustomProperties(sharedInfo, userInfo, isWebPartManager, hasDataWebPart, ref customInitialProperties);
                        if (dictionary11 != null)
                        {
                            info3._allowSetDirty = true;
                            personalizable.Load(dictionary11);
                            info3._allowSetDirty = false;
                        }
                    }
                    if (!isWebPartManager)
                    {
                        IDictionary dictionary12 = null;
                        dictionary2 = GetPersonalizedProperties(control, personalizablePropertyEntries, null, null, extractScope);
                        if (sharedInfo != null)
                        {
                            IDictionary dictionary13 = sharedInfo._properties;
                            if ((dictionary13 != null) && (dictionary13.Count != 0))
                            {
                                hasDataWebPart.SetHasSharedData(true);
                                dictionary12 = SetPersonalizedProperties(control, personalizablePropertyEntries, dictionary13, System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
                            }
                            if ((personalizable2 == null) || !personalizable2.TracksChanges)
                            {
                                dictionary3 = dictionary13;
                            }
                        }
                        if (dictionary12 != null)
                        {
                            IVersioningPersonalizable personalizable4 = control as IVersioningPersonalizable;
                            if (personalizable4 != null)
                            {
                                info3._allowSetDirty = true;
                                personalizable4.Load(dictionary12);
                                info3._allowSetDirty = false;
                            }
                            else
                            {
                                this.SetControlDirty(control, personalizationID, isWebPartManager, true);
                            }
                        }
                    }
                }
            }
            finally
            {
                info3._allowSetDirty = true;
                if (personalizable2 != null)
                {
                    personalizable2.EndLoad();
                }
            }
            info3._control = control;
            info3._personalizableProperties = personalizablePropertyEntries;
            info3._defaultProperties        = dictionary2;
            info3._initialProperties        = dictionary3;
            info3._customInitialProperties  = customInitialProperties;
        }