PeerObject 類別


代表 PeerObject 類別的新執行個體,該執行個體將具有自動產生的 GuidRepresents a new instance of the PeerObject class with an auto-generated Guid.

public ref class PeerObject : IDisposable, IEquatable<System::Net::PeerToPeer::Collaboration::PeerObject ^>, System::Runtime::Serialization::ISerializable
public class PeerObject : IDisposable, IEquatable<System.Net.PeerToPeer.Collaboration.PeerObject>, System.Runtime.Serialization.ISerializable
type PeerObject = class
    interface IDisposable
    interface IEquatable<PeerObject>
    interface ISerializable
Public Class PeerObject
Implements IDisposable, IEquatable(Of PeerObject), ISerializable


PeerObject 是執行時間資料,例如圖片、憑證,或與特定應用程式相關聯的特定描述。A PeerObject is run-time data, such as a picture, certificate, or a specific description that is associated with a particular application. 每個 PeerObject 實例的資料元素都必須小於或等於16KB 的大小。The data element of each PeerObject instance must be less than or equal to 16KB in size. 在結構化 PeerObject 的實例之後,它會透過對等共同作業基礎結構發佈 SetObjectAfter an instance of PeerObject is constructed it is published with the Peer Collaboration Infrastructure via SetObject.

在建立這個類別的實例並設定適當的屬性之後,這個物件可以傳遞至 PeerCollaboration SetObjectDeleteObject 方法,以啟用/停用此物件的發行,供其他對等電腦探索和查看。After constructing an instance of this class and setting the appropriate properties this object may be passed to the PeerCollaborationSetObject and DeleteObject methods to enable/disable the publishing of this object for other peers to discover and view.

向共同作業基礎結構註冊物件之後,註冊資訊不會保存在登錄中,因此會導致實例發生不同的行為 PeerApplicationAfter registering an object with the collaboration infrastructure the registration information is not persisted in the registry, resulting in different behavior from PeerApplication instances. 物件註冊僅適用于已註冊物件之應用程式的存留期。The object registration is only valid for the lifetime duration of the application which registered the object. 應用程式應該在不再需要或應用程式結束之前,取消註冊物件。Applications should unregister objects when they are no longer required or prior to application exit. 根據預設,如果實例超出範圍,則會自動取消註冊 PeerObject。By default, a PeerObject is automatically unregistered if the instance goes out of scope.

在使用註冊方法註冊 PeerObject 實例後變更其屬性, PeerCollaboration 並不會更新 PeerObject 實例的註冊。Changing the properties on a PeerObject instance after it has been registered using the PeerCollaboration registration methods will not update the registration for the PeerObject instance. 若要有效地更新特定 PeerObject 實例的註冊,必須刪除 PeerObject,並使用新資訊重新註冊。To effectively update the registration of a specific PeerObject instance, the PeerObject must be deleted and registered again with the new information.



初始化 PeerObject 類別的新預設執行個體。Initializes a new default instance of the PeerObject class.

PeerObject(Guid, Byte[], PeerScope)

使用相關聯的範圍和資料,初始化新的 PeerObject 執行個體。Initializes a new PeerObject instance with the associated scope and data.

PeerObject(SerializationInfo, StreamingContext)

使用序列化 (Serialization) 所需的相關參數,初始化新的 PeerObject 執行個體。Initializes a new PeerObject instance with the associated parameters required for serialization.



取得或設定描述性資料,此資料與對等共同作業應用程式的 PeerObject 執行個體相關聯。Gets or sets descriptive data associated with the PeerObject instance for a Peer Collaboration application.


取得或設定與 Guid 執行個體關聯的 PeerObjectGets or sets a Guid associated with the PeerObject instance.


取得或設定 PeerScope 執行個體要註冊的 PeerObjectGets or sets the PeerScope in which the PeerObject instance is registered.


取得或設定物件,用於封送處理因 PeerObject 執行個體變更而發出的事件處理常式呼叫。Gets or sets the object used to marshal the event handler calls that are issued as a result of a PeerObject instance change.



釋放 PeerObject 所使用的所有資源。Releases all resources utilized by the PeerObject.


釋放 PeerObject 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。Releases the unmanaged resources used by the PeerObject and optionally releases the managed resources.


PeerObject 與指定的物件相比較。Compares the PeerObject to the specified object.

Equals(Object, Object)

判斷指定的 PeerObject 執行個體是否視為相等。Determines whether the specified PeerObject instances are considered equal.


比較 PeerObject 和指定的 PeerObject 執行個體。Compares a PeerObject to the specified PeerObject instance.


傳回 PeerObject 執行個體的雜湊程式碼。Returns the hash code for the PeerObject instance.

GetObjectData(SerializationInfo, StreamingContext)

將序列化指定之 SerializationInfo 所需的資料,填入 PeerObjectPopulates a SerializationInfo with the data required to serialize the specified PeerObject.


取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)

當遠端對等電腦加入、更新或移除具有指定 ID 的 PeerObject 執行個體時發出信號。Signaled when a PeerObject instance with the specified ID is added, updated or removed by a remote peer.


傳回代表 PeerObject 執行個體的 StringReturns a String that represents a PeerObject instance.



會在 PeerObject 執行個體變更時收到信號。Signaled when a PeerObject instance changes.


ISerializable.GetObjectData(SerializationInfo, StreamingContext)

將從已序列化之資料來源取得的資料填入目前的 PeerObject 執行個體。Populates the current PeerObject instance with the data obtained from the serialized source.