public OperationLinkBuilderTests()
        {
            ResourceType intType = ResourceType.GetPrimitiveResourceType(typeof(int));

            var customerType = new ResourceType(typeof(object), ResourceTypeKind.EntityType, null, "FQ.NS", "Customer", false);
            customerType.CanReflectOnInstanceType = false;
            customerType.AddProperty(new ResourceProperty("Id", ResourcePropertyKind.Primitive | ResourcePropertyKind.Key, intType) { CanReflectOnInstanceTypeProperty = false });
            customerType.SetReadOnly();

            var operation = new ServiceAction("Action", intType, OperationParameterBindingKind.Sometimes, new[] { new ServiceActionParameter("P1", customerType), new ServiceActionParameter("P2", intType) }, null);
            operation.SetReadOnly();
            this.operationWithParameters = new OperationWrapper(operation);

            var typeWithEscapedName = new ResourceType(typeof(object), ResourceTypeKind.ComplexType, null, "FQ NS", "+ /", false);
            typeWithEscapedName.CanReflectOnInstanceType = false;
            typeWithEscapedName.AddProperty(new ResourceProperty("Number", ResourcePropertyKind.Primitive, intType) { CanReflectOnInstanceTypeProperty = false });
            typeWithEscapedName.SetReadOnly();

            operation = new ServiceAction("Action", intType, OperationParameterBindingKind.Sometimes, new[] { new ServiceActionParameter("P1", customerType), new ServiceActionParameter("P2", typeWithEscapedName) }, null);
            operation.SetReadOnly();
            this.operationWithEscapedParameter = new OperationWrapper(operation);

            var bestCustomerType = new ResourceType(typeof(object), ResourceTypeKind.EntityType, customerType, "FQ.NS", "BestCustomer", false);
            bestCustomerType.SetReadOnly();

            operation = new ServiceAction("Action", intType, OperationParameterBindingKind.Sometimes, new[] { new ServiceActionParameter("P1", customerType) }, null);
            operation.SetReadOnly();
            this.operationBoundToBaseType = new OperationWrapper(operation);

            this.entityToSerialize = EntityToSerialize.CreateFromExplicitValues(new object(), bestCustomerType, new TestSerializedEntityKey("http://odata.org/Service.svc/Customers/", bestCustomerType.FullName));

            var metadataUri = new Uri("http://odata.org/Service.svc/$metadata");
            this.testSubject = new OperationLinkBuilder("MyContainer", metadataUri);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OperationSerializer"/> class.
        /// </summary>
        /// <param name="payloadMetadataParameterInterpreter">The metadata query option interpreter </param>
        /// <param name="metadataPropertyManager">The metadata property manager.</param>
        /// <param name="advertiseServiceAction">The callback to use for determining whether an action should be advertised. Should wrap a call to IDataServiceActionProvider.AdvertiseServiceAction.</param>
        /// <param name="namespaceName">Namespace of the operation.</param>
        /// <param name="format">The current format being serialized into.</param>
        /// <param name="metadataUri">The metadata uri of the service.</param>
        internal OperationSerializer(
            PayloadMetadataParameterInterpreter payloadMetadataParameterInterpreter,
            PayloadMetadataPropertyManager metadataPropertyManager,
            AdvertiseServiceActionCallback advertiseServiceAction,
            string namespaceName,
            ODataFormat format,
            Uri metadataUri)
        {
            Debug.Assert(metadataPropertyManager != null, "metadataPropertyManager != null");
            Debug.Assert(payloadMetadataParameterInterpreter != null, "payloadMetadataParameterInterpreter != null");
            Debug.Assert(advertiseServiceAction != null, "advertiseServiceAction != null");

            this.payloadMetadataParameterInterpreter = payloadMetadataParameterInterpreter;
            this.metadataPropertyManager             = metadataPropertyManager;

            this.operationLinkBuilder = new OperationLinkBuilder(namespaceName, metadataUri);
            this.format      = format;
            this.metadataUri = metadataUri;

            this.advertiseServiceAction = advertiseServiceAction;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OperationSerializer"/> class.
        /// </summary>
        /// <param name="payloadMetadataParameterInterpreter">The metadata query option interpreter </param>
        /// <param name="metadataPropertyManager">The metadata property manager.</param>
        /// <param name="advertiseServiceAction">The callback to use for determining whether an action should be advertised. Should wrap a call to IDataServiceActionProvider.AdvertiseServiceAction.</param>
        /// <param name="namespaceName">Namespace of the operation.</param>
        /// <param name="format">The current format being serialized into.</param>
        /// <param name="metadataUri">The metadata uri of the service.</param>
        internal OperationSerializer(
            PayloadMetadataParameterInterpreter payloadMetadataParameterInterpreter,
            PayloadMetadataPropertyManager metadataPropertyManager, 
            AdvertiseServiceActionCallback advertiseServiceAction, 
            string namespaceName, 
            ODataFormat format, 
            Uri metadataUri)
        {
            Debug.Assert(metadataPropertyManager != null, "metadataPropertyManager != null");
            Debug.Assert(payloadMetadataParameterInterpreter != null, "payloadMetadataParameterInterpreter != null");
            Debug.Assert(advertiseServiceAction != null, "advertiseServiceAction != null");

            this.payloadMetadataParameterInterpreter = payloadMetadataParameterInterpreter;
            this.metadataPropertyManager = metadataPropertyManager;

            this.operationLinkBuilder = new OperationLinkBuilder(namespaceName, metadataUri);
            this.format = format;
            this.metadataUri = metadataUri;
            
            this.advertiseServiceAction = advertiseServiceAction;
        }