public static void InitializeService(DataServiceConfiguration config)
        {
            config.UseVerboseErrors = true;
            config.DataServiceBehavior.AcceptSpatialLiteralsInQuery = false;
            config.DataServiceBehavior.MaxProtocolVersion           = Microsoft.OData.Client.ODataProtocolVersion.V4;
            config.SetEntitySetAccessRule("*", Microsoft.OData.Service.EntitySetRights.All);
            config.SetServiceActionAccessRule("RetrieveProduct", Microsoft.OData.Service.ServiceActionRights.Invoke);
            config.SetServiceActionAccessRule("IncreaseSalaries", Microsoft.OData.Service.ServiceActionRights.Invoke);
            config.SetServiceActionAccessRule("UpdatePersonInfo", Microsoft.OData.Service.ServiceActionRights.Invoke);
            config.SetServiceActionAccessRule("IncreaseEmployeeSalary", Microsoft.OData.Service.ServiceActionRights.Invoke);

            config.SetServiceOperationAccessRule("*", Microsoft.OData.Service.ServiceOperationRights.All);
        }
Ejemplo n.º 2
0
 public static void InitializeService(DataServiceConfiguration config)
 {
     config.SetEntitySetAccessRule("*", EntitySetRights.All);
     config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
     config.SetServiceActionAccessRule("*", ServiceActionRights.Invoke);
     config.UseVerboseErrors = true;
     config.DataServiceBehavior.MaxProtocolVersion = ODataProtocolVersion.V4;
 }
 // This method is called only once to initialize service-wide policies.
 public static void InitializeService(DataServiceConfiguration config)
 {
     // TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
     // Examples:
     config.SetEntitySetAccessRule("*", EntitySetRights.All);
     config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
     config.SetServiceActionAccessRule("*", ServiceActionRights.Invoke);
     config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
 }
Ejemplo n.º 4
0
 public static void InitializeService(DataServiceConfiguration config)
 {
     config.UseVerboseErrors = true;
     config.DataServiceBehavior.AcceptSpatialLiteralsInQuery = false;
     config.DataServiceBehavior.MaxProtocolVersion           = Microsoft.OData.Client.ODataProtocolVersion.V4;
     config.SetEntitySetAccessRule("*", Microsoft.OData.Service.EntitySetRights.All);
     config.SetServiceActionAccessRule("*", Microsoft.OData.Service.ServiceActionRights.Invoke);
     config.SetServiceOperationAccessRule("*", Microsoft.OData.Service.ServiceOperationRights.All);
     SpatialImplementation.CurrentImplementation.Operations = new Microsoft.Test.OData.Framework.TestProviders.Common.PseudoDistanceImplementation();
     config.EnableTypeAccess("*");
 }
            public static void InitializeService(DataServiceConfiguration config)
            {
                config.SetEntitySetAccessRule("*", EntitySetRights.All);
                config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
                config.SetServiceActionAccessRule("*", ServiceActionRights.Invoke);
                config.UseVerboseErrors = true;

                config.DataServiceBehavior.UrlConventions = DataServiceUrlConventions.KeyAsSegment;

                config.DataServiceBehavior.MaxProtocolVersion = ODataProtocolVersion.V4;
                config.DataServiceBehavior.IncludeAssociationLinksInResponse = true;
            }
Ejemplo n.º 6
0
        public static void InitializeService(DataServiceConfiguration config)
        {
            config.UseVerboseErrors = true;
            config.DataServiceBehavior.AcceptSpatialLiteralsInQuery = false;
            config.DataServiceBehavior.MaxProtocolVersion           = Microsoft.OData.Client.ODataProtocolVersion.V4;
            config.SetEntitySetAccessRule("*", Microsoft.OData.Service.EntitySetRights.All);
            config.SetServiceActionAccessRule("*", Microsoft.OData.Service.ServiceActionRights.Invoke);
            config.SetServiceOperationAccessRule("*", Microsoft.OData.Service.ServiceOperationRights.All);

            config.SetEntitySetPageSize("Customer", 2);
            config.SetEntitySetPageSize("Order", 2);

            config.RegisterKnownType(typeof(ComplexWithAllPrimitiveTypes));
            config.EnableTypeAccess("*");
        }
