// Methods
 public ServiceEndpoint(ContractDescription contract)
 {
     if (contract == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("contract");
     }
     this.contract = contract;
 }
 public ServiceEndpoint(ContractDescription contract, Binding binding, EndpointAddress address)
 {
     if (contract == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("contract");
     }
     this.contract = contract;
     this.binding = binding;
     this.address = address;
 }
 public static void Ctor_Taking_Name_Initializes()
 {
     const string expectedName = "testName";
     ContractDescription cd = new ContractDescription(expectedName);
     Assert.Equal<string>(expectedName, cd.Name);
     Assert.Equal<string>("http://tempuri.org/", cd.Namespace);
     Assert.Null(cd.ContractType);
     Assert.Null(cd.CallbackContractType);
     Assert.NotNull(cd.Operations);
     Assert.Equal<int>(0, cd.Operations.Count);
     Assert.NotNull(cd.Behaviors);
     Assert.Equal<int>(0, cd.Behaviors.Count);
     Assert.NotNull(cd.ContractBehaviors);
     Assert.Equal<int>(0, cd.ContractBehaviors.Count);
 }
 // Methods
 public ServiceContractGenerationContext(ServiceContractGenerator serviceContractGenerator, ContractDescription contract, CodeTypeDeclaration contractType)
 {
    this.operations = new Collection<OperationContractGenerationContext>();
    if (serviceContractGenerator == null)
    {
       throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("serviceContractGenerator"));
    }
    if (contract == null)
    {
       throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("contract"));
    }
    if (contractType == null)
    {
       throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("contractType"));
    }
    this.serviceContractGenerator = serviceContractGenerator;
    this.contract = contract;
    this.contractType = contractType;
 }
 // Methods
 public OperationDescription(string name, ContractDescription declaringContract)
 {
     this.validateRpcWrapperName = true;
     if (name == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("name");
     }
     if (name.Length == 0)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("name", SR.GetString("SFxOperationDescriptionNameCannotBeEmpty")));
     }
     this.name = new XmlName(name, true);
     if (declaringContract == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("declaringContract");
     }
     this.declaringContract = declaringContract;
     this.isInitiating = true;
     this.isTerminating = false;
     this.faults = new FaultDescriptionCollection();
     this.messages = new MessageDescriptionCollection();
     this.behaviors = new KeyedByTypeCollection<IOperationBehavior>();
     this.knownTypes = new Collection<Type>();
 }
 public static void ProtectionLevel_Property_Sets(ProtectionLevel level)
 {
     ContractDescription cd = new ContractDescription("test");
     cd.ProtectionLevel = level;
     Assert.Equal<ProtectionLevel>(level, cd.ProtectionLevel);
 }
 public void AddBindingParameters(ContractDescription description, ServiceEndpoint endpoint, BindingParameterCollection parameters)
 {
     return;
 }
 private void VisitContract(ContractDescription contract)
 {
     this.Visit(contract);
     foreach (OperationDescription description in contract.Operations)
     {
         this.Visit(description);
     }
 }
 private static bool IsDuplex(ContractDescription contract)
 {
     foreach (OperationDescription description in contract.Operations)
     {
         if (description.IsServerInitiated())
         {
             return true;
         }
     }
     return false;
 }
 public void Validate(ContractDescription description, ServiceEndpoint endpoint)
 {
     return;
 }
 void IContractBehavior.ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime)
 {
 }
