Esempio n. 1
0
        public static void ComputeContractRequirements(ContractDescription contractDescription,
                                                       out ChannelRequirements requirements)
        {
            requirements = new ChannelRequirements
            {
                usesInput   = false,
                usesReply   = false,
                usesOutput  = false,
                usesRequest = false,
                sessionMode = contractDescription.SessionMode
            };

            for (int i = 0; i < contractDescription.Operations.Count; i++)
            {
                OperationDescription operation = contractDescription.Operations[i];
                bool oneWay = (operation.IsOneWay);
                if (!operation.IsServerInitiated())
                {
                    if (oneWay)
                    {
                        requirements.usesInput = true;
                    }
                    else
                    {
                        requirements.usesReply = true;
                    }
                }
                else
                {
                    if (oneWay)
                    {
                        requirements.usesOutput = true;
                    }
                    else
                    {
                        requirements.usesRequest = true;
                    }
                }
            }
        }
Esempio n. 2
0
        public static      Type[] ComputeRequiredChannels(ref ChannelRequirements requirements)
        {
            if (requirements.usesOutput || requirements.usesRequest)
            {
                switch (requirements.sessionMode)
                {
                case SessionMode.Allowed:
                    return(new[] {
                        typeof(IDuplexChannel),
                        typeof(IDuplexSessionChannel),
                    });

                case SessionMode.Required:
                    return(new[] {
                        typeof(IDuplexSessionChannel),
                    });

                case SessionMode.NotAllowed:
                    return(new[] {
                        typeof(IDuplexChannel),
                    });
                }
            }
            else if (requirements.usesInput && requirements.usesReply)
            {
                switch (requirements.sessionMode)
                {
                case SessionMode.Allowed:
                    return(new[] {
                        typeof(IRequestChannel),
                        typeof(IRequestSessionChannel),
                        typeof(IDuplexChannel),
                        typeof(IDuplexSessionChannel),
                    });

                case SessionMode.Required:
                    return(new[] {
                        typeof(IRequestSessionChannel),
                        typeof(IDuplexSessionChannel),
                    });

                case SessionMode.NotAllowed:
                    return(new[] {
                        typeof(IRequestChannel),
                        typeof(IDuplexChannel),
                    });
                }
            }
            else if (requirements.usesInput)
            {
                switch (requirements.sessionMode)
                {
                case SessionMode.Allowed:
                    return(new[] {
                        typeof(IOutputChannel),
                        typeof(IOutputSessionChannel),
                        typeof(IRequestChannel),
                        typeof(IRequestSessionChannel),
                        typeof(IDuplexChannel),
                        typeof(IDuplexSessionChannel),
                    });

                case SessionMode.Required:
                    return(new[] {
                        typeof(IOutputSessionChannel),
                        typeof(IRequestSessionChannel),
                        typeof(IDuplexSessionChannel),
                    });

                case SessionMode.NotAllowed:
                    return(new[] {
                        typeof(IOutputChannel),
                        typeof(IRequestChannel),
                        typeof(IDuplexChannel),
                    });
                }
            }
            else if (requirements.usesReply)
            {
                switch (requirements.sessionMode)
                {
                case SessionMode.Allowed:
                    return(new[] {
                        typeof(IRequestChannel),
                        typeof(IRequestSessionChannel),
                        typeof(IDuplexChannel),
                        typeof(IDuplexSessionChannel),
                    });

                case SessionMode.Required:
                    return(new[] {
                        typeof(IRequestSessionChannel),
                        typeof(IDuplexSessionChannel),
                    });

                case SessionMode.NotAllowed:
                    return(new[] {
                        typeof(IRequestChannel),
                        typeof(IDuplexChannel),
                    });
                }
            }
            else
            {
                switch (requirements.sessionMode)
                {
                case SessionMode.Allowed:
                    return(new[] {
                        typeof(IOutputSessionChannel),
                        typeof(IOutputChannel),
                        typeof(IRequestSessionChannel),
                        typeof(IRequestChannel),
                        typeof(IDuplexChannel),
                        typeof(IDuplexSessionChannel),
                    });

                case SessionMode.Required:
                    return(new[] {
                        typeof(IOutputSessionChannel),
                        typeof(IRequestSessionChannel),
                        typeof(IDuplexSessionChannel),
                    });

                case SessionMode.NotAllowed:
                    return(new[] {
                        typeof(IOutputChannel),
                        typeof(IRequestChannel),
                        typeof(IDuplexChannel),
                    });
                }
            }
            return(null);
        }