Ejemplo n.º 7
0
        public static void InitializeService(DataServiceConfiguration configuration)
        {
            configuration.SetEntitySetAccessRule("*", EntitySetRights.All);
            configuration.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
            configuration.SetServiceActionAccessRule("*", ServiceActionRights.Invoke);

            configuration.UseVerboseErrors = true;

            if (SimpleDataServiceHelper.PageSizeCustomizer != null)
            {
                SimpleDataServiceHelper.PageSizeCustomizer(configuration as DataServiceConfiguration);
            }

            configuration.DataServiceBehavior.MaxProtocolVersion = MaxProtocolVersion;
        }
 public static void InitializeService(DataServiceConfiguration config)
 {
     config.SetEntitySetAccessRule("*", EntitySetRights.All);
     config.DataServiceBehavior.AcceptAnyAllRequests = true;
     config.UseVerboseErrors = true;
     config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
     config.SetServiceActionAccessRule("*", ServiceActionRights.Invoke);
     config.DataServiceBehavior.MaxProtocolVersion       = DataServiceProtocolVersion.V3;
     config.DataServiceBehavior.AcceptProjectionRequests = true;
     config.DataServiceBehavior.AcceptCountRequests      = true;
     config.AnnotationsBuilder = CreateAnnotationsBuilder(() => context);
     config.DataServiceBehavior.AcceptReplaceFunctionInQuery = true;
     config.DataServiceBehavior.AcceptSpatialLiteralsInQuery = true;
     config.DisableValidationOnMetadataWrite = true;
 }
        public static void InitializeService(DataServiceConfiguration config)
        {
            config.UseVerboseErrors = true;
            config.DataServiceBehavior.AcceptSpatialLiteralsInQuery = false;
            config.DataServiceBehavior.MaxProtocolVersion           = System.Data.Services.Common.DataServiceProtocolVersion.V3;
            config.SetEntitySetAccessRule("*", System.Data.Services.EntitySetRights.All);
            config.SetEntitySetAccessRule("MappedEntityType", EntitySetRights.None);
            config.SetEntitySetAccessRule("Message", EntitySetRights.AllRead);

            config.SetServiceActionAccessRule("*", System.Data.Services.ServiceActionRights.Invoke);
            config.SetServiceOperationAccessRule("*", System.Data.Services.ServiceOperationRights.All);

            config.SetEntitySetPageSize("Customer", 2);
            config.SetEntitySetPageSize("Order", 2);

            config.RegisterKnownType(typeof(ComplexWithAllPrimitiveTypes));
            config.EnableTypeAccess("*");
        }
        private static MetadataProviderEdmModel CreateMetadataProviderEdmModel(DataServiceProviderSimulator metadataProvider, IDataServiceActionProvider actionProvider = null)
        {
            var dataServiceSimulator = new DataServiceSimulatorWithGetService {
                OperationContext = new DataServiceOperationContext(false, new DataServiceHost2Simulator()), ProcessingPipeline = new DataServiceProcessingPipeline()
            };

            dataServiceSimulator.OperationContext.InitializeAndCacheHeaders(dataServiceSimulator);

            var dataServiceConfiguration = new DataServiceConfiguration(metadataProvider);

            dataServiceConfiguration.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
            dataServiceConfiguration.SetServiceActionAccessRule("*", ServiceActionRights.Invoke);
            dataServiceConfiguration.DataServiceBehavior.MaxProtocolVersion = ODataProtocolVersion.V4;

            if (actionProvider != null)
            {
                dataServiceSimulator.Providers.Add(typeof(IDataServiceActionProvider), actionProvider);
            }

            DataServiceStaticConfiguration staticConfiguration = new DataServiceStaticConfiguration(dataServiceSimulator.Instance.GetType(), metadataProvider);
            IDataServiceProviderBehavior   providerBehavior    = DataServiceProviderBehavior.CustomDataServiceProviderBehavior;

            DataServiceProviderWrapper providerWrapper = new DataServiceProviderWrapper(
                new DataServiceCacheItem(
                    dataServiceConfiguration,
                    staticConfiguration),
                metadataProvider,
                metadataProvider,
                dataServiceSimulator,
                false);

            dataServiceSimulator.Provider = providerWrapper;

            var model = new MetadataProviderEdmModel(providerWrapper, new DataServiceStreamProviderWrapper(dataServiceSimulator), DataServiceActionProviderWrapper.Create(dataServiceSimulator));

            model.MetadataProvider.ProviderBehavior = providerBehavior;
            return(model);
        }
