SyncFolderHierarchyType クラス

定義

クラスはSyncFolderHierarchyType、クライアント フォルダー階層を 2007 年Microsoft Exchange Server実行しているコンピューターと同期する要求を表します。

public ref class SyncFolderHierarchyType : ExchangeWebServices::BaseRequestType
public class SyncFolderHierarchyType : ExchangeWebServices.BaseRequestType
Public Class SyncFolderHierarchyType
Inherits BaseRequestType
継承
SyncFolderHierarchyType

次の例では、フォルダー階層を同期する方法を示します。 プロパティが SyncState 設定されているため、このフォルダー階層は以前に同期されています。 この SyncFolderHierarchy 操作は、 プロパティによって表される同期呼び出し以降に行われたすべての変更を SyncState 返します。 この呼び出しは、フォルダー図形によって定義されているすべてのプロパティを AllProperties 返します。

static void SyncFolderHierarchy(ExchangeServiceBinding esb)
{ 
    // Create the request.
    SyncFolderHierarchyType <span class="label">request</span> = new SyncFolderHierarchyType();

    // Identify the properties that are synchronized.
    FolderResponseShapeType shape = new FolderResponseShapeType();
    shape.BaseShape = DefaultShapeNamesType.AllProperties;

    // Add synchronized properties to request.
<span class="label">request</span>.FolderShape = shape;

    // Add the synchronization state to the request. This
    // property should be null for the initial synchronization.
<span class="label">request</span>.SyncState = "H4sIAAAAAAAEAO29B2AcSZYlJi9tynt/";

    // Send the request and get the response.
    SyncFolderHierarchyResponseType response = esb.SyncFolderHierarchy(<span class="label">request</span>);

    ArrayOfResponseMessagesType aormt = response.ResponseMessages;
    ResponseMessageType[] rmta = aormt.Items;

    foreach (ResponseMessageType rmt in rmta)
    {
        if (rmt.ResponseClass == ResponseClassType.Success)
        {
            SyncFolderHierarchyResponseMessageType sfhrmt = rmt as SyncFolderHierarchyResponseMessageType;

            // Get the sync state string to use in later synchronization calls.
            string syncState = sfhrmt.SyncState;

            // Get the array of changes that are returned in the response. 
            SyncFolderHierarchyChangesType changeArray = sfhrmt.Changes;

            // This contains the array of folder changes.
            object[] changes = changeArray.Items;

            // This identifies the type of change that occurred on a folder.
            ItemsChoiceType1 changeType; 

            for (int count = 0; count &lt; changes.Length; count++)
            {
                // This identifies the type of change that is represented by the objects
                // in the changes object[].
                changeType = changeArray.ItemsElementName[count];

                // Check for the change type of each folder that is returned in the response.
                switch (changeType)
                { 
                    case ItemsChoiceType1.Create:
                        SyncFolderHierarchyCreateOrUpdateType createdFolder = changes[count] as SyncFolderHierarchyCreateOrUpdateType;
                        // TODO: Handle the created folder.
                        if (createdFolder.Item is CalendarFolderType)
                        {
                            // TODO: Cast to calendar folder and handle properties.
                        }
                        else;
                            // TODO: Check and cast to SearchFolderType, TasksFolderType,
                            //       ContactsFolderType, or FolderType.
                        break;

                    case ItemsChoiceType1.Update:
                        SyncFolderHierarchyCreateOrUpdateType updatedFolder = changes[count] as SyncFolderHierarchyCreateOrUpdateType; ;
                        // TODO: Handle the updated folder.    
                        // TODO: Check and cast to one of the five folder types.
                        break;

                    case ItemsChoiceType1.Delete:
                        SyncFolderHierarchyDeleteType deletedFolder = changes[count] as SyncFolderHierarchyDeleteType;
                        // TODO: Get the identifier of the deleted folder.
                        break;
                }
            }
        }
    }
}

応答で返されるプロパティは SyncState 、後の同期要求に対して保存する必要があります。 また、クライアント アプリケーションが各フォルダーの種類で使用できるすべてのプロパティにアクセスできるように、応答で返されるフォルダーを適切なフォルダーの種類にキャストする必要があることにも注意してください。

重要: 更新プログラムが返される場合、クライアント アプリケーションは、応答内のフォルダーとクライアント上のフォルダーの違いを比較して、発生した変更を判断する必要があります。

すべての変更オブジェクトに同じ基本型がないため、オブジェクト配列が返されます。

注釈

各フォルダー内の項目を同期するには、プロキシ オブジェクトを SyncFolderItemsType 使用します。

コンストラクター

SyncFolderHierarchyType()

コンストラクターは SyncFolderHierarchyType 、 クラスの新しいインスタンスを SyncFolderHierarchyType 初期化します。

プロパティ

FolderShape

プロパティは FolderShape 、応答で返されるプロパティを示す同期フォルダー図形を取得または設定します。 このプロパティは必須です。 これは、読み取り/書き込みプロパティです。

SyncFolderId

プロパティは SyncFolderId 、同期する項目を含むフォルダーの ID を取得または設定します。 このプロパティは省略可能です。 これは、読み取り/書き込みプロパティです。

SyncState

プロパティは SyncState 、同期状態識別子を取得または設定します。 このプロパティは省略可能で、注意が必要です。 これは、読み取り/書き込みプロパティです。

適用対象