Пример #12
0
    public static void Name_Property_With_Empty_String_Throws()
    {
        ContractDescription cd = new ContractDescription("test");

        Assert.Throws <ArgumentOutOfRangeException>(() => cd.Name = String.Empty);
    }
        private bool LoadBizProxy(string bindingName, string bindingConfigName, string address)
        {
            Binding         binding;
            Uri             uri;
            ServiceEndpoint serviceEndpoint;
            ChannelFactory <IServiceString> channelFactory;

            //ChannelFactory<IServiceAsync> _ChannelFactoryAsync;

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

                    //this.LoadBinding(this.GetttributeInnerXml("system.serviceModel", 0));
                    //this.LoadBinding(Factory.FactoryConfig.XmlDocument.SelectNodes(this.GetType().FullName.Replace(".", "/") + "/system.serviceModel").Item(0).InnerXml);
                }

                switch (bindingName)
                {
                case "BasicHttpBinding":
                    if (bindingConfigName.IsNullOrEmpty())
                    {
                        binding = this.GetBasicHttpBinding();
                    }
                    else
                    {
                        binding = this.GetBasicHttpBinding(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 <IServiceString>(serviceEndpoint);
                //this.Service = _ChannelFactory.CreateChannel();

                //_ServiceEndpoint = new ServiceEndpoint(ContractDescription.GetContract(this.GetType()), _Binding, new EndpointAddress(_Uri));
                //_ChannelFactoryAsync = new ChannelFactory<IServiceAsync>(_ServiceEndpoint);
                //this.ServiceAsync = _ChannelFactoryAsync.CreateChannel();

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

                return(true);
            }
            catch (AtomusException exception)
            {
                throw exception;
            }
            catch (Exception exception)
            {
                throw new AtomusException(exception);
            }
        }
Пример #14
0
 /// <summary>
 /// Implement to confirm that the contract and endpoint can support the contract behavior.
 /// </summary>
 /// <param name="contractDescription">The contract to validate.</param>
 /// <param name="endpoint">The endpoint to validate.</param>
 public void Validate(ContractDescription contractDescription, ServiceEndpoint endpoint)
 {
     _contractBehavior.Validate(contractDescription, endpoint);
 }
 public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.DispatchRuntime dispatchRuntime)
 {
     dispatchRuntime.OperationSelector =
         new DispatchByBodyElementOperationSelector();
 }
 public void ApplyClientBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.ClientRuntime clientRuntime)
 {
     // this is a dispatch-side behavior which doesn't require
     // any action on the client
     return;
 }
 public void AddBindingParameters(ContractDescription contractDescription, ServiceEndpoint endpoint, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
 {
     // no binding parameters need to be set here
     return;
 }
 public static void CallbackContractType_Property_Sets(Type contractType)
 {
     ContractDescription cd = new ContractDescription("test");
     cd.CallbackContractType = contractType;
     Assert.Equal<Type>(contractType, cd.CallbackContractType);
 }
 public void ApplyClientBehavior(ContractDescription description, ServiceEndpoint endpoint, ClientRuntime proxy)
 {
     return;
 }
 public static void Name_Property_With_Null_Throws()
 {
     ContractDescription cd = new ContractDescription("test");
     Assert.Throws<ArgumentNullException>(() => cd.Name = null);
 }
Пример #21
0
 public void AddBindingParameters(ContractDescription contractDescription, ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
 {
 }
 void IContractBehavior.AddBindingParameters(ContractDescription contractDescription, ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
 {
 }
 void IContractBehavior.ApplyClientBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, ClientRuntime clientRuntime)
 {
 }
Пример #24
0
    public static void Namespace_Property_Set_With_Invalid_Value_Throws(string nameSpace)
    {
        ContractDescription cd = new ContractDescription("test");

        Assert.Throws <ArgumentException>(() => cd.Namespace = nameSpace);
    }
 public void ApplyDispatchBehavior(ContractDescription description, ServiceEndpoint endpoint, DispatchRuntime dispatch)
 {
     this.contractDescription = description;
     Debug.WriteLine("Added the {0} contract description to exporter.", description.Name);
 }
Пример #26
0
 public static string GetFaultMessageAction(ContractDescription contractName, string opname, string action)
 {
     return(ServiceUtility.GetMessageAction(contractName, opname, action, /* isResponse */ false) + typeof(DomainServiceFault).Name);
 }
Пример #27
0
    public static void ProtectionLevel_Property_Set_With_Invalid_Value_Throws()
    {
        ContractDescription cd = new ContractDescription("test");

        Assert.Throws <ArgumentOutOfRangeException>(() => cd.ProtectionLevel = (ProtectionLevel)99);
    }
 void IContractBehavior.AddBindingParameters(ContractDescription contractDescription, ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
 {
 }
Пример #29
0
    public static void Name_Property_With_Null_Throws()
    {
        ContractDescription cd = new ContractDescription("test");

        Assert.Throws <ArgumentNullException>(() => cd.Name = null);
    }
 public ServiceContractGenerationContext CreateContext(ContractDescription contractDescription)
 {
     this.VisitContract(contractDescription);
     return this.context;
 }
Пример #31
0
 /// <summary>
 /// Implements a modification or extension of the client across a contract.
 /// </summary>
 /// <param name="contractDescription">The contract description to be modified.</param>
 /// <param name="endpoint">The endpoint that exposes the contract.</param>
 /// <param name="dispatchRuntime">The dispatch runtime that controls service execution.</param>
 public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.DispatchRuntime dispatchRuntime)
 {
     ReplaceSerializerOperationBehavior(contractDescription);
 }
 private void Visit(ContractDescription contractDescription)
 {
     bool flag = IsDuplex(contractDescription);
     this.contractMemberScope = new UniqueCodeIdentifierScope();
     this.callbackMemberScope = flag  new UniqueCodeIdentifierScope()  null;
     UniqueCodeNamespaceScope scope = new UniqueCodeNamespaceScope(this.parent.NamespaceManager.EnsureNamespace(contractDescription.Namespace));
     CodeTypeDeclaration codeType = this.typeFactory.CreateInterfaceType();
     CodeTypeReference reference = scope.AddUnique(codeType, contractDescription.CodeName, IContract);
     CodeTypeDeclaration declaration2 = null;
     CodeTypeReference reference2 = null;
     if (flag)
     {
         declaration2 = this.typeFactory.CreateInterfaceType();
         reference2 = scope.AddUnique(declaration2, contractDescription.CodeName + Callback, IContract);
     }
     this.context = new ServiceContractGenerationContext(this.parent, contractDescription, codeType, declaration2);
     this.context.Namespace = scope.CodeNamespace;
     this.context.TypeFactory = this.typeFactory;
     this.context.ContractTypeReference = reference;
     this.context.DuplexCallbackTypeReference = reference2;
     this.AddServiceContractAttribute(this.context);
 }
Пример #33
0
        /// <summary>
        /// The constructor for this.  In addition to initializing all of the parameters it attempts to open and connect
        /// to the network.  This is done asynchronously with ProcessOpen being called either after a timeout (hard coded to 1 minute)
        /// or when a response is received.
        /// </summary>
        /// <param name="nodeName">the unique nodename</param>
        /// <param name="networkName">the name of the network</param>
        /// <param name="password">the password for the network</param>
        public bool PeerChannelWrapperStart(String nodeName, String networkName, String password)
        {
            CheckDisposed();
            //////////////////////////////////////////////////////////////////////////
            //Initialize all the parameters...
            //////////////////////////////////////////////////////////////////////////
            mNodeName    = nodeName;
            mNetworkName = networkName;

            //password cannot be empty otherwise mFactory.CreateChannel() below will throw an exception
            if (string.IsNullOrEmpty(password))
            {
                mPassword = "******";
            }
            else
            {
                mPassword = password.Trim();
            }

            //Construct InstanceContext to handle messages on callback interface.
            mInstanceContext = new InstanceContext(this);

            //////////////////////////////////////////////////////////////////////////
            //Create the PeerTcpBinding
            //////////////////////////////////////////////////////////////////////////
            NetPeerTcpBinding p2pBinding = new NetPeerTcpBinding();

            p2pBinding.Name = "BindingDefault";
            p2pBinding.Port = 0;                                       //dynamic port
            p2pBinding.MaxReceivedMessageSize = 70000000;              //set the max message size in bytes (70mb)
            p2pBinding.Resolver.Mode          = PeerResolverMode.Pnrp; //use the standard pnrp for our resolver to find the network

            //////////////////////////////////////////////////////////////////////////
            //create the Endpoint Address and Service Endpoint.
            //////////////////////////////////////////////////////////////////////////
            String          bindingInfo     = "net.p2p://"; //the endpoint address for a NetPeerTcpBinding must start with net.p2p
            EndpointAddress epa             = new EndpointAddress(String.Concat(bindingInfo, mNetworkName));
            ServiceEndpoint serviceEndpoint = new ServiceEndpoint(ContractDescription.GetContract(typeof(IPeerChannel)), p2pBinding, epa);

            //////////////////////////////////////////////////////////////////////////
            // Create the participant with the given endpoint configuration
            // Each participant opens a duplex channel to the mesh
            // participant is an instance of the channel to the mesh
            //////////////////////////////////////////////////////////////////////////
            mFactory = new DuplexChannelFactory <IPeerChannelWrapper>(mInstanceContext, serviceEndpoint);
            mFactory.Credentials.Peer.MeshPassword = mPassword;
            mParticipant = mFactory.CreateChannel();

            mPicture = new PictureHelper(mParticipant.SharePicture, mNodeName);
            mTextPeerChannelHelper = new ChatHelper(mParticipant.ShareTextMessage);
            mFilePeerChannelHelper = new FileHelper(mParticipant.ShareFile);
            mStreamedAudio         = new StreamingHelper(mParticipant, mNodeName, mParticipant.ShareStreamedAudio);
            mStreamedVideo         = new StreamingHelper(mParticipant, mNodeName, mParticipant.ShareStreamedVideo);

            //////////////////////////////////////////////////////////////////////////
            //Start an asynchronous call that will try to open a connection to the network.
            //if one is not found, but the pnrp resolver is running then a new network will be
            //created.
            //////////////////////////////////////////////////////////////////////////
            try
            {
                AsyncCallback callBack = new AsyncCallback(ProcessOpen);
                TimeSpan      ts       = new TimeSpan(0, 1, 0); //wait a minute
                mParticipant.BeginOpen(ts, callBack, this);
            }
            catch (CommunicationException e)
            {
                System.Windows.MessageBox.Show(String.Format("Error while joining the network: {0}", e.Message));
                mParticipant = null;
                return(false);
            }
            return(true);
        }
 private static IEnumerableIServiceContractGenerationExtension EnumerateBehaviorExtensions(ContractDescription contract)
 {
     EnumerateBehaviorExtensionsd__8 d__ = new EnumerateBehaviorExtensionsd__8(-2);
     d__.3__contract = contract;
     return d__;
 }
Пример #35
0
 /// <summary>
 /// Implement to confirm that the contract and endpoint can support the contract behavior.
 /// </summary>
 /// <param name="contractDescription">The contract to validate.</param>
 /// <param name="endpoint">The endpoint to validate.</param>
 public void Validate(
     ContractDescription contractDescription,
     ServiceEndpoint endpoint)
 {
     // Not implemented.
 }
 public static void Namespace_Property_Set_With_Invalid_Value_Throws(string nameSpace)
 {
     ContractDescription cd = new ContractDescription("test");
     Assert.Throws<ArgumentException>(() => cd.Namespace = nameSpace);
 }
Пример #37
0
 protected override ServiceEndpoint CreateDescription()
 {
     return(new ServiceEndpoint(ContractDescription.GetContract(typeof(ICtorUseCase2))));
 }
 public static void ProtectionLevel_Property_Set_With_Invalid_Value_Throws()
 {
     ContractDescription cd = new ContractDescription("test");
     Assert.Throws<ArgumentOutOfRangeException>(() => cd.ProtectionLevel = (ProtectionLevel)99);
 }
 public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.DispatchRuntime dispatchRuntime)
 {
     dispatchRuntime.ChannelDispatcher.ChannelInitializers.Add(this);
 }
 public static void Name_Property_Sets(string name)
 {
     ContractDescription cd = new ContractDescription("test");
     cd.Name = name;
     Assert.Equal<string>(name, cd.Name);
 }
 public void AddBindingParameters(ContractDescription contractDescription, ServiceEndpoint endpoint, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
 {
 }
 public static void Name_Property_With_Empty_String_Throws()
 {
     ContractDescription cd = new ContractDescription("test");
     Assert.Throws<ArgumentOutOfRangeException>(() => cd.Name = String.Empty);
 }
 public void ApplyClientBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.ClientRuntime clientRuntime)
 {
 }
 internal OperationDescription(string name, ContractDescription declaringContract, bool validateRpcWrapperName) : this(name, declaringContract)
 {
     this.validateRpcWrapperName = validateRpcWrapperName;
 }
Пример #45
0
 void IContractBehavior.ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime)
 {
     dispatchRuntime.InstanceProvider = this;
 }
 void IContractBehavior.ApplyClientBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, ClientRuntime clientRuntime)
 {
 }
Пример #47
0
 void IContractBehavior.Validate(ContractDescription contractDescription, ServiceEndpoint endpoint)
 {
 }
 void IContractBehavior.Validate(ContractDescription contractDescription, ServiceEndpoint endpoint)
 {
 }
Пример #49
0
 public CSharpClientBuilderBuilder(ContractDescription contract)
 {
     _contract = contract;
 }
 public ServiceContractGenerationContext(ServiceContractGenerator serviceContractGenerator, ContractDescription contract, CodeTypeDeclaration contractType, CodeTypeDeclaration duplexCallbackType)
    : this(serviceContractGenerator, contract, contractType)
 {
    this.duplexCallbackType = duplexCallbackType;
 }
Пример #51
0
 public PipeCommunication()
     : base(new ServiceEndpoint(ContractDescription.GetContract(typeof(IPipeCommunication)),
                                new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/sdc/FoxSDC-Agent-Comm")))
 {
 }
Пример #52
0
 public void Validate(ContractDescription contractDescription, ServiceEndpoint endpoint)
 {
 }
Пример #53
0
 public static string GetResponseMessageAction(ContractDescription contractName, string opname, string action)
 {
     return(ServiceUtility.GetMessageAction(contractName, opname, action, /* isResponse */ true));
 }