/// <summary>
        /// Loads an operations session using the ServiceModel file located at the specified path
        /// </summary>
        /// <param name="serviceModel">The path to the service model file</param>
        /// <param name="tokenStore">The path to the directory that holds Azure Tokens</param>
        /// <returns></returns>
        public static OperationsSession Load(string serviceModel, string azureTokenStore)
        {
            // We want to throw FileNotFound if the service model doesn't exist
            if (!File.Exists(serviceModel))
            {
                throw new FileNotFoundException(String.Format(
                                                    CultureInfo.CurrentCulture,
                                                    Strings.OperationsSession_ServiceModelDoesNotExist,
                                                    serviceModel));
            }

            var model  = XmlServiceModelDeserializer.LoadAppModel(serviceModel);
            var tokens = new AzureTokenManager(azureTokenStore);

            // Resolve relative paths
            var configTemplateRefs = model
                                     .Environments
                                     .Select(e => e.ConfigTemplates)
                                     .Where(t => t != null && String.Equals(t.Type, FileSystemConfigTemplateSource.RelativeAppModelType));

            foreach (var configTemplateRef in configTemplateRefs)
            {
                configTemplateRef.Value = Path.Combine(
                    Path.GetDirectoryName(serviceModel),
                    configTemplateRef.Value);
                configTemplateRef.Type = FileSystemConfigTemplateSource.AbsoluteAppModelType;
            }

            return(new OperationsSession(model, tokens));
        }
        /// <summary>
        /// Loads an operations session using the ServiceModel file located at the specified path
        /// </summary>
        /// <param name="serviceModel">The path to the service model file</param>
        /// <param name="tokenStore">The path to the directory that holds Azure Tokens</param>
        /// <returns></returns>
        public static OperationsSession Load(string serviceModel, string azureTokenStore)
        {
        // We want to throw FileNotFound if the service model doesn't exist
            if (!File.Exists(serviceModel))
            {
                throw new FileNotFoundException(String.Format(
                    CultureInfo.CurrentCulture,
                    Strings.OperationsSession_ServiceModelDoesNotExist,
                    serviceModel));
            }

            var model = XmlServiceModelDeserializer.LoadServiceModel(serviceModel);
            var tokens = new AzureTokenManager(azureTokenStore);
            return new OperationsSession(model, tokens);
        }
 public OperationsSession(AppModel model, AzureTokenManager azureTokens)
 {
     Model = model;
     AzureTokens = azureTokens;
     Environments = Model.Environments.ToDictionaryByFirstItemWithKey(e => e.Name, StringComparer.OrdinalIgnoreCase);
 }
 public OperationsSession(AppModel model, AzureTokenManager azureTokens)
 {
     Model        = model;
     AzureTokens  = azureTokens;
     Environments = Model.Environments.ToDictionaryByFirstItemWithKey(e => e.Name, StringComparer.OrdinalIgnoreCase);
 }
        /// <summary>
        /// Loads an operations session using the ServiceModel file located at the specified path
        /// </summary>
        /// <param name="serviceModel">The path to the service model file</param>
        /// <param name="tokenStore">The path to the directory that holds Azure Tokens</param>
        /// <returns></returns>
        public static OperationsSession Load(string serviceModel, string azureTokenStore)
        {
        // We want to throw FileNotFound if the service model doesn't exist
            if (!File.Exists(serviceModel))
            {
                throw new FileNotFoundException(String.Format(
                    CultureInfo.CurrentCulture,
                    Strings.OperationsSession_ServiceModelDoesNotExist,
                    serviceModel));
            }

            var model = XmlServiceModelDeserializer.LoadAppModel(serviceModel);
            var tokens = new AzureTokenManager(azureTokenStore);

            // Resolve relative paths
            var configTemplateRefs = model
                .Environments
                .Select(e => e.ConfigTemplates)
                .Where(t => t != null && String.Equals(t.Type, FileSystemConfigTemplateSource.RelativeAppModelType));
            foreach (var configTemplateRef in configTemplateRefs)
            {
                configTemplateRef.Value = Path.Combine(
                    Path.GetDirectoryName(serviceModel),
                    configTemplateRef.Value);
                configTemplateRef.Type = FileSystemConfigTemplateSource.AbsoluteAppModelType;
            }

            return new OperationsSession(model, tokens);
        }