示例#1
0
        protected void AddEndpointBehaviors(T client, ITokenPassportProvider tokenPassportProvider)
        {
            if (client.tokenPassport == null && tokenPassportProvider == null)
            {
                throw new InvalidOperationException("A Token Passport was not provided and no provider was specified.");
            }

            SuiteTalkHeader[] headers;

            if (client.tokenPassport != null)
            {
                headers = new SuiteTalkHeader[] { new SearchPreferencesHeader(client) };
            }
            else
            {
                headers = new SuiteTalkHeader[] {
                    new TokenPassportHeader(tokenPassportProvider),
                    new SearchPreferencesHeader(client)
                };
            }

            var inspector = new SuiteTalkMessageInspector(headers);

            var endpointBehavior = new SuiteTalkEndpointBehavior(inspector);

            client.Endpoint.EndpointBehaviors.Add(endpointBehavior);

            this.AddDynamicEndpointBehaviours(client);
        }
示例#2
0
        private void AddEndpointBehaviors(T client, string applicationId, IPassportProvider passportProvider)
        {
            if (applicationId == null)
            {
                throw new InvalidOperationException("The Application ID was not specified.");
            }
            if (client.passport == null && passportProvider == null)
            {
                throw new InvalidOperationException("A Passport was not specified and no provider was given.");
            }

            SuiteTalkHeader[] headers;

            if (client.passport != null)
            {
                headers = new SuiteTalkHeader[] {
                    new ApplicationInfoHeader(applicationId),
                    new SearchPreferencesHeader(client)
                };
            }
            else
            {
                headers = new SuiteTalkHeader[] {
                    new ApplicationInfoHeader(applicationId),
                    new PassportHeader(passportProvider),
                    new SearchPreferencesHeader(client)
                };
            }

            var inspector = new SuiteTalkMessageInspector(headers);

            var endpointBehavior = new SuiteTalkEndpointBehavior(inspector);

            client.Endpoint.EndpointBehaviors.Add(endpointBehavior);

            this.AddDynamicEndpointBehaviours(client);
        }