Beispiel #1
0
 public PipeCommunication()
     : base(new ServiceEndpoint(ContractDescription.GetContract(typeof(IPipeCommunication)),
                                new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/sdc/FoxSDC-Agent-Comm")))
 {
 }
 public void GetNonContract()
 {
     ContractDescription cd = ContractDescription.GetContract(
         typeof(object));
 }
 public void GetContract()
 {
     InternalTestGetContract(
         ContractDescription.GetContract(typeof(IFoo)));
 }
 public void WrongAsyncEndContract()
 {
     ContractDescription.GetContract(typeof(IWrongAsyncEndContract));
 }
 public void AsyncMethodNameDoesNotStartWithBegin()
 {
     ContractDescription.GetContract(typeof(IAsyncMethodNameDoesNotStartWithBegin));
 }
 public void GetContractInherit()
 {
     ContractDescription.GetContract(typeof(Foo));
 }
 // [ExpectedException (typeof (InvalidOperationException))]
 public void GetContractNoOperation()
 {
     ContractDescription.GetContract(typeof(INoOperation));
 }
 public CustomEndpoint(string address)
     : this(address, ContractDescription.GetContract(typeof(ICalculator)))
 {
 }
Beispiel #9
0
        protected override System.ServiceModel.Description.ServiceEndpoint CreateDescription()
        {
            ContractDescription desc = ContractDescription.GetContract(_channelType);

            return(new ServiceEndpoint(desc));
        }
 ///-------------------------------------------------------------------------------------------------
 /// <summary>
 ///  Creates end point.
 /// </summary>
 /// <returns>
 ///  The new end point.
 /// </returns>
 ///-------------------------------------------------------------------------------------------------
 protected virtual ServiceEndpoint CreateEndPoint()
 {
     return(new ServiceEndpoint(ContractDescription.GetContract(typeof(IWCFHyperstoreChannel)), DefaultBinding, new EndpointAddress(DefaultAddress)));
 }
Beispiel #11
0
 public ClientChannelManager(TelemetryClient client, Type contractType)
 {
     this.TelemetryClient = client;
     this.OperationMap    = new ClientContract(ContractDescription.GetContract(contractType));
     this.CloseTimeout    = this.OpenTimeout = this.ReceiveTimeout = this.SendTimeout = TimeSpan.FromSeconds(5);
 }
        private bool LoadBizProxy(string bindingName, string bindingConfigName, string address)
        {
            Binding         binding;
            Uri             uri;
            ServiceEndpoint serviceEndpoint;
            ChannelFactory <IServiceExtensions> channelFactory;

            //ChannelFactory<IServiceAsync> _ChannelFactoryAsync;

            try
            {
                if (this.listServicePool.Count == 0)
                {
                    //this.LoadBinding();

                    //this.LoadBinding(this.GetttributeInnerXml("system.serviceModel", 0));
                }

                switch (bindingName)
                {
                case "BasicHttpBinding":
                    if (bindingConfigName.IsNullOrEmpty())
                    {
                        binding = this.GetBasicHttpBinding();
                    }
                    else
                    {
                        binding = this.GetBasicHttpBinding(bindingConfigName);
                    }
                    break;

                case "BasicHttpsBinding":
                    if (bindingConfigName.IsNullOrEmpty())
                    {
                        binding = this.GetBasicHttpsBinding();
                    }
                    else
                    {
                        binding = this.GetBasicHttpsBinding(bindingConfigName);
                    }
                    break;

                case "CustomBinding":
                    if (bindingConfigName.IsNullOrEmpty())
                    {
                        binding = this.GetCustomBinding();
                    }
                    else
                    {
                        binding = this.GetCustomBinding(bindingConfigName);
                    }
                    break;

                //case "NetMsmqBinding":
                //    if (bindingConfigName.IsNullOrEmpty())
                //        binding = this.GetNetMsmqBinding();
                //    else
                //        binding = this.GetNetMsmqBinding(bindingConfigName);
                //    break;

                //case "NetNamedPipeBinding":
                //    if (bindingConfigName.IsNullOrEmpty())
                //        binding = this.GetNetNamedPipeBinding();
                //    else
                //        binding = this.GetNetNamedPipeBinding(bindingConfigName);
                //    break;

                //case "NetPeerTcpBinding":
                //    binding = new NetPeerTcpBinding(bindingConfigName);
                //    ((NetPeerTcpBinding)binding).MaxReceivedMessageSize = 2147483647;
                //    break;

                case "NetTcpBinding":
                    if (bindingConfigName.IsNullOrEmpty())
                    {
                        binding = this.GetNetTcpBinding();
                    }
                    else
                    {
                        binding = this.GetNetTcpBinding(bindingConfigName);
                    }
                    break;

                //case "WSDualHttpBinding":
                //    if (bindingConfigName.IsNullOrEmpty())
                //        binding = this.GetWSDualHttpBinding();
                //    else
                //        binding = this.GetWSDualHttpBinding(bindingConfigName);
                //    break;

                //case "WSHttpBinding":
                //    if (bindingConfigName.IsNullOrEmpty())
                //        binding = this.GetWSHttpBinding();
                //    else
                //        binding = this.GetWSHttpBinding(bindingConfigName);
                //    break;

                default:
                    binding = null;
                    break;
                }

                try
                {
                    string[] tmps = this.GetAttribute("Timeout").Split(',');

                    int hours   = tmps[0].ToInt();
                    int minute  = tmps[1].ToInt();
                    int seconds = tmps[2].ToInt();

                    binding.OpenTimeout    = new TimeSpan(hours, minute, seconds);
                    binding.CloseTimeout   = new TimeSpan(hours, minute, seconds);
                    binding.SendTimeout    = new TimeSpan(hours, minute, seconds);
                    binding.ReceiveTimeout = new TimeSpan(hours, minute, seconds);
                }
                catch (Exception ex)
                {
                    binding.OpenTimeout    = new TimeSpan(0, 10, 0);
                    binding.CloseTimeout   = new TimeSpan(0, 10, 0);
                    binding.SendTimeout    = new TimeSpan(0, 10, 0);
                    binding.ReceiveTimeout = new TimeSpan(0, 10, 0);

                    DiagnosticsTool.MyTrace(ex);
                }

                //_Binding.ReceiveTimeout = new TimeSpan(0, 10, 0);
                uri = new Uri(address);

                serviceEndpoint = new ServiceEndpoint(ContractDescription.GetContract(this.GetType()), binding, new EndpointAddress(uri));
                channelFactory  = new ChannelFactory <IServiceExtensions>(serviceEndpoint);

                this.listServicePool.Add(new ServiceExtensionsInfo()
                {
                    ServiceExtensions = channelFactory.CreateChannel(),
                    IsBusy            = false
                });

                return(true);
            }
            catch (AtomusException exception)
            {
                throw exception;
            }
            catch (Exception exception)
            {
                throw new AtomusException(exception);
            }
        }
Beispiel #13
0
        static void Main()
        {
            ServiceHost host = null;

            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Form1 form = new Form1();

                try
                {
                    string uriAddressString = null;

                    string ports        = ConfigurationManager.AppSettings["rangeOfPorts"];
                    int[]  rangeOfPorts = string.IsNullOrEmpty(ports) ?
                                          new int[] { 10100, 10101, 10102, 10103, 10104, 10105, 10106, 10107, 10108, 10109 } :
                    ports.Split(',').Select(n => Convert.ToInt32(n)).ToArray();

                    var usedPorts = IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpListeners();
                    for (int ii = 0; ii < rangeOfPorts.Length; ii++)
                    {
                        if (usedPorts.FirstOrDefault(p => p.Port == rangeOfPorts[ii]) == null)
                        {
                            uriAddressString = string.Format(@"http://localhost:{0}/sb", rangeOfPorts[ii]);
                            break;
                        }
                    }
                    ;

                    if (string.IsNullOrEmpty(uriAddressString))
                    {
                        throw new Exception("Not available port in the range 10100-10109");
                    }

                    // interprocess communications
                    var endpointAddress = new EndpointAddress("net.pipe://localhost/AzureIoTHubTester_" + Process.GetCurrentProcess().Id);
                    var binding         = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
                    var se = new ServiceEndpoint(ContractDescription.GetContract(typeof(IGenericOneWayContract)), binding, endpointAddress);

                    host = new ServiceHost(typeof(TesterService));
                    host.AddServiceEndpoint(se);

                    host.Extensions.Add(form);
                    host.Open();
                }
                catch (Exception ex)
                {
                    form.ShowText(ex.Message);
                }


                // form.Text = string.Format("[{0}] Axure IoT Hub Tester", (form.Tag as Uri).Port);
                Application.Run(form);
            }
            finally
            {
                if (host != null && host.State == CommunicationState.Faulted)
                {
                    host.Abort();
                }
                else if (host != null && host.State == CommunicationState.Opened)
                {
                    host.Close();
                }
            }
        }
Beispiel #14
0
        /// <summary>
        /// 启动指定地址服务
        /// </summary>
        /// <param name="servAddr">服务地址</param>
        /// <param name="restr">执行描述</param>
        /// <returns>执行标志</returns>
        public bool Start(Uri servAddr, EnumWCFProtocol protocol, ref string restr)
        {
            //承载和运行服务(MSDN第三步)
            //为服务配置基址
            //1.为服务的基址创建 Uri 实例。此 URI 指定 HTTP 方案、本地计算机、端口号 8000,以及服务协定中为服务命名空间指定的服务路径 ServiceModelSample/Service。
            //Uri baseAddress = new Uri("http://localhost:8000/ServiceModelSamples/Service");

            //承载服务
            //1.导入 System.ServiceModel.Description 命名空间。这行代码应该与 using 或 imports 语句的其余部分一起放置在 Program.cs/Program.vb 文件的顶部。
            //2.创建一个新的 ServiceHost 实例以承载服务。必须指定实现服务协定和基址的类型。对于此示例,基址为 http://localhost:8000/ServiceModelSamples/Service,CalculatorService 为实现服务协定的类型。

            //3.添加一个捕获 CommunicationException 的 try-catch 语句,并在接下来的三个步骤中将该代码添加到 try 块中。catch 子句应该显示错误信息,然后调用 selfHost.Abort()。
            try

            {
                if (this.ServiceContractObj == null)
                {
                    restr = "服务宿主对象未设置!";
                    return(false);
                }
                if (servAddr == null)
                {
                    restr = "服务器地址为空!";
                    return(false);
                }
                this.Stop(ref restr);

                //4.添加公开服务的终结点。为此,必须指定终结点公开的协议、绑定和终结点的地址。对于此示例,将 ICalculator 指定为协定,将 WSHttpBinding 指定为绑定,并将 CalculatorService 指定为地址。在这里请注意,终结点地址是相对地址。终结点的完整地址是基址和终结点地址的组合。在此例中,完整地址是 http://localhost:8000/ServiceModelSamples/Service/CalculatorService。
                EndpointAddress  _address     = new EndpointAddress(servAddr);
                BasicHttpBinding basicBinding = null;
                WebHttpBinding   webBinding   = null;
                if (protocol == EnumWCFProtocol.BasicHttp)
                {
                    basicBinding = new BasicHttpBinding();
                    basicBinding.MaxBufferPoolSize = 2147483647;
                    basicBinding.MaxBufferSize     = 2147483647;

                    basicBinding.MaxReceivedMessageSize = 2147483647;
                    basicBinding.ReceiveTimeout         = TimeSpan.MaxValue;        //20s
                    basicBinding.SendTimeout            = TimeSpan.FromSeconds(50); //20s
                }
                else if (protocol == EnumWCFProtocol.WebHttp)
                {
                    webBinding = new WebHttpBinding();
                    webBinding.MaxBufferPoolSize = 2147483647;
                    webBinding.MaxBufferSize     = 2147483647;

                    webBinding.MaxReceivedMessageSize = 2147483647;
                    webBinding.ReceiveTimeout         = TimeSpan.MaxValue;        //20s
                    webBinding.SendTimeout            = TimeSpan.FromSeconds(50); //20s
                }



                ContractDescription _contract = ContractDescription.GetContract(typeof(IContractObj));



                this.SelfHost = new ServiceHost(this.ServiceContractObj, servAddr);
                //添加终结点ABC
                if (protocol == EnumWCFProtocol.BasicHttp)
                {
                    ServiceEndpoint basicendpoint = new ServiceEndpoint(_contract, basicBinding, _address);

                    this.SelfHost.Description.Endpoints.Add(basicendpoint);
                }
                else if (protocol == EnumWCFProtocol.WebHttp)
                {
                    WebHttpEndpoint webEndpoint = new WebHttpEndpoint(_contract, _address);
                    webEndpoint.HelpEnabled = true;
                    webEndpoint.Binding     = webBinding;
                    this.SelfHost.Description.Endpoints.Add(webEndpoint);
                }


                //启用元数据交换
                ServiceMetadataBehavior meta = new ServiceMetadataBehavior();
                meta.HttpsGetEnabled = true;
                meta.HttpGetEnabled  = true;
                this.SelfHost.Description.Behaviors.Add(meta);
                this.SelfHost.Open();


                return(true);
            }
            catch (CommunicationException ce)
            {
                restr = ce.StackTrace;
                this.SelfHost.Abort();
                return(false);
            }
        }
 public void ConstructorServiceEndpoint()
 {
     // It is okay to pass ServiceEndpoint that does not have Binding or EndpointAddress.
     new ChannelFactory <IRequestChannel> (new ServiceEndpoint(ContractDescription.GetContract(typeof(IMetadataExchange)), null, null));
 }
Beispiel #16
0
 ServiceEndpoint CreateEndpoint()
 {
     return(new ServiceEndpoint(ContractDescription.GetContract(typeof(IMyService)), new WebHttpBinding(),
                                new EndpointAddress("http://localhost:37564")));
 }
 public ClientContract(Type contractType)
     : this(ContractDescription.GetContract(contractType))
 {
 }
Beispiel #18
0
        public void ReplaceBinding1()
        {
            var se = new WebHttpEndpoint(ContractDescription.GetContract(typeof(IMetadataExchange)), null);

            se.Binding = new NetTcpBinding();              // this does not throw exception yet.
        }
 public void GetMultipleServiceContract()
 {
     ContractDescription.GetContract(typeof(FooBar));
 }
Beispiel #20
0
        protected override ServiceDescription CreateDescription(out IDictionary <string, ContractDescription> implementedContracts)
        {
            ServiceDescription description;
            TService           instance = _serviceProvider.GetService <TService>();

            if (instance != null)
            {
                description = ServiceDescription.GetService(instance);
            }
            else
            {
                description = ServiceDescription.GetService <TService>();
            }

            // Any user supplied IServiceBehaviors can be applied now
            var serviceBehaviors = _serviceProvider.GetServices <IServiceBehavior>();

            foreach (var behavior in serviceBehaviors)
            {
                description.Behaviors.Add(behavior);
            }

            ServiceBehaviorAttribute serviceBehavior = description.Behaviors.Find <ServiceBehaviorAttribute>();
            object serviceInstanceUsedAsABehavior    = serviceBehavior.GetWellKnownSingleton();

            if (serviceInstanceUsedAsABehavior == null)
            {
                serviceInstanceUsedAsABehavior = serviceBehavior.GetHiddenSingleton();
                _disposableInstance            = serviceInstanceUsedAsABehavior as IDisposable;
            }

            if ((typeof(IServiceBehavior).IsAssignableFrom(typeof(TService)) || typeof(IContractBehavior).IsAssignableFrom(typeof(TService))) &&
                serviceInstanceUsedAsABehavior == null)
            {
                if (instance == null)
                {
                    serviceInstanceUsedAsABehavior = ServiceDescription.CreateImplementation <TService>();
                }
                else
                {
                    serviceInstanceUsedAsABehavior = instance;
                }

                _disposableInstance = serviceInstanceUsedAsABehavior as IDisposable;
            }

            if (instance != null)
            {
                if (serviceBehavior.InstanceContextMode == InstanceContextMode.Single)
                {
                    SingletonInstance = instance;
                }
                else
                {
                    serviceBehavior.InstanceProvider = new DependencyInjectionInstanceProvider(_serviceProvider, typeof(TService));
                    if (serviceInstanceUsedAsABehavior == null && instance is IDisposable disposable)
                    {
                        disposable.Dispose();
                    }
                }
            }

            if (instance == null)
            {
                if (serviceInstanceUsedAsABehavior is IServiceBehavior)
                {
                    description.Behaviors.Add((IServiceBehavior)serviceInstanceUsedAsABehavior);
                }
            }

            ReflectedContractCollection reflectedContracts = new ReflectedContractCollection();
            List <Type> interfaces = ServiceReflector.GetInterfaces <TService>();

            for (int i = 0; i < interfaces.Count; i++)
            {
                Type contractType = interfaces[i];
                if (!reflectedContracts.Contains(contractType))
                {
                    ContractDescription contract = null;
                    if (serviceInstanceUsedAsABehavior != null)
                    {
                        contract = ContractDescription.GetContract <TService>(contractType, serviceInstanceUsedAsABehavior);
                    }
                    else
                    {
                        contract = ContractDescription.GetContract <TService>(contractType);
                    }

                    reflectedContracts.Add(contract);
                    Collection <ContractDescription> inheritedContracts = contract.GetInheritedContracts();
                    for (int j = 0; j < inheritedContracts.Count; j++)
                    {
                        ContractDescription inheritedContract = inheritedContracts[j];
                        if (!reflectedContracts.Contains(inheritedContract.ContractType))
                        {
                            reflectedContracts.Add(inheritedContract);
                        }
                    }
                }
            }
            ReflectedContracts = reflectedContracts;

            implementedContracts = reflectedContracts.ToImplementedContracts();
            return(description);
        }
 public void GetContractInvalidAsync()
 {
     ContractDescription.GetContract(typeof(IInvalidAsync));
 }
Beispiel #22
0
        public bool Init(ref string reStr)
        {
            try
            {
                localMesBasebll   = new LOCAL_MES_STEP_INFOBll();
                localMesDetailbll = new LOCAL_MES_STEP_INFO_DETAILBll();
                productCfgBll     = new ProductSizeCfgBll();
                LineNodes.NodeFactory nodeFactory = new LineNodes.NodeFactory();


                if (!nodeFactory.ConfigInit(ref reStr))
                {
                    return(false);
                }
                this.plcRWs       = nodeFactory.PlcRWList;
                this.rfidRWs      = nodeFactory.RfidRWList;
                this.barcodeRWs   = nodeFactory.BarcodeRWList;
                this.airDetectRWs = nodeFactory.AirDetectRWList;
                this.printerRWs   = nodeFactory.PrinterRWList;
                this.nodeList     = nodeFactory.GetNodes(ref reStr);
                this.threadList   = nodeFactory.GetThreadAlloc(ref reStr);
                foreach (ThreadBaseModel threadObj in this.threadList)
                {
                    threadObj.LogRecorder = logRecorder;
                }
                //  this.threadList = new List<ThreadRunModel>();

                ////线程1
                //ThreadRunModel threadObj = new ThreadRunModel(1, "线程1:" );
                //threadObj.LoopInterval = 100;
                //threadObj.LogRecorder = logRecorder;
                //threadObj.AddNode(node);
                //if (!threadObj.TaskInit(ref reStr))
                //{
                //    Console.WriteLine(reStr);
                //}
                //this.threadList.Add(threadObj);

                //线程2

                //for (int i = 0; i < nodeList.Count(); i++)
                //{
                //    CtlNodeBaseModel node = nodeList[i];

                //    ThreadRunModel threadObj = new ThreadRunModel(i + 1, "线程:" + node.NodeName);
                //    threadObj.LoopInterval = 100;

                //    threadObj.LogRecorder = logRecorder;
                //    threadObj.AddNode(node);
                //    if (!threadObj.TaskInit(ref reStr))
                //    {
                //        Console.WriteLine(reStr);
                //    }
                //    this.threadList.Add(threadObj);
                //}

                //for (int i = 0; i < nodeList.Count(); i++)
                //{
                //    CtlNodeBaseModel node = nodeList[i];
                //    node.PlcRW = this.plcRWs[0];
                //    node.SimMode = NodeFactory.SimMode;
                //}

                if (!NodeFactory.SimMode)
                {
                    CommDevConnect();//通信设备连接
                }

                this.nodeStatusList = new List <CtlNodeStatus>();
                svcNodeStatusList   = new List <MonitorSvcNodeStatus>();
                foreach (CtlNodeBaseModel node in this.nodeList)
                {
                    this.nodeStatusList.Add(node.CurrentStat);
                    node.LogRecorder = logRecorder;
                    MonitorSvcNodeStatus svcStat = new MonitorSvcNodeStatus();
                    svcStat.NodeName       = node.NodeName;
                    svcStat.ProductBarcode = node.CurrentStat.ProductBarcode;
                    svcStat.StatDescribe   = node.CurrentStat.StatDescribe;
                    svcStat.Status         = node.CurrentStat.Status.ToString();
                    svcNodeStatusList.Add(svcStat);
                }

                mainThread = new ThreadBaseModel(1, "业务线程");
                mainThread.LoopInterval = 10;
                mainThread.SetThreadRoutine(new DelegateThreadRoutine(BusinessLoop));
                if (!mainThread.TaskInit(ref reStr))
                {
                    logRecorder.AddLog(new LogModel(objectName, reStr, EnumLoglevel.错误));

                    return(false);
                }


                historyDataClearThread = new ThreadBaseModel(2, "日志清理线程");
                historyDataClearThread.LoopInterval = 60000;//1分钟清理一次
                historyDataClearThread.SetThreadRoutine(ClearLogLoop);
                if (!historyDataClearThread.TaskInit(ref reStr))
                {
                    logRecorder.AddLog(new LogModel(objectName, reStr, EnumLoglevel.错误));
                }
                printerLoopThread = new ThreadBaseModel(3, "贴标队列处理线程");
                printerLoopThread.LoopInterval = 500;//500
                printerLoopThread.SetThreadRoutine(PrinterQueueLoop);
                printerLoopThread.TaskInit(ref reStr);
                //   Console.WriteLine("P1");

                view.InitNodeMonitorview(this.nodeList);
                //   Console.WriteLine("P2");
                //宿主WCF服务
                Uri                 _baseAddress = new Uri("http://localhost:8733/ZZ/LineNodes/NodeMonitorSvc/");
                EndpointAddress     _Address     = new EndpointAddress(_baseAddress);
                BasicHttpBinding    _Binding     = new BasicHttpBinding();
                ContractDescription _Contract    = ContractDescription.GetContract(typeof(LineNodes.INodeMonitorSvc));
                ServiceEndpoint     endpoint     = new ServiceEndpoint(_Contract, _Binding, _Address);
                NodeMonitorSvc      monitorSvc   = new NodeMonitorSvc();

                monitorSvc.dlgtNodeStatus += GetSvcNodeStatus;
                monitorSvc.dlgtRunningDev += GetRunningDetectdevs;

                ServiceHost host = new ServiceHost(monitorSvc, _baseAddress);
                //添加终结点ABC
                host.Description.Endpoints.Add(endpoint);
                //启用元数据交换
                ServiceMetadataBehavior meta = new ServiceMetadataBehavior();

                meta.HttpGetEnabled = true;
                host.Description.Behaviors.Add(meta);
                host.Open();
                //  Console.WriteLine("P3");
                return(true);
            }
            catch (Exception ex)
            {
                view.PopupMes(ex.ToString());
                return(false);
            }
        }
 public void DuplicateOperationNames()
 {
     ContractDescription.GetContract(typeof(IDuplicateOperationNames));
 }
Beispiel #24
0
 public ConverterMessageDeliveryReaderFactory(MessageEncoder encoder, params Type[] contracts) : this(encoder, (from t in contracts select ContractDescription.GetContract(t)).ToArray())
 {
 }
 public void AsyncNameDoesNotStartWithBeginButExplicitName()
 {
     // it is still invalid ...
     ContractDescription.GetContract(typeof(IAsyncNameDoesNotStartWithBeginButExplicitName));
 }
Beispiel #26
0
        public List <AirlineServer.Trip> getTrips(string src, string dst, DateTime date, List <string> sellers)
        {
            List <string> sellersToSearch;
            Dictionary <string, ZNodesDataStructures.MachineNode> machines = AirlineReplicationModule.Instance.Machines;
            List <Flight> sourceFlights = new List <Flight>();
            List <Flight> dstFlights    = new List <Flight>();
            List <Trip>   trips         = new List <Trip>();

            if (sellers.Count == 0)
            {
                sellersToSearch = new List <string>();
            }
            else
            {
                sellersToSearch = sellers;
            }

            foreach (string m in machines.Keys)
            {
                try
                {
                    ServiceEndpoint endPoint = new ServiceEndpoint(
                        ContractDescription.GetContract(typeof(ISellerClusterService)), new BasicHttpBinding(), new EndpointAddress(machines[m].uri));
                    using (ChannelFactory <ISellerClusterService> httpFactory = new ChannelFactory <ISellerClusterService>(endPoint))
                    {
                        ISellerClusterService sellerCluster = httpFactory.CreateChannel();
                        sourceFlights.AddRange(sellerCluster.getRelevantFlightsBySrc(src, date, sellersToSearch));
                        dstFlights.AddRange(sellerCluster.getRelevantFlightsByDst(dst, date, sellersToSearch));
                        dstFlights.AddRange(sellerCluster.getRelevantFlightsByDst(dst, date.AddDays(1), sellersToSearch));
                    }
                }
                catch (Exception e)
                {
                    throw new FaultException("The query could not be fully made: " + e.Message);
                }

                foreach (AirlineServer.Flight srcFlight in sourceFlights)
                {
                    if (srcFlight.dst.Equals(dst))
                    {
                        Trip trip = new Trip();
                        trip.firstFlight  = srcFlight;
                        trip.secondFlight = null;
                        trip.price        = srcFlight.price;
                        trips.Add(trip);
                        continue;
                    }
                    foreach (AirlineServer.Flight dstFlight in dstFlights)
                    {
                        if (srcFlight.dst.Equals(dstFlight.src))
                        {
                            Trip trip = new Trip();
                            trip.firstFlight  = srcFlight;
                            trip.secondFlight = dstFlight;
                            trip.price        = srcFlight.price + dstFlight.price;
                            trips.Add(trip);
                        }
                    }
                }
            }

            return(trips);
        }
        public void MultipleContractsInTypeHierarchy()
        {
            ContractDescription.GetContract(typeof(DuplicateCheckClassWrapper.ServiceInterface));

            var host = new ServiceHost(typeof(DuplicateCheckClassWrapper.DummyService));               // fine in MS, fails in Mono with "A contract cannot have two operations that have the identical names and different set of parameters"
        }
Beispiel #28
0
 /// <summary>
 /// The constructor.
 /// </summary>
 /// <param name="ctx">Specifies the context.</param>
 public MyCaffeGymUiProxy(InstanceContext ctx)
     : base(ctx, new ServiceEndpoint(ContractDescription.GetContract(typeof(IXMyCaffeGymUiService)),
                                     new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/MyCaffeGym/gymui")))
 {
 }
 public void MessageContractAttributes5()
 {
     ContractDescription.GetContract(typeof(IFoo2_5));
 }
Beispiel #30
0
 protected override ServiceEndpoint CreateDescription()
 {
     return(new ServiceEndpoint(ContractDescription.GetContract(typeof(ICtorUseCase2))));
 }