/// <summary>
        /// Gets the list of operations that are always bindable to a type.
        /// </summary>
        /// <param name="bindingType">The binding type in question.</param>
        /// <returns>The list of operations that are always bindable to a type.</returns>
        public IEnumerable <IEdmOperation> GetBindableOperationsForType(IEdmType bindingType)
        {
            Debug.Assert(bindingType != null, "bindingType != null");
            Debug.Assert(this.isResponse, "this.readingResponse");

            return(MetadataUtils.CalculateBindableOperationsForType(bindingType, this.model, this.edmTypeResolver));
        }
Beispiel #2
0
        public void CalculateBindableOperationsForDerivedEntityTypeWithTypeResolver()
        {
            var bindingType        = this.model.FindType("TestModel.TVMovie");
            var bindableOperations = MetadataUtils.CalculateBindableOperationsForType(bindingType, this.model, new EdmTypeReaderResolver(this.model, this.NameToTypeResolver));

            Assert.Equal(2, bindableOperations.Count());
            Assert.True(bindableOperations.Count(o => o.Name == "Rate") == 1);
            Assert.True(bindableOperations.Count(o => o.Name == "ChangeChannel") == 1);
        }
Beispiel #3
0
        public void CalculateBindableOperationsForDerivedEntityTypeWithTypeResolver()
        {
            var bindingType        = this.model.FindType("TestModel.TVMovie");
            var bindableOperations = MetadataUtils.CalculateBindableOperationsForType(bindingType, this.model, new EdmTypeReaderResolver(this.model, ODataReaderBehavior.CreateWcfDataServicesClientBehavior(this.NameToTypeResolver)));

            Assert.AreEqual(2, bindableOperations.Length);
            Assert.IsTrue(bindableOperations.Count(o => o.Name == "Rate") == 1);
            Assert.IsTrue(bindableOperations.Count(o => o.Name == "ChangeChannel") == 1);
        }
Beispiel #4
0
        public void CalculateBindableOperationsForEntityCollectionTypeWithTypeResolver()
        {
            var bindingType        = new EdmCollectionType(this.model.FindType("TestModel.Movie").ToTypeReference(nullable: false));
            var bindableOperations = MetadataUtils.CalculateBindableOperationsForType(bindingType, this.model, new EdmTypeReaderResolver(this.model, this.NameToTypeResolver));

            Assert.Equal(2, bindableOperations.Count());
            foreach (var operation in bindableOperations)
            {
                Assert.Equal("RateMultiple", operation.Name);
            }
        }
Beispiel #5
0
        public void CalculateBindableOperationsForEntityTypeWithTypeResolver()
        {
            var bindingType        = this.model.FindType("TestModel.Movie");
            var bindableOperations = MetadataUtils.CalculateBindableOperationsForType(bindingType, this.model, new EdmTypeReaderResolver(this.model, this.NameToTypeResolver));

            Assert.Single(bindableOperations);
            foreach (var operation in bindableOperations)
            {
                Assert.Equal("Rate", operation.Name);
            }
        }
        public void CalculateBindableOperationsForEntityTypeWithTypeResolver()
        {
            var bindingType        = this.model.FindType("TestModel.Movie");
            var bindableOperations = MetadataUtils.CalculateBindableOperationsForType(bindingType, this.model, new EdmTypeReaderResolver(this.model, ODataReaderBehavior.CreateWcfDataServicesClientBehavior(this.NameToTypeResolver)));

            Assert.Equal(1, bindableOperations.Length);
            foreach (var operation in bindableOperations)
            {
                Assert.Equal("Rate", operation.Name);
            }
        }
Beispiel #7
0
        public void CalculateBindableOperationsForEntityCollectionTypeWithTypeResolver()
        {
            var bindingType        = new EdmCollectionType(this.model.FindType("TestModel.Movie").ToTypeReference(nullable: false));
            var bindableOperations = MetadataUtils.CalculateBindableOperationsForType(bindingType, this.model, new EdmTypeReaderResolver(this.model, ODataReaderBehavior.CreateWcfDataServicesClientBehavior(this.NameToTypeResolver)));

            Assert.AreEqual(2, bindableOperations.Length);
            foreach (var operation in bindableOperations)
            {
                Assert.AreEqual("RateMultiple", operation.Name);
            }
        }
Beispiel #8
0
        /// <summary>
        /// Gets the list of operations that are always bindable to a type.
        /// </summary>
        /// <param name="bindingType">The binding type in question.</param>
        /// <returns>The list of operations that are always bindable to a type.</returns>
        public IEdmOperation[] GetBindableOperationsForType(IEdmType bindingType)
        {
            Debug.Assert(bindingType != null, "bindingType != null");
            Debug.Assert(this.bindableOperationsCache != null, "this.bindableOperationsCache != null");
            Debug.Assert(this.isResponse, "this.readingResponse");

            IEdmOperation[] bindableOperations;
            if (!this.bindableOperationsCache.TryGetValue(bindingType, out bindableOperations))
            {
                bindableOperations = MetadataUtils.CalculateBindableOperationsForType(bindingType, this.model, this.edmTypeResolver);
                this.bindableOperationsCache.Add(bindingType, bindableOperations);
            }

            return(bindableOperations);
        }