Ejemplo n.º 1
0
        public override bool ShouldSerialize(IDesignerSerializationManager manager, object value, MemberDescriptor descriptor)
        {
            if (manager == null)
            {
                throw new ArgumentNullException("manager");
            }
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            if (descriptor == null)
            {
                throw new ArgumentNullException("descriptor");
            }

            bool result = ((PropertyDescriptor)descriptor).ShouldSerializeValue(value);

            if (!GetRelationship(manager, value, descriptor).IsEmpty)
            {
                result = true;
            }

            if (!result)
            {
                SerializeAbsoluteContext absolute = manager.Context[typeof(SerializeAbsoluteContext)] as SerializeAbsoluteContext;
                if (absolute.Member == null || absolute.Member == descriptor)
                {
                    result = true;
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
        public override bool ShouldSerialize(IDesignerSerializationManager manager, object value, MemberDescriptor descriptor)
        {
            if (manager == null)
            {
                throw new ArgumentNullException("manager");
            }
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            if (descriptor == null)
            {
                throw new ArgumentNullException("descriptor");
            }

            PropertyDescriptor property = (PropertyDescriptor)descriptor;

            if (property.Attributes.Contains(DesignerSerializationVisibilityAttribute.Hidden))
            {
                return(false);
            }
            else if (property.Attributes.Contains(DesignOnlyAttribute.Yes))
            {
                return(false);
            }

            bool result = property.ShouldSerializeValue(value);

            if (!result)
            {
                if (!GetRelationship(manager, value, descriptor).IsEmpty)
                {
                    result = true;
                }
            }

            if (!result)
            {
                SerializeAbsoluteContext absolute = manager.Context[typeof(SerializeAbsoluteContext)] as SerializeAbsoluteContext;
                if (absolute != null && absolute.ShouldSerialize(descriptor))
                {
                    result = true;
                }
            }

            return(result);
        }
Ejemplo n.º 3
0
        public object SerializeAbsolute(IDesignerSerializationManager manager, object value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            if (manager == null)
            {
                throw new ArgumentNullException("manager");
            }

            SerializeAbsoluteContext context = new SerializeAbsoluteContext();

            manager.Context.Push(context);
            object result = this.Serialize(manager, value);

            manager.Context.Pop();
            return(result);
        }
Ejemplo n.º 4
0
        public virtual CodeStatementCollection SerializeMemberAbsolute(IDesignerSerializationManager manager,
                                                                       object owningobject, MemberDescriptor member)
        {
            if (member == null)
            {
                throw new ArgumentNullException("member");
            }
            if (owningobject == null)
            {
                throw new ArgumentNullException("owningobject");
            }
            if (manager == null)
            {
                throw new ArgumentNullException("manager");
            }

            SerializeAbsoluteContext context = new SerializeAbsoluteContext(member);

            manager.Context.Push(context);
            CodeStatementCollection result = this.SerializeMember(manager, owningobject, member);

            manager.Context.Pop();
            return(result);
        }