示例#1
0
 public DataService(JNode jNode)
 {
     ServiceName = jNode.Get <String>("serviceName");
     // Adapter = null;
     HasServerMetadata = jNode.Get <bool>("hasServerMetadata");
     // JsonResultsAdapter
     UseJsonP = jNode.Get <bool>("useJsonp");
 }
示例#2
0
        public DataService(JNode jNode)
        {
            ServiceName       = jNode.Get <String>("serviceName");
            HasServerMetadata = jNode.Get <bool>("hasServerMetadata");

            UseJsonP = jNode.Get <bool>("useJsonp");
            Adapter  = GetAdapter(jNode.Get <String>("adapterName"));
            InitializeHttpClient();
        }
示例#3
0
 public ComplexType(JNode jNode)
 {
     ShortName = jNode.Get <String>("shortName");
     Namespace = jNode.Get <String>("namespace");
     // BaseTypeName = jnode.Get<String>("baseTypeName");
     // IsAbstract = jnode.Get<bool>("isAbstract");
     jNode.GetJNodeArray("dataProperties").Select(jn => new DataProperty(jn)).ForEach(dp => AddDataProperty(dp));
     // validators
     // custom
 }
示例#4
0
 public NavigationProperty(JNode jNode)
 {
     Name            = jNode.Get <String>("name");
     EntityTypeName  = jNode.Get <String>("entityTypeName");
     IsScalar        = jNode.Get <bool>("isScalar", true);
     AssociationName = jNode.Get <String>("associationName");
     // _validators.AddRange()
     _foreignKeyNames.AddRange(jNode.GetArray <String>("foreignKeyNames"));
     _invForeignKeyNames.AddRange(jNode.GetArray <String>("invForeignKeyNames"));
     // custom
 }
示例#5
0
        private void PopulateEntity(IEntity targetEntity, JNode jn)
        {
            var targetAspect = targetEntity.EntityAspect;
            var backingStore = targetAspect.BackingStore;

            var entityType = targetAspect.EntityType;

            entityType.DataProperties.ForEach(dp => {
                var propName = dp.Name;
                if (dp.IsComplexProperty)
                {
                    var coNode         = jn.GetJNode(propName);
                    var newCo          = (IComplexObject)coNode.ToObject(dp.ClrType);
                    var targetCo       = (IComplexObject)backingStore[propName];
                    var targetCoAspect = targetCo.ComplexAspect;
                    var coBacking      = targetCoAspect.BackingStore;
                    newCo.ComplexAspect.BackingStore.ForEach(kvp2 => {
                        coBacking[kvp2.Key] = kvp2.Value;
                    });
                    UpdateOriginalValues(targetCoAspect, coNode);
                }
                else
                {
                    var val = jn.Get(propName, dp.ClrType);
                    backingStore[propName] = val;
                }
            });
            UpdateOriginalValues(targetAspect, jn);
        }
示例#6
0
        internal EntityKey(JNode jn)
        {
            var etName = jn.Get <String>("entityType");

            EntityType = MetadataStore.Instance.GetEntityType(etName);
            ClrType    = EntityType.ClrType;
            // coerce the incoming data
            Values = jn.GetArray("values", EntityType.KeyProperties.Select(kp => kp.ClrType)).ToArray();
        }
示例#7
0
        public EntityType(JNode jNode)
        {
            ShortName            = jNode.Get <String>("shortName");
            Namespace            = jNode.Get <String>("namespace");
            BaseTypeName         = jNode.Get <String>("baseTypeName");
            IsAbstract           = jNode.Get <bool>("isAbstract");
            AutoGeneratedKeyType = jNode.GetEnum <AutoGeneratedKeyType>("autoGeneratedKeyType");
            var drn = jNode.Get <String>("defaultResourceName");

            if (drn != null)
            {
                MetadataStore.Instance.AddResourceName(drn, this, true);
            }
            jNode.GetJNodeArray("dataProperties").Select(jn => new DataProperty(jn)).ForEach(dp => AddDataProperty(dp));
            jNode.GetJNodeArray("navigationProperties").Select(jn => new NavigationProperty(jn)).ForEach(np => AddNavigationProperty(np));
            // validators
            // custom
        }
示例#8
0
        private EntityKey ExtractEntityKey(EntityType entityType, JNode jn)
        {
            var keyValues = entityType.KeyProperties
                            .Select(p => jn.Get(p.Name, p.ClrType))
                            .ToArray();
            var entityKey = EntityKey.Create(entityType, keyValues);

            return(entityKey);
        }
示例#9
0
        private void DeserializeFrom(JNode jNode)
        {
            MetadataVersion = jNode.Get <String>("metadataVersion");
            // Name
            NamingConvention = NamingConvention.FromName(jNode.Get <String>("namingConvention"));
            // localQueryComparisonOptions
            jNode.GetJNodeArray("dataServices").Select(jn => new DataService(jn)).ForEach(ds => {
                if (!_dataServiceMap.ContainsKey(ds.ServiceName))
                {
                    _dataServiceMap.Add(ds.ServiceName, ds);
                }
            });
            var stypes = jNode.GetJNodeArray("structuralTypes")
                         .Select(jn => jn.Get <bool>("isComplexType", false)
          ? (StructuralType) new ComplexType(jn)
          : (StructuralType) new EntityType(jn));

            stypes.ForEach(st => this.AddStructuralType(st));

            jNode.GetMap <String>("resourceEntityTypeMap").ForEach(kvp => {
                var et = GetEntityType(kvp.Value);
                AddResourceName(kvp.Key, et);
            });
        }
示例#10
0
        private Validator ValidatorFromJNode(JNode jNode)
        {
            var  vrName = jNode.Get <String>("name");
            Type vrType;

            if (!_validatorMap.TryGetValue(vrName, out vrType))
            {
                var e = new Exception("Unable to create a validator for " + vrName);
                _errors.Add(e);
                return(null);
            }
            // Deserialize the object
            var vr = (Validator)jNode.ToObject(vrType, true);

            return(vr);
        }
示例#11
0
 public DataProperty(JNode jNode)
 {
     Name            = jNode.Get <String>("name");
     ComplexTypeName = jNode.Get <String>("complexTypeName");
     if (ComplexTypeName == null)
     {
         DataType = DataType.FromName(jNode.Get <String>("dataType"));
     }
     IsNullable = jNode.Get <bool>("isNullable", true);
     if (DataType != null)
     {
         DefaultValue = jNode.Get("defaultValue", DataType.ClrType);
     }
     IsPartOfKey        = jNode.Get <bool>("isPartOfKey", false);
     IsUnmapped         = jNode.Get <bool>("isUnmapped", false);
     IsAutoIncrementing = jNode.Get <bool>("isAutoIncrementing", false);
     ConcurrencyMode    = (ConcurrencyMode)Enum.Parse(typeof(ConcurrencyMode), jNode.Get <String>("conncurrencyMode", ConcurrencyMode.None.ToString()));
     MaxLength          = jNode.Get <int?>("maxLength");
     EnumTypeName       = jNode.Get <String>("enumType");
     IsScalar           = jNode.Get <bool>("isScalar", true);
     _validators        = new ValidatorCollection(jNode.GetJNodeArray("validators"));
 }