Пример #1
0
        public NamespaceManager CreateNamespaceManager()
        {
            NamespaceManager namespaceManager;

            this.Validate();
            string            item = this.connectionProperties["OperationTimeout"];
            IEnumerable <Uri> endpointAddresses = KeyValueConfigurationManager.GetEndpointAddresses(this.connectionProperties["Endpoint"], this.connectionProperties["ManagementPort"]);
            IEnumerable <Uri> uris            = KeyValueConfigurationManager.GetEndpointAddresses(this.connectionProperties["StsEndpoint"], null);
            string            str             = this.connectionProperties["SharedSecretIssuer"];
            string            item1           = this.connectionProperties["SharedSecretValue"];
            string            str1            = this.connectionProperties["SharedAccessKeyName"];
            string            item2           = this.connectionProperties["SharedAccessKey"];
            string            str2            = this.connectionProperties["WindowsDomain"];
            string            item3           = this.connectionProperties["WindowsUsername"];
            SecureString      windowsPassword = this.GetWindowsPassword();
            string            str3            = this.connectionProperties["OAuthDomain"];
            string            item4           = this.connectionProperties["OAuthUsername"];
            SecureString      oAuthPassword   = this.GetOAuthPassword();

            try
            {
                TokenProvider tokenProvider = KeyValueConfigurationManager.CreateTokenProvider(uris, str, item1, str1, item2, str2, item3, windowsPassword, str3, item4, oAuthPassword);
                if (!string.IsNullOrEmpty(item))
                {
                    NamespaceManagerSettings namespaceManagerSetting = new NamespaceManagerSettings()
                    {
                        OperationTimeout = TimeSpan.Parse(item, CultureInfo.CurrentCulture),
                        TokenProvider    = tokenProvider
                    };
                    namespaceManager = new NamespaceManager(endpointAddresses, namespaceManagerSetting);
                }
                else
                {
                    namespaceManager = new NamespaceManager(endpointAddresses, tokenProvider);
                }
            }
            catch (ArgumentException argumentException1)
            {
                ArgumentException argumentException = argumentException1;
                throw new ConfigurationErrorsException(SRClient.AppSettingsCreateManagerWithInvalidConnectionString(argumentException.Message), argumentException);
            }
            catch (UriFormatException uriFormatException1)
            {
                UriFormatException uriFormatException = uriFormatException1;
                throw new ConfigurationErrorsException(SRClient.AppSettingsCreateManagerWithInvalidConnectionString(uriFormatException.Message), uriFormatException);
            }
            return(namespaceManager);
        }