当前位置: 首页>>代码示例>>C#>>正文


C# ProfileClient.GetEnvironmentOrDefault方法代码示例

本文整理汇总了C#中ProfileClient.GetEnvironmentOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# ProfileClient.GetEnvironmentOrDefault方法的具体用法?C# ProfileClient.GetEnvironmentOrDefault怎么用?C# ProfileClient.GetEnvironmentOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProfileClient的用法示例。


在下文中一共展示了ProfileClient.GetEnvironmentOrDefault方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetClient

        internal IJobSubmissionClient GetClient(string cluster)
        {
            cluster.ArgumentNotNull("ClusterEndpoint");
            IJobSubmissionClient client = null;
            ProfileClient profileClient = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));

            string currentEnvironmentName = this.CurrentSubscription == null ? null : this.CurrentSubscription.Environment;

            var clientCredential = this.GetJobSubmissionClientCredentials(
                this.CurrentSubscription,
                profileClient.GetEnvironmentOrDefault(currentEnvironmentName),
                cluster,
                profileClient.Profile);
            if (clientCredential != null)
            {
                client = ServiceLocator.Instance.Locate<IAzureHDInsightJobSubmissionClientFactory>().Create(clientCredential);
                client.SetCancellationSource(this.tokenSource);
                if (this.Logger.IsNotNull())
                {
                    client.AddLogWriter(this.Logger);
                }

                return client;
            }

            throw new InvalidOperationException("Expected either a Subscription or Credential parameter.");
        }
开发者ID:shuainie,项目名称:azure-powershell,代码行数:27,代码来源:AzureHDInsightJobCommandExecutorBase.cs

示例2: GetClient

        internal IHDInsightClient GetClient()
        {
            this.CurrentSubscription.ArgumentNotNull("CurrentSubscription");

            ProfileClient client = new ProfileClient();

            var subscriptionCredentials = this.GetSubscriptionCredentials(
                this.CurrentSubscription,
                client.GetEnvironmentOrDefault(this.CurrentSubscription.Environment),
                client.Profile);

            if (this.Endpoint.IsNotNull())
            {
                subscriptionCredentials.Endpoint = this.Endpoint;               
            }

            var clientInstance = ServiceLocator.Instance.Locate<IAzureHDInsightClusterManagementClientFactory>().Create(subscriptionCredentials);
            clientInstance.SetCancellationSource(this.tokenSource);
            if (this.Logger.IsNotNull())
            {
                clientInstance.AddLogWriter(this.Logger);
            }

            return clientInstance;
        }
开发者ID:Indhukrishna,项目名称:azure-powershell,代码行数:25,代码来源:AzureHDInsightClusterCommandBase.cs

示例3: GetClient

        internal IHDInsightClient GetClient(bool ignoreSslErrors = false)
        {
            this.CurrentSubscription.ArgumentNotNull("CurrentSubscription");

            ProfileClient client = new ProfileClient(new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));

            var subscriptionCredentials = this.GetSubscriptionCredentials(
                this.CurrentSubscription,
                client.GetEnvironmentOrDefault(this.CurrentSubscription.Environment),
                client.Profile);

            if (this.Endpoint.IsNotNull())
            {
                subscriptionCredentials.Endpoint = this.Endpoint;               
            }

            var clientInstance = ServiceLocator.Instance.Locate<IAzureHDInsightClusterManagementClientFactory>().Create(subscriptionCredentials, ignoreSslErrors);
            clientInstance.SetCancellationSource(this.tokenSource);
            if (this.Logger.IsNotNull())
            {
                clientInstance.AddLogWriter(this.Logger);
            }

            return clientInstance;
        }
开发者ID:Azure,项目名称:azure-powershell,代码行数:25,代码来源:AzureHDInsightClusterCommandBase.cs

示例4: AddsAzureEnvironment

        public void AddsAzureEnvironment()
        {
            var profile = new AzureProfile();
            Mock<ICommandRuntime> commandRuntimeMock = new Mock<ICommandRuntime>();
            AddAzureEnvironmentCommand cmdlet = new AddAzureEnvironmentCommand()
            {
                CommandRuntime = commandRuntimeMock.Object,
                Name = "Katal",
                PublishSettingsFileUrl = "http://microsoft.com",
                ServiceEndpoint = "endpoint.net",
                ManagementPortalUrl = "management portal url",
                StorageEndpoint = "endpoint.net",
                GalleryEndpoint = "http://galleryendpoint.com",
                Profile = profile
            };
            cmdlet.InvokeBeginProcessing();
            cmdlet.ExecuteCmdlet();
            cmdlet.InvokeEndProcessing();

            commandRuntimeMock.Verify(f => f.WriteObject(It.IsAny<PSAzureEnvironment>()), Times.Once());
            ProfileClient client = new ProfileClient(profile);
            AzureEnvironment env = client.GetEnvironmentOrDefault("KaTaL");
            Assert.Equal(env.Name, cmdlet.Name);
            Assert.Equal(env.Endpoints[AzureEnvironment.Endpoint.PublishSettingsFileUrl], cmdlet.PublishSettingsFileUrl);
            Assert.Equal(env.Endpoints[AzureEnvironment.Endpoint.ServiceManagement], cmdlet.ServiceEndpoint);
            Assert.Equal(env.Endpoints[AzureEnvironment.Endpoint.ManagementPortalUrl], cmdlet.ManagementPortalUrl);
            Assert.Equal(env.Endpoints[AzureEnvironment.Endpoint.Gallery], "http://galleryendpoint.com");
        }
