Example #1
0
        private object GetMemberCodeDomSerializer(IDesignerSerializationManager manager, object currentSerializer, System.Type objectType, System.Type serializerType)
        {
            CodeDomLocalizationModel none = this._model;

            if (!typeof(PropertyDescriptor).IsAssignableFrom(objectType))
            {
                return(null);
            }
            if (currentSerializer == null)
            {
                return(null);
            }
            if (currentSerializer is ResourcePropertyMemberCodeDomSerializer)
            {
                return(null);
            }
            if ((this._extender == null) || !this._extender.GetLocalizable(null))
            {
                return(null);
            }
            PropertyDescriptor descriptor = manager.Context[typeof(PropertyDescriptor)] as PropertyDescriptor;

            if ((descriptor == null) || !descriptor.IsLocalizable)
            {
                none = CodeDomLocalizationModel.None;
            }
            if (this._memberSerializers == null)
            {
                this._memberSerializers = new Hashtable();
            }
            if (this._nopMemberSerializers == null)
            {
                this._nopMemberSerializers = new Hashtable();
            }
            object obj2 = null;

            if (none == CodeDomLocalizationModel.None)
            {
                obj2 = this._nopMemberSerializers[currentSerializer];
            }
            else
            {
                obj2 = this._memberSerializers[currentSerializer];
            }
            if (obj2 == null)
            {
                obj2 = new ResourcePropertyMemberCodeDomSerializer((MemberCodeDomSerializer)currentSerializer, this._extender, none);
                if (none == CodeDomLocalizationModel.None)
                {
                    this._nopMemberSerializers[currentSerializer] = obj2;
                    return(obj2);
                }
                this._memberSerializers[currentSerializer] = obj2;
            }
            return(obj2);
        }
Example #2
0
        /// <summary>
        ///  Returns a code dom serializer for members.
        /// </summary>
        private object GetMemberCodeDomSerializer(IDesignerSerializationManager manager, object currentSerializer, Type objectType, Type serializerType)
        {
            CodeDomLocalizationModel model = _model;

            if (!typeof(PropertyDescriptor).IsAssignableFrom(objectType))
            {
                return(null);
            }

            // Ok, we got a property descriptor.  If we're being localized
            // we provide a different type of serializer.  But, we only
            // do this if we were given a current serializer.  Otherwise
            // we don't know how to perform the serialization.
            // We can only provide a custom serializer if we have an existing one
            // to base off of.
            if (currentSerializer is null)
            {
                return(null);
            }

            // If we've already provided this serializer, don't do it again
            if (currentSerializer is ResourcePropertyMemberCodeDomSerializer)
            {
                return(null);
            }

            // We only care if we're localizable
            if (_extender is null || !_extender.GetLocalizable(null))
            {
                return(null);
            }

            // Fish the property out of the context to see if the property is localizable.
            PropertyDescriptor serializingProperty = manager.Context[typeof(PropertyDescriptor)] as PropertyDescriptor;

            if (serializingProperty is null || !serializingProperty.IsLocalizable)
            {
                model = CodeDomLocalizationModel.None;
            }

            if (_memberSerializers is null)
            {
                _memberSerializers = new Hashtable();
            }

            if (_nopMemberSerializers is null)
            {
                _nopMemberSerializers = new Hashtable();
            }

            object newSerializer;

            if (model == CodeDomLocalizationModel.None)
            {
                newSerializer = _nopMemberSerializers[currentSerializer];
            }
            else
            {
                newSerializer = _memberSerializers[currentSerializer];
            }

            if (newSerializer is null)
            {
                newSerializer = new ResourcePropertyMemberCodeDomSerializer((MemberCodeDomSerializer)currentSerializer, _extender, model);

                if (model == CodeDomLocalizationModel.None)
                {
                    _nopMemberSerializers[currentSerializer] = newSerializer;
                }
                else
                {
                    _memberSerializers[currentSerializer] = newSerializer;
                }
            }

            return(newSerializer);
        }
 private object GetMemberCodeDomSerializer(IDesignerSerializationManager manager, object currentSerializer, System.Type objectType, System.Type serializerType)
 {
     CodeDomLocalizationModel none = this._model;
     if (!typeof(PropertyDescriptor).IsAssignableFrom(objectType))
     {
         return null;
     }
     if (currentSerializer == null)
     {
         return null;
     }
     if (currentSerializer is ResourcePropertyMemberCodeDomSerializer)
     {
         return null;
     }
     if ((this._extender == null) || !this._extender.GetLocalizable(null))
     {
         return null;
     }
     PropertyDescriptor descriptor = manager.Context[typeof(PropertyDescriptor)] as PropertyDescriptor;
     if ((descriptor == null) || !descriptor.IsLocalizable)
     {
         none = CodeDomLocalizationModel.None;
     }
     if (this._memberSerializers == null)
     {
         this._memberSerializers = new Hashtable();
     }
     if (this._nopMemberSerializers == null)
     {
         this._nopMemberSerializers = new Hashtable();
     }
     object obj2 = null;
     if (none == CodeDomLocalizationModel.None)
     {
         obj2 = this._nopMemberSerializers[currentSerializer];
     }
     else
     {
         obj2 = this._memberSerializers[currentSerializer];
     }
     if (obj2 == null)
     {
         obj2 = new ResourcePropertyMemberCodeDomSerializer((MemberCodeDomSerializer) currentSerializer, this._extender, none);
         if (none == CodeDomLocalizationModel.None)
         {
             this._nopMemberSerializers[currentSerializer] = obj2;
             return obj2;
         }
         this._memberSerializers[currentSerializer] = obj2;
     }
     return obj2;
 }