Exemplo n.º 1
0
 public static void __Reset()
 {
     lock (__lock) {
         var x = __instance._probedAssemblies;
         __instance = new MetadataStore();
         __instance.ProbeAssemblies(x.ToArray());
     }
 }
Exemplo n.º 2
0
        private ImportResult ImportEntities(JNode jn, ImportOptions importOptions)
        {
            importOptions = importOptions ?? ImportOptions.Default;
            if (importOptions.ShouldMergeMetadata)
            {
                var msNode = jn.GetJNode("metadataStore");
                if (msNode != null)
                {
                    MetadataStore.ImportMetadata(msNode);
                    var dsJn = jn.GetJNode("dataService");
                    if (dsJn != null)
                    {
                        DefaultDataService = new DataService(dsJn);
                    }
                    var qoJn = jn.GetJNode("queryOptions");
                    if (qoJn != null)
                    {
                        DefaultQueryOptions = new QueryOptions(qoJn);
                    }
                }
            }
            var entityGroupNodesMap = jn.GetJNodeArrayMap("entityGroupMap");
            // tempKeyMap will have a new values where collisions will occur
            var tempKeyMap = jn.GetJNodeArray("tempKeys").Select(jnEk => new EntityKey(jnEk)).ToDictionary(
                ek => ek,
                ek => this.FindEntityByKey(ek) == null ? ek : EntityKey.Create(ek.EntityType, KeyGenerator.GetNextTempId(ek.EntityType.KeyProperties.First()))
                );

            var mergeStrategy    = (importOptions.MergeStrategy ?? this.DefaultQueryOptions.MergeStrategy ?? QueryOptions.Default.MergeStrategy).Value;
            var importedEntities = new List <IEntity>();

            using (NewIsLoadingBlock()) {
                entityGroupNodesMap.ForEach(kvp => {
                    var entityTypeName = kvp.Key;
                    var entityNodes    = kvp.Value;
                    var entityType     = MetadataStore.GetEntityType(entityTypeName);
                    var entities       = ImportEntityGroup(entityNodes, entityType, tempKeyMap, mergeStrategy);
                    importedEntities.AddRange(entities);
                });
            }
            return(new ImportResult(importedEntities, tempKeyMap));
        }
Exemplo n.º 3
0
        public CsdlMetadataProcessor(MetadataStore metadataStore, String jsonMetadata)
        {
            _metadataStore = metadataStore;
            var json = (JObject)JsonConvert.DeserializeObject(jsonMetadata);

            _schema    = json["schema"];
            _namespace = (String)_schema["namespace"];

            var mapping = (String)_schema["cSpaceOSpaceMapping"];

            if (mapping != null)
            {
                var tmp = (JArray)JsonConvert.DeserializeObject(mapping);
                _cSpaceOSpaceMap = tmp.ToDictionary(v => (String)v[0], v => (String)v[1]);
            }

            var entityTypes = ToEnumerable(_schema["entityType"]).Cast <JObject>()
                              .Select(ParseCsdlEntityType).ToList();
            var complexTypes = ToEnumerable(_schema["complexType"]).Cast <JObject>()
                               .Select(ParseCsdlComplexType).ToList();

            entityTypes.ForEach(et => ResolveComplexTypeRefs(et));

            var entityContainer = _schema["entityContainer"];

            if (entityContainer != null)
            {
                var entitySets = ToEnumerable(entityContainer["entitySet"]).Cast <JObject>().ToList();
                entitySets.ForEach(es => {
                    var entityTypeInfo = ParseTypeName((String)es["entityType"]);
                    var entityType     = _metadataStore.GetEntityType(entityTypeInfo.TypeName);
                    var resourceName   = (String)es["name"];
                    _metadataStore.AddResourceName(resourceName, entityType, true);
                });
            }
        }
Exemplo n.º 4
0
 public static void __Reset()
 {
     lock (__lock) {
         __instance = new MetadataStore();
     }
 }
Exemplo n.º 5
0
 public override bool CanConvert(Type objectType)
 {
     return(MetadataStore.IsStructuralType(objectType));
 }
Exemplo n.º 6
0
 public ClrTypeMap(MetadataStore metadataStore)
 {
     _metadataStore = metadataStore;
 }
Exemplo n.º 7
0
 public async Task <DataService> FetchMetadata(DataService dataService = null)
 {
     dataService = dataService != null ? dataService : this.DefaultDataService;
     return(await MetadataStore.FetchMetadata(dataService));
 }
Exemplo n.º 8
0
 public override bool CanConvert(Type objectType)
 {
     return(MetadataStore.IsStructuralType(objectType));
     // return MetadataStore.IsStructuralType(objectType) || objectType == typeof(Object);
 }