DeploymentSyncOptions.Rules 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得與目前物件實例相關聯的 物件集合 DeploymentRule 。
public:
property Microsoft::Web::Deployment::DeploymentRuleCollection ^ Rules { Microsoft::Web::Deployment::DeploymentRuleCollection ^ get(); };
public Microsoft.Web.Deployment.DeploymentRuleCollection Rules { get; }
member this.Rules : Microsoft.Web.Deployment.DeploymentRuleCollection
Public ReadOnly Property Rules As DeploymentRuleCollection
屬性值
, DeploymentRuleCollection 包含 DeploymentRule 與目前物件實例相關聯的物件。
範例
下列範例會藉由呼叫靜態方法來 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());
}
}
}