[Serializable] public class 事件參數 : ExternalDataEventArgs { private string 存值; public string 自訂屬性 { get { return this.存值; } set { this.存值 = value; } } public 事件參數() : base(Guid.NewGuid()) { } public 事件參數(Guid instanceId, string 值參數) : base(instanceId) { this.存值 = 值參數; } } [ExternalDataExchangeAttribute()] public interface 外來事件介面 { event EventHandler<事件參數> 一個外來事件; } public class 實作類別 : 外來事件介面 { public event EventHandler<事件參數> 一個外來事件; public void 觸發事件(Guid instanceId, string 值參數, IIdentity 使用者參數) { 事件參數 e = new 事件參數(instanceId,值參數); String 安全標置 = null; WindowsIdentity 使用者 = 使用者參數 as WindowsIdentity; if (使用者 != null && 使用者.User != null) { 安全標置 = 使用者.User.Translate(typeof(NTAccount)).ToString(); } else if (使用者參數 != null) { 安全標置 = 使用者參數.Name; } e.Identity = 安全標置; Console.WriteLine("外來事件已執行,使用者:", 使用者參數.Name); if (一個外來事件 != null) { 一個外來事件("sender:wxwinter", e); } } } |