コード例 #1
0
        /// <summary>
        /// Gets the target set from the binding set and path expression.
        /// </summary>
        /// <param name="provider">Provider instance to resolve the association set.</param>
        /// <param name="bindingSet">Binding resource set.</param>
        /// <returns>Returns the target resource set for the path expression.</returns>
        internal ResourceSetWrapper GetTargetSet(DataServiceProviderWrapper provider, ResourceSetWrapper bindingSet)
        {
            Debug.Assert(provider != null, "provider != null");
            Debug.Assert(bindingSet != null, "sourceSet != null");
            Debug.Assert(this.pathSegments != null && this.pathSegments.Length > 0, "InitializePathSegments() must be called before this.");
            Debug.Assert(bindingSet.ResourceType.IsAssignableFrom(this.pathSegments[0].SourceType), "bindingSet.ResourceType.IsAssignableFrom(this.pathSegments[0].SourceType)");

            ResourceSetWrapper resultSet = bindingSet;

            for (int idx = 0; resultSet != null && idx < this.pathSegments.Length; idx++)
            {
                PathSegment segment = this.pathSegments[idx];
                if (segment.Property != null)
                {
                    resultSet = provider.GetResourceSet(resultSet, segment.SourceType, segment.Property);
                }
#if DEBUG
                else
                {
                    Debug.Assert(idx == 0, "Path cannot end with type identifier.");
                }
#endif
            }

            return(resultSet);
        }
コード例 #2
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);
        }
コード例 #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;
        }
コード例 #4
0
        /// <summary>
        /// Gets the target set from the binding set and path expression.
        /// </summary>
        /// <param name="provider">Provider instance to resolve the association set.</param>
        /// <param name="bindingSet">Binding resource set.</param>
        /// <returns>Returns the target resource set for the path expression.</returns>
        internal ResourceSetWrapper GetTargetSet(DataServiceProviderWrapper provider, ResourceSetWrapper bindingSet)
        {
            Debug.Assert(provider != null, "provider != null");
            Debug.Assert(bindingSet != null, "sourceSet != null");
            Debug.Assert(this.pathSegments != null && this.pathSegments.Length > 0, "InitializePathSegments() must be called before this.");
            Debug.Assert(bindingSet.ResourceType.IsAssignableFrom(this.pathSegments[0].SourceType), "bindingSet.ResourceType.IsAssignableFrom(this.pathSegments[0].SourceType)");

            ResourceSetWrapper resultSet = bindingSet;
            for (int idx = 0; resultSet != null && idx < this.pathSegments.Length; idx++)
            {
                PathSegment segment = this.pathSegments[idx];
                if (segment.Property != null)
                {
                    resultSet = provider.GetResourceSet(resultSet, segment.SourceType, segment.Property);
                }
#if DEBUG
                else
                {
                    Debug.Assert(idx == 0, "Path cannot end with type identifier.");
                }
#endif
            }

            return resultSet;
        }