Beispiel #1
0
        private static void CustomReadPropertiesFromElements(SerializationContext serializationContext, Interface element, XmlReader reader)
        {
            while (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element)
            {
                switch (reader.LocalName)
                {
                case "inheritsIEntity":
                    if (reader.IsEmptyElement)
                    {                                        // No serialized value, must be default one.
                        SerializationUtilities.Skip(reader); // Skip this tag.
                    }
                    else
                    {
                        string strValue = DONetEntityModelDesignerSerializationHelper.Instance.ReadElementContentAsString(serializationContext, element, reader);
                        InheritsIEntityMode value;
                        if (Enum.TryParse(strValue, true, out value))
                        {
                            element.InheritsIEntity = value;
                        }
                        else
                        {       // Invalid property value, ignored.
                            EntityModelDesignerSerializationBehaviorSerializationMessages.IgnoredPropertyValue(serializationContext, reader, "inheritsIEntity", typeof(InheritsIEntityMode), strValue);
                        }

                        SerializationUtilities.SkipToNextElement(reader);
                    }
                    break;

                default:
                    return;  // Don't know this element.
                }
            }
        }
Beispiel #2
0
        private bool ScalarProperty_ReadPropertiesFromAttributes(SerializationContext serializationContext,
                                                                 ScalarProperty scalarProperty, XmlReader reader)
        {
            // Type
            if (!serializationContext.Result.Failed)
            {
                string attribType = DONetEntityModelDesignerSerializationHelper.Instance.ReadAttribute(serializationContext, scalarProperty, reader, "type");
                if (!string.IsNullOrEmpty(attribType))
                {
                    string typeDisplayName = SystemPrimitiveTypesConverter.GetDisplayName(attribType);
                    if (!string.IsNullOrEmpty(typeDisplayName))
                    {
                        Type        clrType     = SystemPrimitiveTypesConverter.GetClrType(typeDisplayName);
                        Guid        typeId      = SystemPrimitiveTypesConverter.GetTypeId(clrType);
                        IModelRoot  entityModel = scalarProperty.Store.GetEntityModel();
                        IDomainType domainType  = entityModel.GetDomainType(typeId);
                        if (domainType == null)
                        {
                            domainType =
                                entityModel.BuildInDomainTypes.SingleOrDefault(type => type.FullName == "System.String");
                        }

                        scalarProperty.Type = (DomainType)domainType;

                        return(true);
                    }
                    else
                    {   // Invalid property value, ignored.
                        EntityModelDesignerSerializationBehaviorSerializationMessages.IgnoredPropertyValue(serializationContext, reader, "type", typeof(global::System.String), attribType);
                    }
                }
            }

            return(false);
        }
        private static void CustomReadPropertiesFromElements(SerializationContext serializationContext, NavigationProperty element, XmlReader reader)
        {
            while (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element)
            {
                switch (reader.LocalName)
                {
                case "key":                                  // key
                    if (reader.IsEmptyElement)
                    {                                        // No serialized value, must be default one.
                        SerializationUtilities.Skip(reader); // Skip this tag.
                    }
                    else
                    {
                        OrmKeyAttribute keyAttribute = new OrmKeyAttribute();
                        keyAttribute.DeserializeFromXml(reader);
                        element.KeyAttribute = keyAttribute;

                        SerializationUtilities.SkipToNextElement(reader);
                        reader.SkipToNextElementFix();
                    }
                    break;

                case "multiplicity":                         // Multiplicity
                    if (reader.IsEmptyElement)
                    {                                        // No serialized value, must be default one.
                        SerializationUtilities.Skip(reader); // Skip this tag.
                    }
                    else
                    {
                        string           strMultiplicity = DONetEntityModelDesignerSerializationHelper.Instance.ReadElementContentAsString(serializationContext, element, reader);
                        MultiplicityKind valueOfMultiplicity;
                        if (Enum.TryParse(strMultiplicity, true, out valueOfMultiplicity))
                        {
                            element.Multiplicity = valueOfMultiplicity;
                        }
                        else
                        {       // Invalid property value, ignored.
                            EntityModelDesignerSerializationBehaviorSerializationMessages.IgnoredPropertyValue(serializationContext, reader, "multiplicity", typeof(global::TXSoftware.DataObjectsNetEntityModel.Common.MultiplicityKind), strMultiplicity);
                        }

                        SerializationUtilities.SkipToNextElement(reader);
                    }
                    break;

                default:
                    return;      // Don't know this element.
                }
            }
        }
Beispiel #4
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);
        }