开发者ID:nityasharma,项目名称:azure-powershell,代码行数:28,代码来源:AddAzureEnvironmentTests.cs

示例5: Subscription

        internal Subscription(AzureSubscription azureSubscription)
        {
            if (azureSubscription == null)
            {
                throw new ArgumentNullException();
            }

            ProfileClient client = new ProfileClient(new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
            var environment = client.GetEnvironmentOrDefault(azureSubscription.Environment);

            this.SubscriptionName = azureSubscription.Name;
            this.SubscriptionId = azureSubscription.Id.ToString();
            this.ServiceEndpoint = new Uri(String.Format("{0}/{1}/services/systemcenter/vmm", environment.GetEndpoint(AzureEnvironment.Endpoint.ServiceManagement).TrimEnd(new[] { '/' }), SubscriptionId));
            this.Certificate = FileUtilities.DataStore.GetCertificate(azureSubscription.Account);
            this.CredentialType = CredentialType.UseCertificate;
        }
开发者ID:Azure,项目名称:azure-powershell,代码行数:16,代码来源:Subscription.cs

示例6: AzurePSCmdlet

        public AzurePSCmdlet()
        {
            DefaultProfileClient = new ProfileClient();

            if (AzureSession.CurrentContext.Subscription == null &&
               DefaultProfileClient.Profile.DefaultSubscription != null)
            {
                try
                {
                    AzureSession.SetCurrentContext(
                        DefaultProfileClient.Profile.DefaultSubscription,
                        DefaultProfileClient.GetEnvironmentOrDefault(
                            DefaultProfileClient.Profile.DefaultSubscription.Environment),
                        DefaultProfileClient.GetAccountOrNull(DefaultProfileClient.Profile.DefaultSubscription.Account));
                }
                catch
                {
                    // Ignore anything at this point
                }
            }

        }
开发者ID:Indhukrishna,项目名称:azure-powershell,代码行数:22,代码来源:AzurePSCmdlet.cs

示例7: GetCurrentEnvironmentReturnsCorrectValue

        public void GetCurrentEnvironmentReturnsCorrectValue()
        {
            MockDataStore dataStore = new MockDataStore();
            ProfileClient.DataStore = dataStore;
            ProfileClient client = new ProfileClient();

            AzureSession.SetCurrentContext(azureSubscription1, azureEnvironment, azureAccount);

            var newEnv = client.GetEnvironmentOrDefault(azureEnvironment.Name);

            Assert.Equal(azureEnvironment.Name, newEnv.Name);
        }
开发者ID:djrosanova,项目名称:azure-sdk-tools,代码行数:12,代码来源:ProfileClientTests.cs

示例8: GetAzureEnvironmentReturnsCorrectValue

        public void GetAzureEnvironmentReturnsCorrectValue()
        {
            MockDataStore dataStore = new MockDataStore();
            ProfileClient.DataStore = dataStore;
            ProfileClient client = new ProfileClient();
            client.AddOrSetEnvironment(azureEnvironment);

            Assert.Equal(EnvironmentName.AzureCloud, AzureSession.CurrentContext.Environment.Name);

            var defaultEnv = client.GetEnvironmentOrDefault(null);

            Assert.Equal(EnvironmentName.AzureCloud, defaultEnv.Name);

            var newEnv = client.GetEnvironmentOrDefault(azureEnvironment.Name);

            Assert.Equal(azureEnvironment.Name, newEnv.Name);

            Assert.Throws<ArgumentException>(() => client.GetEnvironmentOrDefault("bad"));
        }
开发者ID:djrosanova,项目名称:azure-sdk-tools,代码行数:19,代码来源:ProfileClientTests.cs

示例9: GetStorageAccountWithAzureEnvironment

        /// <summary>
        /// Get storage account and use specific azure environment
        /// </summary>
        /// <param name="credential">Storage credential</param>
        /// <param name="storageAccountName">Storage account name, it's used for build end point</param>
        /// <param name="useHttps">Use secure Http protocol</param>
        /// <param name="azureEnvironmentName">Environment name</param>
        /// <returns>A storage account</returns>
        internal CloudStorageAccount GetStorageAccountWithAzureEnvironment(StorageCredentials credential,
            string storageAccountName, bool useHttps, string azureEnvironmentName = "")
        {
            AzureEnvironment azureEnvironment = null;

            if (null != SMProfile)
            {
                if (DefaultContext != null && string.IsNullOrEmpty(azureEnvironmentName))
                {
                    azureEnvironment = DefaultContext.Environment;

                    if (null == azureEnvironment)
                    {
                        azureEnvironmentName = EnvironmentName.AzureCloud;
                    }
                }

                if(null == azureEnvironment)
                {
                    try
                    {
                        var profileClient = new ProfileClient(SMProfile);
                        azureEnvironment = profileClient.GetEnvironmentOrDefault(azureEnvironmentName);
                    }
                    catch(ArgumentException e)
                    {
                        throw new ArgumentException(e.Message + " " + string.Format(CultureInfo.CurrentCulture, Resources.ValidEnvironmentName, EnvironmentName.AzureCloud, EnvironmentName.AzureChinaCloud));
                    }
                }

            }

            if (null != azureEnvironment)
            {
                try
                {
                    Uri blobEndPoint = azureEnvironment.GetStorageBlobEndpoint(storageAccountName, useHttps);
                    Uri queueEndPoint = azureEnvironment.GetStorageQueueEndpoint(storageAccountName, useHttps);
                    Uri tableEndPoint = azureEnvironment.GetStorageTableEndpoint(storageAccountName, useHttps);
                    Uri fileEndPoint = azureEnvironment.GetStorageFileEndpoint(storageAccountName, useHttps);

                    return new CloudStorageAccount(credential, blobEndPoint, queueEndPoint, tableEndPoint, fileEndPoint);
                }
                catch (ArgumentNullException)
                {
                    // the environment may not have value for StorageEndpointSuffix, in this case, we'll still use the default domain of "core.windows.net"
                }
            }
            
            return GetStorageAccountWithEndPoint(credential, storageAccountName, useHttps, Resources.DefaultDomain);
        }
开发者ID:injyzarif,项目名称:azure-powershell,代码行数:59,代码来源:NewAzureStorageContext.cs

示例10: GetCurrentEnvironmentReturnsCorrectValue

        public void GetCurrentEnvironmentReturnsCorrectValue()
        {
            MemoryDataStore dataStore = new MemoryDataStore();
            AzureSession.DataStore = dataStore;
            ProfileClient client = new ProfileClient(currentProfile);

            client.AddOrSetEnvironment(azureEnvironment);
            client.AddOrSetAccount(azureAccount);
            client.AddOrSetSubscription(azureSubscription1);

            currentProfile.DefaultSubscription = azureSubscription1;

            var newEnv = client.GetEnvironmentOrDefault(azureEnvironment.Name);

            Assert.Equal(azureEnvironment.Name, newEnv.Name);
        }
开发者ID:Azure,项目名称:azure-powershell,代码行数:16,代码来源:ProfileClientTests.cs

示例11: GetStorageAccountWithAzureEnvironment

        /// <summary>
        /// Get storage account and use specific azure environment
        /// </summary>
        /// <param name="credential">Storage credential</param>
        /// <param name="storageAccountName">Storage account name, it's used for build end point</param>
        /// <param name="useHttps">Use secure Http protocol</param>
        /// <param name="azureEnvironmentName">Environment name</param>
        /// <returns>A storage account</returns>
        internal CloudStorageAccount GetStorageAccountWithAzureEnvironment(StorageCredentials credential,
            string storageAccountName, bool useHttps, string azureEnvironmentName = "")
        {
            AzureEnvironment azureEnvironment = null;
            
            if (string.IsNullOrEmpty(azureEnvironmentName))
            {
                azureEnvironment = Profile.Context.Environment;
            }
            else
            {
                try
                {
                    var profileClient = new ProfileClient(Profile);
                    azureEnvironment = profileClient.GetEnvironmentOrDefault(azureEnvironmentName);
                }
                catch (ArgumentException e)
                {
                    throw new ArgumentException(e.Message + " " + string.Format(CultureInfo.CurrentCulture, Resources.ValidEnvironmentName, EnvironmentName.AzureCloud, EnvironmentName.AzureChinaCloud)); 
                }
            }

            Uri blobEndPoint = azureEnvironment.GetStorageBlobEndpoint(storageAccountName, useHttps);
            Uri queueEndPoint = azureEnvironment.GetStorageQueueEndpoint(storageAccountName, useHttps);
            Uri tableEndPoint = azureEnvironment.GetStorageTableEndpoint(storageAccountName, useHttps);
            Uri fileEndPoint = azureEnvironment.GetStorageFileEndpoint(storageAccountName, useHttps);

            return new CloudStorageAccount(credential, blobEndPoint, queueEndPoint, tableEndPoint, fileEndPoint);
        }
开发者ID:shuainie,项目名称:azure-powershell,代码行数:37,代码来源:NewAzureStorageContext.cs


注:本文中的ProfileClient.GetEnvironmentOrDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。