Example #1
0
 internal DataServiceProviderWrapper(DataServiceCacheItem cacheItem, IDataServiceMetadataProvider metadataProvider, IDataServiceQueryProvider queryProvider, IDataService dataService)
 {
     this.metadata                  = cacheItem;
     this.metadataProvider          = metadataProvider;
     this.queryProvider             = queryProvider;
     this.dataService               = dataService;
     this.operationWrapperCache     = new Dictionary <string, OperationWrapper>(EqualityComparer <string> .Default);
     this.metadataProviderEdmModels = new Dictionary <DataServiceOperationContext, MetadataProviderEdmModel>(EqualityComparer <DataServiceOperationContext> .Default);
     this.models                  = new Dictionary <DataServiceOperationContext, IEdmModel>(EqualityComparer <DataServiceOperationContext> .Default);
     this.edmSchemaVersion        = MetadataEdmSchemaVersion.Version1Dot0;
     this.containerNameCache      = null;
     this.containerNamespaceCache = null;
 }
Example #2
0
        public void StaticConfigurationCaching()
        {
            ReflectionBookStoreDataService service = new ReflectionBookStoreDataService();

            service.AttachHost(new DataServiceHostSimulator
            {
                AbsoluteServiceUri = new Uri("http://www.temp.org"),
                AbsoluteRequestUri = new Uri("http://www.temp.org/Authors"),
                RequestHttpMethod  = "GET",
                ResponseStream     = new MemoryStream()
            });

            service.ProcessRequest();

            DataServiceCacheItem cacheItem = MetadataCache <DataServiceCacheItem> .TryLookup(service.GetType(), new object());

            DataServiceStaticConfiguration oldStaticConfig = cacheItem.StaticConfiguration;

            service.AttachHost(new DataServiceHostSimulator
            {
                AbsoluteServiceUri = new Uri("http://www.temp.org"),
                AbsoluteRequestUri = new Uri("http://www.temp.org/Books"),
                RequestHttpMethod  = "GET",
                ResponseStream     = new MemoryStream()
            });

            service.ProcessRequest();

            cacheItem = MetadataCache <DataServiceCacheItem> .TryLookup(service.GetType(), new object());

            DataServiceStaticConfiguration newStaticConfig = cacheItem.StaticConfiguration;

            Assert.AreEqual(oldStaticConfig, newStaticConfig);

            ResourceSet rsBooks           = cacheItem.ResourceSetWrapperCache["Books"].ResourceSet;
            var         queryInterceptors = newStaticConfig.GetReadAuthorizationMethods(rsBooks);

            Assert.AreEqual(queryInterceptors.Count(), 1);

            ResourceSet rsAuthors          = cacheItem.ResourceSetWrapperCache["Authors"].ResourceSet;
            var         changeInterceptors = newStaticConfig.GetWriteAuthorizationMethods(rsAuthors);

            Assert.AreEqual(changeInterceptors.Count(), 1);
        }