Пример #1
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);
        }
Пример #2
0
            public Type TryGetClrType(Type defaultType)
            {
                Type result = null;

                string displayName = SystemPrimitiveTypesConverter.GetDisplayName(this.FullName);

                if (!string.IsNullOrEmpty(displayName))
                {
                    result = SystemPrimitiveTypesConverter.GetClrType(displayName);
                }

                return(result ?? defaultType);
            }