private void SelectServiceOperation(OperationInfoBase operationInfo) { Fx.Assert(operationInfo != null, "operationInfo cannot be null"); ServiceContractListItem serviceContract = this.serviceContracts.Find(operationInfo.GetContractFullName(null)); // Dont select operation if the contract cannot be found in the serviceContracts list if (serviceContract == null) { return; } ServiceOperationListItem operationItem = null; if (operationInfo is OperationInfo) { operationItem = new WorkflowServiceOperationListItem(); operationItem.Validating += new CancelEventHandler(ServiceOperationValidating); operationItem.Name = operationInfo.Name; ((WorkflowServiceOperationListItem)operationItem).Operation = operationInfo as OperationInfo; } else if (operationInfo is TypedOperationInfo) { operationItem = new TypedServiceOperationListItem(); operationItem.Validating += new CancelEventHandler(ServiceOperationValidating); operationItem.Name = operationInfo.Name; ((TypedServiceOperationListItem)operationItem).Operation = operationInfo as TypedOperationInfo; } serviceContract.SelectionOperation(operationItem); }
public void AddServiceOperation(OperationInfoBase operationInfo, Activity implementingActivity) { if (operationInfo == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("operationInfo"); } TypedOperationInfo typedOperationInfo = operationInfo as TypedOperationInfo; OperationInfo workflowOperationInfo = operationInfo as OperationInfo; string contractName = operationInfo.GetContractFullName(null); // Do not add operation if the contractName is not valid. Not throwing here gives the user to fix // a broken contract/operation by selecting a different operation from the UI. if (String.IsNullOrEmpty(contractName)) { return; } ServiceContractListItem serviceContract = this.serviceContracts.Find(contractName); if (typedOperationInfo != null) { if (serviceContract == null) { serviceContract = new ServiceContractListItem(this.operationsListBox); serviceContract.Validating += new CancelEventHandler(ServiceContractValidating); serviceContract.Name = contractName; serviceContract.ContractType = typedOperationInfo.ContractType; serviceContract.IsCustomContract = false; AddServiceContract(serviceContract); } TypedServiceOperationListItem operationItem = new TypedServiceOperationListItem(); operationItem.Validating += new CancelEventHandler(ServiceOperationValidating); operationItem.Name = typedOperationInfo.Name; operationItem.Operation = typedOperationInfo; operationItem.ImplementingActivities.Add(implementingActivity); serviceContract.AddOperation(operationItem); } else if (workflowOperationInfo != null) { if (serviceContract == null) { serviceContract = new ServiceContractListItem(this.operationsListBox); serviceContract.Validating += new CancelEventHandler(ServiceContractValidating); serviceContract.Name = workflowOperationInfo.ContractName; serviceContract.IsCustomContract = true; AddServiceContract(serviceContract); } WorkflowServiceOperationListItem workflowOperationItem = new WorkflowServiceOperationListItem(); workflowOperationItem.Validating += new CancelEventHandler(ServiceOperationValidating); workflowOperationItem.Operation = workflowOperationInfo; workflowOperationItem.ImplementingActivities.Add(implementingActivity); serviceContract.AddOperation(workflowOperationItem); } }