public static void InitializeService(IDataServiceConfiguration config) { GetProvider().InitializeService <TDataContext>(config); config.SetServiceOperationAccessRule("AttachFilesToEntity", ServiceOperationRights.All); config.SetServiceOperationAccessRule("DeleteEntity", ServiceOperationRights.All); config.SetServiceOperationAccessRule("GetEntityUrl", ServiceOperationRights.ReadSingle); config.SetServiceOperationAccessRule("GetSiteMapChildren", ServiceOperationRights.AllRead); }
// 本方法只被调用一次来初始化服务的全局规则。 public static void InitializeService(IDataServiceConfiguration config) { // 设定规则,表明那些实体集合和服务操作是可见的,可以更新的,等等。 config.UseVerboseErrors = true; config.SetEntitySetAccessRule("*", EntitySetRights.All); config.SetServiceOperationAccessRule("CoursesByPersonID", ServiceOperationRights.All); config.SetServiceOperationAccessRule("GetPersonUpdateException", ServiceOperationRights.All); }
// This method is called only once to initialize service-wide policies. public static void InitializeService(IDataServiceConfiguration config) { // Set rules to indicate which entity sets and service operations // are visible, updatable, etc. config.UseVerboseErrors = true; config.SetEntitySetAccessRule("*", EntitySetRights.All); config.SetServiceOperationAccessRule("CoursesByPersonID", ServiceOperationRights.All); config.SetServiceOperationAccessRule("GetPersonUpdateException", ServiceOperationRights.All); }
public static void InitializeService(IDataServiceConfiguration config) { #if DEBUG config.UseVerboseErrors = true; #endif config.SetEntitySetAccessRule("*", EntitySetRights.All); config.SetServiceOperationAccessRule("*", ServiceOperationRights.AllRead); }
public static void InitializeService(IDataServiceConfiguration config) { //entities config.SetEntitySetAccessRule("Pictures", EntitySetRights.All); config.SetEntitySetAccessRule("Tags", EntitySetRights.WriteAppend | EntitySetRights.AllRead); config.UseVerboseErrors = true; //operations config.SetServiceOperationAccessRule("*", ServiceOperationRights.ReadSingle); }
public static void InitializeService(IDataServiceConfiguration config) { config.UseVerboseErrors = true; config.SetEntitySetAccessRule("Movies", EntitySetRights.AllRead); config.SetEntitySetAccessRule("Reviews", EntitySetRights.All); config.MaxResultsPerCollection = 20; config.SetServiceOperationAccessRule("GetTopTenMovies", ServiceOperationRights.All); }
// This method is called only once to initialize service-wide policies. public static void InitializeService(IDataServiceConfiguration config) { config.SetEntitySetAccessRule("Customers", EntitySetRights.AllRead); config.SetServiceOperationAccessRule("CustomerNames", ServiceOperationRights.AllRead); }
public static void InitializeService(IDataServiceConfiguration config) { config.SetEntitySetAccessRule("*", EntitySetRights.All); config.SetServiceOperationAccessRule("*", ServiceOperationRights.All); }
internal static void RegisterServices(IDataServiceConfiguration config) { config.SetServiceOperationAccessRule("Search", ServiceOperationRights.AllRead); config.SetServiceOperationAccessRule("FindPackagesById", ServiceOperationRights.AllRead); config.SetServiceOperationAccessRule("GetUpdates", ServiceOperationRights.AllRead); }
/// <summary>Initializes the service configuration.</summary> public static void InitializeService(IDataServiceConfiguration configuration) { APICallLog.Current.DataService.InitializeService("TestDataWebService"); //Because the configuration settings can be deliberately messed up on the server-side before calling ClearAll() , //we need this to be the first step in the InitializeService ClearAllIfRequired(); try { foreach (string setting in configurationSettings.PropertySetList) { if (setting == "UseVerboseErrors") { configuration.UseVerboseErrors = configurationSettings.UseVerboseErrors; } else if (setting == "MaxBatchCount") { configuration.MaxBatchCount = configurationSettings.MaxBatchCount; } else if (setting == "MaxChangesetCount") { configuration.MaxChangesetCount = configurationSettings.MaxChangesetCount; } else if (setting == "MaxExpandCount") { configuration.MaxExpandCount = configurationSettings.MaxExpandCount; } else if (setting == "MaxExpandDepth") { configuration.MaxExpandDepth = configurationSettings.MaxExpandDepth; } else if (setting == "MaxObjectCountOnInsert") { configuration.MaxObjectCountOnInsert = configurationSettings.MaxObjectCountOnInsert; } else if (setting == "MaxResultsPerCollection") { configuration.MaxResultsPerCollection = configurationSettings.MaxResultsPerCollection; } } foreach (string entity in configurationSettings.EntitySetAccessRules.Keys) { configuration.SetEntitySetAccessRule(entity, configurationSettings.EntitySetAccessRules[entity]); } foreach (string entity in configurationSettings.ServiceOperationAccessRules.Keys) { configuration.SetServiceOperationAccessRule(entity, configurationSettings.ServiceOperationAccessRules[entity]); } MethodInfo mi = configuration.GetType().GetMethod("SetEntitySetPageSize", BindingFlags.Instance | BindingFlags.Public); if (mi != null) { foreach (string entity in configurationSettings.EntitySetPageSizes.Keys) { mi.Invoke(configuration, new object[] { entity, configurationSettings.EntitySetPageSizes[entity] }); } } foreach (string type in configurationSettings.KnownTypesToRegister) { Type t = Type.GetType(type); if (t == null) { t = typeof(TestDataWebService <>).Assembly.GetType(type); } if (t == null) { throw new DataServiceException(500, "Could not resolve type with name '" + type + "'"); } configuration.RegisterKnownType(t); } MethodInfo enableTypeAccess = configuration.GetType().GetMethod("EnableTypeAccess", BindingFlags.Instance | BindingFlags.Public); if (enableTypeAccess != null) { // Note: the provider wrapper for IDSMP is strict about calls to TryResolveResourceType. // However, the DataServiceConfiguration.EnableTypeAccess method does not cache resolved types, // so we need to explicitly turn off the extra validation before calling it. bool oldValue = MetadataProviderWrapper.ValidateTypeResolution; try { MetadataProviderWrapper.ValidateTypeResolution = false; foreach (string typeName in configurationSettings.EnableAccessToTypes) { enableTypeAccess.Invoke(configuration, new object[] { typeName }); } } finally { // make sure to turn the validation back on, if it was on MetadataProviderWrapper.ValidateTypeResolution = oldValue; } } if (configuration.GetType().Name == "DataServiceConfiguration") { PropertyInfo dsb = configuration.GetType().GetProperty("DataServiceBehavior"); if (dsb != null) { object dataServiceBevhaior = dsb.GetValue(configuration, null); if (dataServiceBevhaior != null) { Type dataServiceBehaviorType = dataServiceBevhaior.GetType(); if (configurationSettings.PropertySetList.Contains("AllowCountRequests")) { PropertyInfo propertyInfo = dataServiceBehaviorType.GetProperty("AcceptCountRequests"); propertyInfo.SetValue(dataServiceBevhaior, configurationSettings.AllowCountRequests, null); } if (configurationSettings.PropertySetList.Contains("AllowProjectionRequests")) { PropertyInfo propertyInfo = dataServiceBehaviorType.GetProperty("AcceptProjectionRequests"); propertyInfo.SetValue(dataServiceBevhaior, configurationSettings.AllowProjectionRequests, null); } if (configurationSettings.PropertySetList.Contains("InvokeInterceptorsOnLinkDelete")) { PropertyInfo propertyInfo = dataServiceBehaviorType.GetProperty("InvokeInterceptorsOnLinkDelete"); propertyInfo.SetValue(dataServiceBevhaior, configurationSettings.InvokeInterceptorsOnLinkDelete, null); } if (configurationSettings.PropertySetList.Contains("MaxProtocolVersion") && configurationSettings.MaxProtocolVersion.HasValue) { PropertyInfo propertyInfo = dataServiceBehaviorType.GetProperty("MaxProtocolVersion"); propertyInfo.SetValue(dataServiceBevhaior, configurationSettings.MaxProtocolVersion, null); } } } // //object } } catch (Exception excpt) { if (!ClearAllIfRequired()) { throw new DataServiceException(excpt.ToString(), excpt); } } finally { APICallLog.Current.Pop(); } }
/// <summary>Initializes the service configuration.</summary> public static void InitializeService(IDataServiceConfiguration configuration) { configuration.SetEntitySetAccessRule("*", EntitySetRights.All); configuration.SetServiceOperationAccessRule("*", ServiceOperationRights.All); configuration.UseVerboseErrors = true; }