Esempio n. 1
0
        public PublishContext(
            ServiceSettings settings,
            string packagePath,
            string configPath,
            string serviceName,
            string deploymentName,
            string rootPath)
        {
            Validate.ValidateNullArgument(settings, Resources.InvalidServiceSettingMessage);
            Validate.ValidateStringIsNullOrEmpty(packagePath, "packagePath");
            Validate.ValidateFileFull(configPath, Resources.ServiceConfiguration);
            Validate.ValidateStringIsNullOrEmpty(serviceName, "serviceName");

            this.ServiceSettings = settings;
            this.PackagePath     = packagePath;
            this.ConfigPath      = configPath;
            this.RootPath        = rootPath;
            this.ServiceName     = serviceName;
            this.DeploymentName  = string.IsNullOrEmpty(deploymentName) ?
                                   char.ToLower(ServiceSettings.Slot[0]) + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss-ffff")
                : deploymentName;

            if (!string.IsNullOrEmpty(settings.Subscription))
            {
                GlobalSettingsManager globalSettingsManager = GlobalSettingsManager.Load(GlobalPathInfo.GlobalSettingsDirectory);
                SubscriptionId = globalSettingsManager.GetSubscriptionId(settings.Subscription);
            }
            else
            {
                throw new ArgumentNullException("settings.Subscription", Resources.InvalidSubscriptionNameMessage);
            }
        }