private void AddServiceAsync(ServiceName serviceName, AddServiceCompletedEventHandler callback) { if (NSMessageHandler.MSNTicket == MSNTicket.Empty || AddressBook == null) { OnServiceOperationFailed(this, new ServiceOperationFailedEventArgs("AddService", new MSNPSharpException("You don't have access right on this action anymore."))); } else { AddServiceRequestType r = new AddServiceRequestType(); r.serviceInfo = new InfoType(); r.serviceInfo.Handle = new HandleType(); r.serviceInfo.Handle.Type = serviceName; r.serviceInfo.Handle.ForeignId = String.Empty; r.serviceInfo.InverseRequired = true; MsnServiceState addServiceObject = new MsnServiceState(PartnerScenario.CircleSave, "AddService", true); SharingServiceBinding abService = (SharingServiceBinding)CreateService(MsnServiceType.Sharing, addServiceObject); abService.AddServiceCompleted += delegate(object service, AddServiceCompletedEventArgs e) { OnAfterCompleted(new ServiceOperationEventArgs(abService, MsnServiceType.Sharing, e)); if (e.Cancelled || NSMessageHandler.MSNTicket == MSNTicket.Empty) { return; } if (e.Error == null) { Trace.WriteLineIf(Settings.TraceSwitch.TraceInfo, serviceName + "=" + e.Result.AddServiceResult + " created..."); // Update service membership... msRequest(PartnerScenario.BlockUnblock, delegate { if (callback != null) { callback(abService, e); } }); } }; RunAsyncMethod(new BeforeRunAsyncMethodEventArgs(abService, MsnServiceType.Sharing, addServiceObject, r)); } }
private void AddServiceAsync(ServiceName serviceName, AddServiceCompletedEventHandler callback) { if (NSMessageHandler.MSNTicket == MSNTicket.Empty || AddressBook == null) { OnServiceOperationFailed(this, new ServiceOperationFailedEventArgs("AddService", new MSNPSharpException("You don't have access right on this action anymore."))); } else { AddServiceRequestType r = new AddServiceRequestType(); r.serviceInfo = new InfoType(); r.serviceInfo.Handle = new HandleType(); r.serviceInfo.Handle.Type = serviceName; r.serviceInfo.Handle.ForeignId = String.Empty; r.serviceInfo.InverseRequired = true; MsnServiceState addServiceObject = new MsnServiceState(PartnerScenario.CircleSave, "AddService", true); SharingServiceBinding abService = (SharingServiceBinding)CreateService(MsnServiceType.Sharing, addServiceObject); abService.AddServiceCompleted += delegate(object service, AddServiceCompletedEventArgs e) { OnAfterCompleted(new ServiceOperationEventArgs(abService, MsnServiceType.Sharing, e)); if (e.Cancelled || NSMessageHandler.MSNTicket == MSNTicket.Empty) return; if (e.Error == null) { Trace.WriteLineIf(Settings.TraceSwitch.TraceInfo, serviceName + "=" + e.Result.AddServiceResult + " created..."); // Update service membership... msRequest(PartnerScenario.BlockUnblock, delegate { if (callback != null) callback(abService, e); }); } }; RunAsyncMethod(new BeforeRunAsyncMethodEventArgs(abService, MsnServiceType.Sharing, addServiceObject, r)); } }