Esempio n. 1
0
        public static SubscriptionsManager Import(string subscriptionsDataFile, PublishData publishSettings, X509Certificate2 certificate)
        {
            var subscriptionsManager = new SubscriptionsManager();
            if (File.Exists(subscriptionsDataFile))
            {
                subscriptionsManager.ImportSubscriptionsFile(subscriptionsDataFile, certificate);
            }

            if (publishSettings != null)
            {
                foreach (var subscription in publishSettings.Items.Single().Subscription)
                {
                    var subscriptionData = subscriptionsManager.Subscriptions.ContainsKey(subscription.Name)
                        ? subscriptionsManager.Subscriptions[subscription.Name]
                        : new SubscriptionData { SubscriptionName = subscription.Name };

                    subscriptionData.SubscriptionId = subscription.Id;
                    subscriptionData.Certificate = certificate;
                    subscriptionData.ServiceEndpoint = publishSettings.Items.Single().Url;

                    subscriptionsManager.Subscriptions[subscriptionData.SubscriptionName] = subscriptionData;
                }
            }

            return subscriptionsManager;
        }
        public static SubscriptionsManager Import(string subscriptionsDataFile, PublishData publishSettings, X509Certificate2 certificate)
        {
            var subscriptionsManager = new SubscriptionsManager();
            if (File.Exists(subscriptionsDataFile))
            {
                subscriptionsManager.ImportSubscriptionsFile(subscriptionsDataFile, certificate);
            }

            if (publishSettings != null)
            {
                foreach (var subscription in publishSettings.Items.Single().Subscription)
                {
                    var subscriptionData = subscriptionsManager.Subscriptions.ContainsKey(subscription.Name)
                        ? subscriptionsManager.Subscriptions[subscription.Name]
                        : new SubscriptionData { SubscriptionName = subscription.Name };

                    subscriptionData.SubscriptionId = subscription.Id;
                    if (!string.IsNullOrEmpty(subscription.ManagementCertificate))
                    {
                        subscriptionData.Certificate = new X509Certificate2(Convert.FromBase64String(subscription.ManagementCertificate), string.Empty);
                    }
                    else
                    {
                        subscriptionData.Certificate = certificate;
                    }

                    if (!string.IsNullOrEmpty(subscription.ServiceManagementUrl))
                    {
                        subscriptionData.ServiceEndpoint = subscription.ServiceManagementUrl;
                    }
                    else
                    {
                        subscriptionData.ServiceEndpoint = publishSettings.Items.Single().Url;
                    }

                    subscriptionsManager.Subscriptions[subscriptionData.SubscriptionName] = subscriptionData;
                }
            }

            return subscriptionsManager;
        }