예제 #1
0
        /// <summary>
        /// This method deserializes all properties that are serialized as XML attributes.
        /// </summary>
        /// <remarks>
        /// Because this method only handles properties serialized as XML attributes, the passed-in reader shouldn't be moved inside this method.
        /// The caller will guarantee that the reader is positioned on the open XML tag of the current element being deserialized.
        /// </remarks>
        /// <param name="serializationContext">Serialization context.</param>
        /// <param name="element">In-memory LinkShape instance that will get the deserialized data.</param>
        /// <param name="reader">XmlReader to read serialized data from.</param>
        protected override void ReadPropertiesFromAttributes(SerializationContext serializationContext, ModelElement element, System.Xml.XmlReader reader)
        {
            LinkShape instanceOfLinkShape = element as LinkShape;

            global::System.Diagnostics.Debug.Assert(instanceOfLinkShape != null, "Expecting an instance of LinkShape");

            // DummyProperty
            if (!serializationContext.Result.Failed)
            {
                string attribDummyProperty = DiagramsDSLSerializationHelper.Instance.ReadAttribute(serializationContext, element, reader, "dummyProperty");
                if (attribDummyProperty != null)
                {
                    global::System.String valueOfDummyProperty;
                    if (SerializationUtilities.TryGetValue <global::System.String>(serializationContext, attribDummyProperty, out valueOfDummyProperty))
                    {
                        instanceOfLinkShape.DummyProperty = valueOfDummyProperty;
                    }
                    else
                    {   // Invalid property value, ignored.
                        TestDslDefinitionSerializationBehaviorSerializationMessages.IgnoredPropertyValue(serializationContext, reader, "dummyProperty", typeof(global::System.String), attribDummyProperty);
                    }
                }
            }
            // RoutingMode
            if (!serializationContext.Result.Failed)
            {
                string attribRoutingMode = DiagramsDSLSerializationHelper.Instance.ReadAttribute(serializationContext, element, reader, "routingMode");
                if (attribRoutingMode != null)
                {
                    RoutingMode valueOfRoutingMode;
                    if (SerializationUtilities.TryGetValue <RoutingMode>(serializationContext, attribRoutingMode, out valueOfRoutingMode))
                    {
                        instanceOfLinkShape.RoutingMode = valueOfRoutingMode;
                    }
                    else
                    {   // Invalid property value, ignored.
                        TestDslDefinitionSerializationBehaviorSerializationMessages.IgnoredPropertyValue(serializationContext, reader, "routingMode", typeof(RoutingMode), attribRoutingMode);
                    }
                }
            }
            //base.ReadPropertiesFromAttributes(serializationContext, element, reader);
        }
예제 #2
0
        private bool PropertyBase_ReadPropertiesFromAttributes(SerializationContext serializationContext,
                                                               PropertyBase propertyBase, XmlReader reader)
        {
            // Access
            if (!serializationContext.Result.Failed)
            {
                string attribAccess = DONetEntityModelDesignerSerializationHelper.Instance.ReadAttribute(serializationContext, propertyBase, reader, "access");
                if (attribAccess != null)
                {
                    AccessModifier valueOfAccess;
                    if (SerializationUtilities.TryGetValue <AccessModifier>(serializationContext, attribAccess, out valueOfAccess))
                    {
                        propertyBase.PropertyAccess = new PropertyAccessModifiers();
                        PropertyAccessModifier modifier = valueOfAccess == AccessModifier.Public
                                                              ? PropertyAccessModifier.Public
                                                              : PropertyAccessModifier.Internal;
                        propertyBase.PropertyAccess.Getter = modifier;
                        propertyBase.PropertyAccess.Setter = modifier;

                        return(true);
                    }
                    else
                    {   // Invalid property value, ignored.
                        EntityModelDesignerSerializationBehaviorSerializationMessages.IgnoredPropertyValue(serializationContext, reader, "access", typeof(AccessModifier), attribAccess);
                    }
                }
                else
                {
                    propertyBase.PropertyAccess        = new PropertyAccessModifiers();
                    propertyBase.PropertyAccess.Getter = PropertyAccessModifier.Public;
                    propertyBase.PropertyAccess.Setter = PropertyAccessModifier.Public;

                    return(false);
                }
            }

            return(false);
        }