DeploymentSyncOptions 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
| DeploymentSyncOptions() |
建立 DeploymentSyncOptions 的執行個體。 |
| DeploymentSyncOptions(SerializationInfo, StreamingContext) |
DeploymentSyncOptions()
建立 DeploymentSyncOptions 的執行個體。
public:
DeploymentSyncOptions();
public DeploymentSyncOptions ();
Public Sub New ()
範例
下列範例會藉由呼叫靜態方法來 GetAvailableRules 實作 類別 DeploymentSyncOptions ,以取得將套用至同步作業的目前可用規則。 DeploymentSyncOptions實例接著會修改屬性: WhatIf 和 UseChecksum 。
注意 屬性 WhatIf 可讓您執行試用版同步,以判斷同步作業的可能性,並提供與 實例 DeploymentChangeSummary 一起使用時可能發生的變更度量。
using System;
using Microsoft.Web.Deployment;
namespace MSDeploy.Web.Deployment
{
class Program
{
static void Main(string[] args)
{
// List currently available rules
foreach(DeploymentRule rule in
DeploymentSyncOptions.GetAvailableRules())
{
Console.WriteLine("Description: " + rule.Description);
Console.WriteLine("ExampleOrDetail: " + rule.ExampleOrDetail);
Console.WriteLine("FriendlyName: " + rule.FriendlyName);
Console.WriteLine("Name: " + rule.Name);
Console.WriteLine("Handler: " +
rule.RuleHandler.ToString());
Console.WriteLine();
}
DeploymentSyncOptions syncOptions = new DeploymentSyncOptions();
syncOptions.WhatIf = true; // report expected results of
// syncing without performing a sync operation
syncOptions.UseChecksum = true; // compare files through
// checksum to determine if they should be synced
DeploymentBaseOptions sourceBaseOptions =
new DeploymentBaseOptions();
DeploymentBaseOptions destinationBaseOptions =
new DeploymentBaseOptions();
DeploymentObject deploymentObject =
DeploymentManager.CreateObject(
DeploymentWellKnownProvider.AppHostConfig,
"Default Web Site", sourceBaseOptions);
DeploymentChangeSummary changes =
deploymentObject.SyncTo(
DeploymentWellKnownProvider.AppHostConfig,
"Default Web Site2", destinationBaseOptions,
syncOptions);
Console.WriteLine("Added: " +
changes.ObjectsAdded.ToString());
Console.WriteLine("Updated: " +
changes.ObjectsUpdated.ToString());
Console.WriteLine("Deleted: " +
changes.ObjectsDeleted.ToString());
Console.WriteLine("Errors: " +
changes.Errors.ToString());
}
}
}
適用於
DeploymentSyncOptions(SerializationInfo, StreamingContext)
protected:
DeploymentSyncOptions(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected DeploymentSyncOptions (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new Microsoft.Web.Deployment.DeploymentSyncOptions : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> Microsoft.Web.Deployment.DeploymentSyncOptions
Protected Sub New (info As SerializationInfo, context As StreamingContext)
參數
- info
- SerializationInfo
- context
- StreamingContext