public void Clear()
 {
     _contexts.Clear();
     EnvironmentTable.Clear();
     SubscriptionTable.Clear();
     AccountTable.Clear();
 }
Exemplo n.º 2
0
        private void Initialize(AzureRmProfile profile)
        {
            EnvironmentTable.Clear();
            // Adding predefined environments
            foreach (var env in AzureEnvironment.PublicEnvironments)
            {
                EnvironmentTable[env.Key] = env.Value;
            }

            Contexts.Clear();
            DefaultContextKey = "Default";
            if (profile != null)
            {
                foreach (var environment in profile.EnvironmentTable)
                {
                    EnvironmentTable[environment.Key] = environment.Value;
                }

                foreach (var context in profile.Contexts)
                {
                    this.Contexts.Add(context.Key, context.Value);
                }

                DefaultContextKey = profile.DefaultContextKey ?? (profile.Contexts.Any() ? null : "Default");
            }
        }
Exemplo n.º 3
0
        private void Initialize(AzureRmProfile profile)
        {
            EnvironmentTable.Clear();
            // Adding predefined environments
            foreach (var env in AzureEnvironment.PublicEnvironments)
            {
                EnvironmentTable[env.Key] = env.Value;
            }

            Contexts.Clear();
            DefaultContextKey = "Default";
            if (profile != null)
            {
                foreach (var environment in profile.EnvironmentTable)
                {
                    EnvironmentTable[environment.Key] = environment.Value;
                }

                foreach (var context in profile.Contexts)
                {
                    context.Value.TokenCache = AzureSession.Instance.TokenCache;
                    this.Contexts.Add(context.Key, context.Value);
                }

                DefaultContextKey = profile.DefaultContextKey ?? "Default";
            }
        }
Exemplo n.º 4
0
        private void Load(string path)
        {
            this.ProfilePath = path;

            if (!AzureSession.Instance.DataStore.DirectoryExists(AzureSession.Instance.ProfileDirectory))
            {
                AzureSession.Instance.DataStore.CreateDirectory(AzureSession.Instance.ProfileDirectory);
            }

            if (AzureSession.Instance.DataStore.FileExists(ProfilePath))
            {
                string         contents   = AzureSession.Instance.DataStore.ReadFileAsText(ProfilePath);
                var            oldProfile = JsonConvert.DeserializeObject <LegacyAzureRmProfile>(contents);
                AzureRmProfile profile;
                if (!oldProfile.TryConvert(out profile))
                {
                    profile = JsonConvert.DeserializeObject <IAzureContextContainer>(contents, new AzureRmProfileConverter()) as AzureRmProfile;
                }
                Debug.Assert(profile != null);
                EnvironmentTable.Clear();
                foreach (var environment in profile.EnvironmentTable)
                {
                    EnvironmentTable[environment.Key] = environment.Value;
                }

                Contexts.Clear();
                foreach (var context in profile.Contexts)
                {
                    this.Contexts.Add(context.Key, context.Value);
                }
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Set the contaienr to its defautl state
 /// </summary>
 public void Clear()
 {
     Contexts.Clear();
     DefaultContext = new AzureContext();
     EnvironmentTable.Clear();
     foreach (var environment in AzureEnvironment.PublicEnvironments)
     {
         EnvironmentTable.Add(environment.Key, environment.Value);
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Set the contaienr to its default state
        /// </summary>
        public void Clear()
        {
            this.GetTokenCache()?.Clear();
            Contexts.Clear();
            DefaultContextKey = "Default";
            DefaultContext    = new AzureContext();
            EnvironmentTable.Clear();
            foreach (var environment in AzureEnvironment.PublicEnvironments)
            {
                EnvironmentTable.Add(environment.Key, environment.Value);
            }

            AzureRmProfileProvider.Instance.SetTokenCacheForProfile(this);
        }