Пример #1
0
        /// <summary>
        /// Converts the response from the service to a powershell Secondary Link object
        /// </summary>
        /// <param name="resourceGroupName">The name of the Resource Group containing the primary database</param>
        /// <param name="serverName">The name of the Azure SQL Server containing the primary database</param>
        /// <param name="databaseName">The name of primary database</param>
        /// <param name="partnerResourceGroupName">The name of the Resource Group containing the secondary database</param>
        /// <param name="linkId">The linkId of the replication link to the secondary</param>
        /// <param name="response">The replication link response</param>
        /// <returns>The Azure SQL Database ReplicationLink object</returns>
        private AzureReplicationLinkModel CreateReplicationLinkModelFromResponse(string resourceGroupName, string serverName, string databaseName, string partnerResourceGroupName, Management.Sql.Models.ReplicationLink resp)
        {
            // partnerResourceGroupName is required because it is not exposed in any reponse from the service.
            // AllowConnections.ReadOnly is not yet supported
            AllowConnections allowConnections = (resp.Role.ToString().Equals(Management.Sql.Models.CreateMode.Secondary) ||
                                                 resp.PartnerRole.ToString().Equals(Management.Sql.Models.CreateMode.Secondary)) ? AllowConnections.All : AllowConnections.No;

            AzureReplicationLinkModel model = new AzureReplicationLinkModel();

            model.LinkId = new Guid(resp.Name);
            model.PartnerResourceGroupName = partnerResourceGroupName;
            model.PartnerServerName        = resp.PartnerServer;
            model.PartnerDatabaseName      = resp.PartnerDatabase;
            model.ResourceGroupName        = resourceGroupName;
            model.ServerName       = serverName;
            model.DatabaseName     = databaseName;
            model.AllowConnections = allowConnections;
            model.Location         = resp.Location;
            model.PartnerLocation  = resp.PartnerLocation;
            model.PercentComplete  = resp.PercentComplete.ToString();
            model.ReplicationState = resp.ReplicationState;
            model.PartnerRole      = resp.PartnerRole.ToString();
            model.Role             = resp.Role.ToString();
            model.StartTime        = resp.StartTime.ToString();

            return(model);
        }
        public CspOptions BuildCspOptions()
        {
            _options.Script = AllowScripts.BuildOptions();
            _options.Style  = AllowStyles.BuildOptions();
#pragma warning disable CS0618 // Type or member is obsolete
            _options.Child = AllowChildren.BuildOptions();
#pragma warning restore CS0618 // Type or member is obsolete
            _options.Connect        = AllowConnections.BuildOptions();
            _options.Manifest       = AllowManifest.BuildOptions();
            _options.Default        = ByDefaultAllow.BuildOptions();
            _options.Font           = AllowFonts.BuildOptions();
            _options.FormAction     = AllowFormActions.BuildOptions();
            _options.FrameAncestors = AllowFraming.BuildOptions();
            _options.Img            = AllowImages.BuildOptions();
            _options.Media          = AllowAudioAndVideo.BuildOptions();
            Tuple <CspObjectSrcOptions, CspPluginTypesOptions> pluginOptions = AllowPlugins.BuildOptions();
            _options.Object          = pluginOptions.Item1;
            _options.PluginTypes     = pluginOptions.Item2;
            _options.Sandbox         = _sandboxBuilder.BuildOptions();
            _options.Frame           = AllowFrames.BuildOptions();
            _options.Worker          = AllowWorkers.BuildOptions();
            _options.Prefetch        = AllowPrefetch.BuildOptions();
            _options.BaseUri         = AllowBaseUri.BuildOptions();
            _options.RequireSri      = RequireSri.BuildOptions();
            _options.OnSendingHeader = OnSendingHeader;
            return(_options);
        }
        public CspOptions BuildCspOptions()
        {
            _options.Script         = AllowScripts.BuildOptions();
            _options.Style          = AllowStyles.BuildOptions();
            _options.Child          = AllowChildren.BuildOptions();
            _options.Connect        = AllowConnections.BuildOptions();
            _options.Default        = ByDefaultAllow.BuildOptions();
            _options.Font           = AllowFonts.BuildOptions();
            _options.FormAction     = AllowFormActions.BuildOptions();
            _options.FrameAncestors = AllowFraming.BuildOptions();
            _options.Img            = AllowImages.BuildOptions();
            _options.Media          = AllowAudioAndVideo.BuildOptions();
            Tuple <CspObjectSrcOptions, CspPluginTypesOptions> pluginOptions = AllowPlugins.BuildOptions();

            _options.Object      = pluginOptions.Item1;
            _options.PluginTypes = pluginOptions.Item2;
            _options.Sandbox     = _sandboxBuilder.BuildOptions();
            return(_options);
        }