private ResourcePropertyCache InitializeResourcePropertyCache(DataServiceProviderWrapper provider, System.Data.Services.Providers.ResourceType type)
        {
            ResourcePropertyCache cache;

            if (!this.resourcePropertyCache.TryGetValue(type, out cache))
            {
                cache = new ResourcePropertyCache {
                    Properties = new List <ResourceProperty>()
                };
                foreach (ResourceProperty property in type.Properties)
                {
                    if ((property.TypeKind != ResourceTypeKind.EntityType) || (provider.GetContainer(this, type, property) != null))
                    {
                        cache.Properties.Add(property);
                    }
                }
                cache.PropertiesDeclaredOnTheType = new List <ResourceProperty>();
                foreach (ResourceProperty property2 in type.PropertiesDeclaredOnThisType)
                {
                    if ((property2.TypeKind != ResourceTypeKind.EntityType) || (provider.GetContainer(this, type, property2) != null))
                    {
                        cache.PropertiesDeclaredOnTheType.Add(property2);
                    }
                }
                this.resourcePropertyCache.Add(type, cache);
            }
            return(cache);
        }
Beispiel #2
0
        /// <summary>
        /// Gets the visible resource properties declared on the <paramref name="entityType"/> for this set.
        /// We cache the list of visible resource properties so we don't have to calculate it repeatedly when serializing feeds.
        /// </summary>
        /// <param name="provider">Data service provider instance.</param>
        /// <param name="entityType">Resource type in question.</param>
        /// <returns>List of visible resource properties declared on the resource type.</returns>
        private IEnumerable <ResourceProperty> GetEntitySerializablePropertiesDeclaredOnTheResourceType(DataServiceProviderWrapper provider, ResourceType entityType)
        {
            Debug.Assert(entityType != null && entityType.ResourceTypeKind == ResourceTypeKind.EntityType, "entityType != null && entityType.ResourceTypeKind == ResourceTypeKind.EntityType");

            ResourcePropertyCache cachedResourceProperties = this.InitializeResourcePropertyCache(provider, entityType);

            return(cachedResourceProperties.PropertiesDeclaredOnTheType);
        }
Beispiel #3
0
        /// <summary>
        /// Checks if the cache is populated, otherwise populates it.
        /// </summary>
        /// <param name="provider">Data service provider instance.</param>
        /// <param name="type">Resource type in question.</param>
        /// <returns>An instance of ResourcePropertyCache, with all information about the properties cached.</returns>
        private ResourcePropertyCache InitializeResourcePropertyCache(DataServiceProviderWrapper provider, ResourceType type)
        {
            Debug.Assert(provider != null, "provider != null");
            Debug.Assert(type != null, "resourceType != null");
            Debug.Assert(this.ResourceType.IsAssignableFrom(type), "this.ResourceType.IsAssignableFrom(resourceType)");

            ResourcePropertyCache propertyCache;

            if (!this.resourcePropertyCache.TryGetValue(type, out propertyCache))
            {
                propertyCache            = new ResourcePropertyCache();
                propertyCache.Properties = new List <ResourceProperty>();
                foreach (ResourceProperty property in type.Properties)
                {
                    if (property.TypeKind == ResourceTypeKind.EntityType && provider.GetResourceSet(this, type, property) == null)
                    {
                        // non-visible nav properties
                        continue;
                    }

                    propertyCache.Properties.Add(property);
                }

                propertyCache.PropertiesDeclaredOnTheType = new List <ResourceProperty>();
                foreach (ResourceProperty property in type.PropertiesDeclaredOnThisType)
                {
                    if (property.TypeKind == ResourceTypeKind.EntityType && provider.GetResourceSet(this, type, property) == null)
                    {
                        // non-visible nav properties
                        continue;
                    }

                    propertyCache.PropertiesDeclaredOnTheType.Add(property);
                }

                this.resourcePropertyCache.Add(type, propertyCache);
            }

            return(propertyCache);
        }
Beispiel #4
0
 private ResourcePropertyCache InitializeResourcePropertyCache(DataServiceProviderWrapper provider, System.Data.Services.Providers.ResourceType type)
 {
     ResourcePropertyCache cache;
     if (!this.resourcePropertyCache.TryGetValue(type, out cache))
     {
         cache = new ResourcePropertyCache {
             Properties = new List<ResourceProperty>()
         };
         foreach (ResourceProperty property in type.Properties)
         {
             if ((property.TypeKind != ResourceTypeKind.EntityType) || (provider.GetContainer(this, type, property) != null))
             {
                 cache.Properties.Add(property);
             }
         }
         cache.PropertiesDeclaredOnTheType = new List<ResourceProperty>();
         foreach (ResourceProperty property2 in type.PropertiesDeclaredOnThisType)
         {
             if ((property2.TypeKind != ResourceTypeKind.EntityType) || (provider.GetContainer(this, type, property2) != null))
             {
                 cache.PropertiesDeclaredOnTheType.Add(property2);
             }
         }
         this.resourcePropertyCache.Add(type, cache);
     }
     return cache;
 }
        /// <summary>
        /// Checks if the cache is populated, otherwise populates it.
        /// </summary>
        /// <param name="provider">Data service provider instance.</param>
        /// <param name="type">Resource type in question.</param>
        /// <returns>An instance of ResourcePropertyCache, with all information about the properties cached.</returns>
        private ResourcePropertyCache InitializeResourcePropertyCache(DataServiceProviderWrapper provider, ResourceType type)
        {
            Debug.Assert(provider != null, "provider != null");
            Debug.Assert(type != null, "resourceType != null");
            Debug.Assert(this.ResourceType.IsAssignableFrom(type), "this.ResourceType.IsAssignableFrom(resourceType)");

            ResourcePropertyCache propertyCache;
            if (!this.resourcePropertyCache.TryGetValue(type, out propertyCache))
            {
                propertyCache = new ResourcePropertyCache();
                propertyCache.Properties = new List<ResourceProperty>();
                foreach (ResourceProperty property in type.Properties)
                {
                    if (property.TypeKind == ResourceTypeKind.EntityType && provider.GetResourceSet(this, type, property) == null)
                    {
                        // non-visible nav properties
                        continue;
                    }

                    propertyCache.Properties.Add(property);
                }

                propertyCache.PropertiesDeclaredOnTheType = new List<ResourceProperty>();
                foreach (ResourceProperty property in type.PropertiesDeclaredOnThisType)
                {
                    if (property.TypeKind == ResourceTypeKind.EntityType && provider.GetResourceSet(this, type, property) == null)
                    {
                        // non-visible nav properties
                        continue;
                    }

                    propertyCache.PropertiesDeclaredOnTheType.Add(property);
                }

                this.resourcePropertyCache.Add(type, propertyCache);
            }

            return propertyCache;
        }