Esempio n. 1
0
        /// <summary>Constructs the operation selector for runtime.</summary>
        /// <param name="endpoint">End point.</param>
        /// <param name="metadata">Domain data service metadata.</param>
        public DomainDataServiceOperationSelector(
            ServiceEndpoint endpoint,
            DomainDataServiceMetadata metadata)
            : base(DomainDataServiceOperationSelector.ExtractNonRootQueryServiceOperations(endpoint, metadata))
        {
            this.baseUri = endpoint.ListenUri;
            this.serviceRootQueryOperations = new Dictionary <string, string>();

            // Collect all the query operations, since they are to be handled by selector in this class.
            foreach (var od in endpoint.Contract.Operations)
            {
                string resourceSetName = DomainDataServiceOperationSelector.GetRootQueryOperation(od, metadata);
                if (!String.IsNullOrEmpty(resourceSetName))
                {
                    Debug.Assert(!this.serviceRootQueryOperations.ContainsKey(resourceSetName), "There should only be 1 default query operation per set.");

                    // Note the fact that requests on resourceSet correspond to the given operation.
                    this.serviceRootQueryOperations.Add(resourceSetName, od.Name);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Obtains the service operations available on the model and hands over all those
        /// operations to the base class for processing. The root query operations are
        /// handled by this class itself.
        /// </summary>
        /// <param name="endpoint">Endpoint on which operations are defined.</param>
        /// <param name="metadata">Metadata of the domain service.</param>
        /// <returns>Endpoint that contains all the operations that base class needs to process.</returns>
        private static ServiceEndpoint ExtractNonRootQueryServiceOperations(ServiceEndpoint endpoint, DomainDataServiceMetadata metadata)
        {
            ContractDescription cd = new ContractDescription(endpoint.Contract.Name);

            // Provide all the non-root query operations to the base class, only provide those operations that
            // have some representation on the domain data service.
            foreach (OperationDescription od in endpoint.Contract.Operations)
            {
                if (metadata.ServiceOperations.Keys.Contains(od.Name))
                {
                    Debug.Assert(
                        String.IsNullOrEmpty(DomainDataServiceOperationSelector.GetRootQueryOperation(od, metadata)),
                        "Service operation must not be a root query operation.");
                    cd.Operations.Add(od);
                }
            }

            return(new ServiceEndpoint(cd, endpoint.Binding, endpoint.Address)
            {
                ListenUri = endpoint.ListenUri
            });
        }