Exemplo n.º 1
0
        void Initialize()
        {
            Subscriptions = new Dictionary <string, List <string> >();

            foreach (Uri baseAddress in BaseAddresses)
            {
                if (baseAddress.Scheme != "sb")
                {
                    throw new InvalidOperationException("Can only use 'sb' for base address scheme");
                }

                Type[] contracts = ServiceBusHelper.GetServiceContracts(Description.ServiceType);
                foreach (Type contract in contracts)
                {
                    AddServiceEndpoint(contract, RelayBinding, baseAddress.AbsoluteUri + contract + "/");
                    Subscriptions[contract.Name] = new List <string>();
                }
            }

            IEndpointBehavior selector = new EventSelector(Subscriptions);

            foreach (ServiceEndpoint endpoint in Description.Endpoints)
            {
                endpoint.Behaviors.Add(selector);
            }
        }
Exemplo n.º 2
0
 public void Subscribe()
 {
     Type[] contracts = ServiceBusHelper.GetServiceContracts(Description.ServiceType);
     lock (Subscriptions)
     {
         foreach (Type contract in contracts)
         {
             Subscribe(contract);
         }
     }
 }
Exemplo n.º 3
0
        static void VerifyTypeOperation(Type serviceType, Type contractType, string operation)
        {
            if (String.IsNullOrEmpty(operation) || String.IsNullOrWhiteSpace(operation))
            {
                throw new InvalidOperationException("Operation: " + operation + " cannot be null or empty");
            }

            Type[] contracts = ServiceBusHelper.GetServiceContracts(serviceType);
            if (contracts.Contains(contractType) == false)
            {
                throw new InvalidOperationException("Service type: " + serviceType.FullName + " does not support contrat: " + contractType.FullName);
            }

            if (GetOperations(contractType).Contains(operation) == false)
            {
                throw new InvalidOperationException("Contract type: " + contractType.FullName + " does not support operation: " + operation);
            }
        }