Ejemplo n.º 11
0
        public static void InitializeService(DataServiceConfiguration configuration)
        {
            if (OpenWebDataServiceHelper.EntitySetAccessRule.Value != null)
            {
                foreach (var rule in OpenWebDataServiceHelper.EntitySetAccessRule.Value)
                {
                    configuration.SetEntitySetAccessRule(rule.Key, rule.Value);
                }
            }
            else
            {
                configuration.SetEntitySetAccessRule("*", EntitySetRights.All);
            }

            if (OpenWebDataServiceHelper.ServiceOperationAccessRule.Value != null)
            {
                foreach (var rule in OpenWebDataServiceHelper.ServiceOperationAccessRule.Value)
                {
                    configuration.SetServiceOperationAccessRule(rule.Key, rule.Value);
                }
            }
            else
            {
                configuration.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
            }

            if (OpenWebDataServiceHelper.ServiceActionAccessRule.Value != null)
            {
                foreach (var rule in OpenWebDataServiceHelper.ServiceActionAccessRule.Value)
                {
                    configuration.SetServiceActionAccessRule(rule.Key, rule.Value);
                }
            }
            else
            {
                configuration.SetServiceActionAccessRule("*", ServiceActionRights.Invoke);
            }

            if (OpenWebDataServiceHelper.EnableAccess.Value != null)
            {
                foreach (string type in OpenWebDataServiceHelper.EnableAccess.Value)
                {
                    ((DataServiceConfiguration)configuration).EnableTypeAccess(type);
                }
            }

            configuration.DisableValidationOnMetadataWrite = OpenWebDataServiceHelper.DisableValidationOnMetadataWrite;
            configuration.UseVerboseErrors     = OpenWebDataServiceHelper.ForceVerboseErrors;
            configuration.EnableTypeConversion = OpenWebDataServiceHelper.EnableTypeConversion;

            if (OpenWebDataServiceHelper.MaxBatchCount.Value.HasValue)
            {
                configuration.MaxBatchCount = OpenWebDataServiceHelper.MaxBatchCount.Value.Value;
            }
            if (OpenWebDataServiceHelper.MaxChangeSetCount.Value.HasValue)
            {
                configuration.MaxChangesetCount = OpenWebDataServiceHelper.MaxChangeSetCount.Value.Value;
            }
            if (OpenWebDataServiceHelper.MaxObjectCountOnInsert.Value.HasValue)
            {
                configuration.MaxObjectCountOnInsert = OpenWebDataServiceHelper.MaxObjectCountOnInsert.Value.Value;
            }
            if (OpenWebDataServiceHelper.MaxResultsPerCollection.Value.HasValue)
            {
                configuration.MaxResultsPerCollection = OpenWebDataServiceHelper.MaxResultsPerCollection.Value.Value;
            }
            if (OpenWebDataServiceHelper.MaxExpandDepth.Value.HasValue)
            {
                configuration.MaxExpandDepth = OpenWebDataServiceHelper.MaxExpandDepth.Value.Value;
            }

            if (OpenWebDataServiceHelper.PageSizeCustomizer.Value != null)
            {
                OpenWebDataServiceHelper.PageSizeCustomizer.Value(configuration, typeof(T));
            }

            configuration.DataServiceBehavior.MaxProtocolVersion = OpenWebDataServiceHelper.MaxProtocolVersion;
            configuration.DataServiceBehavior.IncludeAssociationLinksInResponse = OpenWebDataServiceHelper.IncludeRelationshipLinksInResponse;
            configuration.DataServiceBehavior.AcceptCountRequests                    = OpenWebDataServiceHelper.AcceptCountRequests;
            configuration.DataServiceBehavior.AcceptAnyAllRequests                   = OpenWebDataServiceHelper.AcceptAnyAllRequests;
            configuration.DataServiceBehavior.AcceptProjectionRequests               = OpenWebDataServiceHelper.AcceptProjectionRequests;
            configuration.DataServiceBehavior.InvokeInterceptorsOnLinkDelete         = OpenWebDataServiceHelper.InvokeInterceptorsOnLinkDelete;
            configuration.DataServiceBehavior.UseMetadataKeyOrderForBuiltInProviders = OpenWebDataServiceHelper.UseMetadataKeyOrderForBuiltInProviders;
            configuration.DataServiceBehavior.AcceptSpatialLiteralsInQuery           = OpenWebDataServiceHelper.AcceptSpatialLiteralsInQuery;
            configuration.DataServiceBehavior.AcceptReplaceFunctionInQuery           = OpenWebDataServiceHelper.AcceptReplaceFunctionInQuery;

            configuration.DataServiceBehavior.UrlConventions = OpenWebDataServiceHelper.GenerateKeyAsSegment ? DataServiceUrlConventions.KeyAsSegment : DataServiceUrlConventions.Default;

            //configuration.UseV4ExpandSyntax = false;

            // Invoke InitializeService on the context type
            MethodInfo methodInfo = typeof(T).GetMethod("InitializeService", BindingFlags.Static | BindingFlags.Public | BindingFlags.DeclaredOnly);

            if (methodInfo != null && methodInfo.ReturnType == typeof(void))
            {
                methodInfo.Invoke(null, new object[] { configuration });
            }
        }
