/// <summary> /// Initializes a new <see cref="DataServiceConfiguration"/> with /// the specified <paramref name="provider"/>. /// </summary> /// <param name="provider">Non-null provider for this configuration.</param> internal DataServiceConfiguration(IDataServiceMetadataProvider provider) { WebUtil.CheckArgumentNull(provider, "provider"); this.provider = provider; this.resourceRights = new Dictionary <string, EntitySetRights>(EqualityComparer <string> .Default); this.serviceOperationRights = new Dictionary <string, ServiceOperationRights>(EqualityComparer <string> .Default); this.serviceActionRights = new Dictionary <string, ServiceActionRights>(EqualityComparer <string> .Default); this.pageSizes = new Dictionary <string, int>(EqualityComparer <string> .Default); this.rightsForUnspecifiedResourceContainer = EntitySetRights.None; this.rightsForUnspecifiedServiceOperation = ServiceOperationRights.None; this.rightsForUnspecifiedServiceAction = ServiceActionRights.None; this.knownTypes = new List <Type>(); this.maxBatchCount = Int32.MaxValue; this.maxChangeSetCount = Int32.MaxValue; this.maxExpandCount = Int32.MaxValue; this.maxExpandDepth = Int32.MaxValue; this.maxResultsPerCollection = Int32.MaxValue; this.maxObjectCountOnInsert = Int32.MaxValue; this.accessEnabledResourceTypes = new HashSet <string>(EqualityComparer <string> .Default); this.dataServiceBehavior = new DataServiceBehavior(); // default value is true since in V1, we always did the type conversion // and this configuration settings was introduced in V2 this.typeConversion = true; }
public void ConfigurationFileShouldSupercedeApiForReplace() { var testSubject = new DataServiceBehavior { AcceptReplaceFunctionInQuery = false }; DataServicesReplaceFunctionFeature replaceFeature = new TestReplaceFeature(true) { Enable = true }; DataServicesFeaturesSection dataServicesFeaturesSection = new DataServicesFeaturesSection { ReplaceFunction = replaceFeature }; testSubject.ApplySettingsFromConfiguration(dataServicesFeaturesSection); testSubject.AcceptReplaceFunctionInQuery.Should().BeTrue(); replaceFeature.Enable = false; testSubject.ApplySettingsFromConfiguration(dataServicesFeaturesSection); testSubject.AcceptReplaceFunctionInQuery.Should().BeFalse(); }
private static IEnumerable<IEdmVocabularyAnnotation> GetMetadataAnnotations(DataServiceBehavior dataServiceBehavior, out EdmEntityContainer container) { container = new EdmEntityContainer("Fake", "Container"); var primaryModel = new EdmModel(); primaryModel.AddElement(container); return UrlConvention.BuildMetadataAnnotations(dataServiceBehavior, primaryModel); }
/// <summary> /// Initializes a new <see cref="DataServiceConfiguration"/> with /// the specified <paramref name="provider"/>. /// </summary> /// <param name="provider">Non-null provider for this configuration.</param> internal DataServiceConfiguration(IDataServiceMetadataProvider provider) { WebUtil.CheckArgumentNull(provider, "provider"); this.provider = provider; this.resourceRights = new Dictionary<string, EntitySetRights>(EqualityComparer<string>.Default); this.serviceOperationRights = new Dictionary<string, ServiceOperationRights>(EqualityComparer<string>.Default); this.serviceActionRights = new Dictionary<string, ServiceActionRights>(EqualityComparer<string>.Default); this.pageSizes = new Dictionary<string, int>(EqualityComparer<string>.Default); this.rightsForUnspecifiedResourceContainer = EntitySetRights.None; this.rightsForUnspecifiedServiceOperation = ServiceOperationRights.None; this.rightsForUnspecifiedServiceAction = ServiceActionRights.None; this.knownTypes = new List<Type>(); this.maxBatchCount = Int32.MaxValue; this.maxChangeSetCount = Int32.MaxValue; this.maxExpandCount = Int32.MaxValue; this.maxExpandDepth = Int32.MaxValue; this.maxResultsPerCollection = Int32.MaxValue; this.maxObjectCountOnInsert = Int32.MaxValue; this.accessEnabledResourceTypes = new HashSet<string>(EqualityComparer<string>.Default); this.dataServiceBehavior = new DataServiceBehavior(); // default value is true since in V1, we always did the type conversion // and this configuration settings was introduced in V2 this.typeConversion = true; }
public void ConfigurationFileShouldForReplaceShouldOnlyBeAppliedIfPresent() { var testSubject = new DataServiceBehavior { AcceptReplaceFunctionInQuery = true }; testSubject.ApplySettingsFromConfiguration(new DataServicesFeaturesSection { ReplaceFunction = new TestReplaceFeature(false) { Enable = false } }); testSubject.AcceptReplaceFunctionInQuery.Should().BeTrue(); }