예제 #1
0
        /// <summary>Whether the types contained in the set has mappings for friendly feeds are V1 compatible or not</summary>
        /// <param name="provider">Data service provider instance.</param>
        /// <returns>False if there's any type in this set which has friendly feed mappings with KeepInContent=false. True otherwise.</returns>
        internal bool EpmIsV1Compatible(DataServiceProviderWrapper provider)
        {
#if DEBUG
            Debug.Assert(provider != null, "provider != null");
            Debug.Assert(this.resourceSet != null, "this.resourceSet != null");
            Debug.Assert(this.isReadOnly, "EpmIsV1Compatible - entity set settings not initialized.");
#endif
            if (!this.epmIsV1Compatible.HasValue)
            {
                // Go through all types contained in the set. If any one type is EpmIsV1Compatible == false,
                // the whole set is EpmIsV1Compatible=false.
                ResourceType baseType       = this.resourceSet.ResourceType;
                bool         isV1Compatible = baseType.EpmIsV1Compatible;

                // If the base type is not epm v1 compatible or it has no derived type, we need not look any further.
                if (isV1Compatible && provider.HasDerivedTypes(baseType))
                {
                    foreach (ResourceType derivedType in provider.GetDerivedTypes(baseType))
                    {
                        if (!derivedType.EpmIsV1Compatible)
                        {
                            // We can stop as soon as we find the first type that is not epm v1 compatible.
                            isV1Compatible = false;
                            break;
                        }
                    }
                }

                this.epmIsV1Compatible = isV1Compatible;
            }

            return(this.epmIsV1Compatible.Value);
        }
예제 #2
0
 private void CheckHierarchy(DataServiceProviderWrapper provider)
 {
     if (!this.epmMinDSPV.HasValue)
     {
         System.Data.Services.Providers.ResourceType resourceType = this.resourceSet.ResourceType;
         bool hasEntityPropertyMappings = resourceType.HasEntityPropertyMappings;
         DataServiceProtocolVersion epmMinimumDataServiceProtocolVersion = resourceType.EpmMinimumDataServiceProtocolVersion;
         bool    flag2           = false;
         bool    flag3           = this.GetEntitySerializableProperties(provider, resourceType).Any <ResourceProperty>(p => p.TypeKind == ResourceTypeKind.EntityType);
         bool    isOpenType      = resourceType.IsOpenType;
         Version metadataVersion = resourceType.MetadataVersion;
         if (provider.HasDerivedTypes(resourceType))
         {
             foreach (System.Data.Services.Providers.ResourceType type2 in provider.GetDerivedTypes(resourceType))
             {
                 if (type2.EpmMinimumDataServiceProtocolVersion > epmMinimumDataServiceProtocolVersion)
                 {
                     epmMinimumDataServiceProtocolVersion = type2.EpmMinimumDataServiceProtocolVersion;
                 }
                 hasEntityPropertyMappings |= type2.HasEntityPropertyMappings;
                 bool flag5 = this.GetEntitySerializablePropertiesDeclaredOnTheResourceType(provider, type2).Any <ResourceProperty>(p => p.TypeKind == ResourceTypeKind.EntityType);
                 flag3          |= flag5;
                 flag2          |= type2.HasNamedStreamsDeclaredOnThisType | flag5;
                 metadataVersion = WebUtil.RaiseVersion(metadataVersion, type2.MetadataVersion);
                 isOpenType     |= type2.IsOpenType;
                 if (((epmMinimumDataServiceProtocolVersion == DataServiceProtocolVersion.V3) && (metadataVersion == RequestDescription.Version3Dot0)) && (flag2 && isOpenType))
                 {
                     break;
                 }
             }
         }
         this.hasEntityPropertyMappings = hasEntityPropertyMappings;
         this.epmMinDSPV = new DataServiceProtocolVersion?(epmMinimumDataServiceProtocolVersion);
         this.hasNavigationPropertyOrNamedStreamOnDerivedTypes = flag2;
         this.hasAccessibleNavigationProperty = flag3;
         this.hasOpenTypes    = isOpenType;
         this.metadataVersion = metadataVersion;
     }
 }