Ejemplo n.º 12
0
 public static void InitializeService(DataServiceConfiguration config)
 {
     config.SetEntitySetAccessRule("*", EntitySetRights.All);
     config.SetServiceActionAccessRule("*", ServiceActionRights.Invoke);
     config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
 }
Ejemplo n.º 13
0
        /// <summary>
        /// TODO: Refactor this into a factory pattern, if needed
        /// </summary>
        /// <returns>IDataService</returns>
        public IDataService CreateService <T>() where T : DataServiceSimulator, new()
        {
            T dataService = new T();

            //
            // Operation Context
            //
            DataServiceOperationContext operationContext = new DataServiceOperationContext(host);

            operationContext.InitializeAndCacheHeaders(dataService);

            //
            // Configuration
            //
            DataServiceConfiguration config = new DataServiceConfiguration(provider);

            config.SetEntitySetAccessRule("*", EntitySetRights.All);
            config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
            config.SetServiceActionAccessRule("*", ServiceActionRights.Invoke);
            config.DataServiceBehavior.AcceptAnyAllRequests              = this.behavior.AcceptAnyAllRequests;
            config.DataServiceBehavior.AcceptCountRequests               = this.behavior.AcceptCountRequests;
            config.DataServiceBehavior.AcceptProjectionRequests          = this.behavior.AcceptProjectionRequests;
            config.DataServiceBehavior.AcceptSpatialLiteralsInQuery      = this.behavior.AcceptSpatialLiteralsInQuery;
            config.DataServiceBehavior.IncludeAssociationLinksInResponse = this.behavior.IncludeAssociationLinksInResponse;
            config.DataServiceBehavior.InvokeInterceptorsOnLinkDelete    = this.behavior.InvokeInterceptorsOnLinkDelete;
            config.DataServiceBehavior.MaxProtocolVersion = this.behavior.MaxProtocolVersion;
            config.DataServiceBehavior.UseMetadataKeyOrderForBuiltInProviders = this.behavior.UseMetadataKeyOrderForBuiltInProviders;

            DataServiceStaticConfiguration staticConfiguration = new DataServiceStaticConfiguration(dataService.Instance.GetType(), provider);
            IDataServiceProviderBehavior   providerBehavior    = DataServiceProviderBehavior.CustomDataServiceProviderBehavior;

            var providerWrapper = new DataServiceProviderWrapper(
                new DataServiceCacheItem(
                    config,
                    staticConfiguration),
                provider,
                provider,
                dataService,
                false);

            dataService.ProcessingPipeline   = new DataServiceProcessingPipeline();
            dataService.Provider             = providerWrapper;
            providerWrapper.ProviderBehavior = providerBehavior;

            //
            // Service
            //
            operationContext.RequestMessage.InitializeRequestVersionHeaders(config.DataServiceBehavior.MaxProtocolVersion.ToVersion());
            var pipeline = new DataServiceProcessingPipeline();

#if DEBUG
            pipeline.SkipDebugAssert = true;
#endif
            dataService.OperationContext   = operationContext;
            dataService.Provider           = providerWrapper;
            dataService.ProcessingPipeline = pipeline;
            dataService.Configuration      = config;
            dataService.StreamProvider     = new DataServiceStreamProviderWrapper(dataService);
            dataService.ActionProvider     = DataServiceActionProviderWrapper.Create(dataService);
            return(dataService);
        }