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); }
protected override ServiceOperationListItem CreateObject(string name) { ServiceOperationListItem result = new WorkflowServiceOperationListItem(); result.Name = name; return(result); }
public WorkflowServiceOperationListItem CreateOperation() { WorkflowServiceOperationListItem result = (WorkflowServiceOperationListItem)this.operations.CreateWithUniqueName(); result.Operation.ContractName = this.Name; return(result); }
private void UpdateImplementingActivities() { ServiceOperationListItem operationListItem = this.Item as ServiceOperationListItem; WorkflowServiceOperationListItem workflowOperationListItem = this.Item as WorkflowServiceOperationListItem; TypedServiceOperationListItem reflectedOperationListItem = this.Item as TypedServiceOperationListItem; OperationInfoBase operation = null; if (workflowOperationListItem != null) { operation = workflowOperationListItem.Operation; } else if (reflectedOperationListItem != null) { operation = reflectedOperationListItem.Operation; } Fx.Assert(operation != null, "operation should not be null at this point"); // workflow operations list item will complain if some operationInfo objects have different signature than others // for the same operation name. This will happen when we are updating the activities, since they already have a operation // object for that operation name, but with a different signature. so make them all point to null first ,then update. if (workflowOperationListItem != null) { foreach (Activity activity in operationListItem.ImplementingActivities) { PropertyDescriptorUtils.SetPropertyValue(this.ServiceProvider, ServiceOperationHelpers.GetServiceOperationInfoPropertyDescriptor(activity), activity, null); } } foreach (Activity activity in operationListItem.ImplementingActivities) { PropertyDescriptorUtils.SetPropertyValue(this.ServiceProvider, ServiceOperationHelpers.GetServiceOperationInfoPropertyDescriptor(activity), activity, operation.Clone()); } }
void operationNameTextBox_Validated(object sender, EventArgs e) { WorkflowServiceOperationListItem workflowOperationListItem = this.Item as WorkflowServiceOperationListItem; Fx.Assert(workflowOperationListItem != null, "this method should only be called on workflowOperations"); workflowOperationListItem.Operation.Name = this.operationNameTextBox.Text; OnOperationPropertiesChanged(); }
void oneWayCheckBoxCheckedChanged(object sender, EventArgs e) { WorkflowServiceOperationListItem workflowOperationListItem = this.Item as WorkflowServiceOperationListItem; Fx.Assert(workflowOperationListItem != null, "this method should only be called on workflowOperations"); workflowOperationListItem.Operation.IsOneWay = this.oneWayCheckBox.Checked; OnOperationPropertiesChanged(); }
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); } }
void UpdateOperationParameters() { WorkflowServiceOperationListItem workflowOperationListItem = this.Item as WorkflowServiceOperationListItem; Fx.Assert(workflowOperationListItem != null, "UpdateOperation should only be called on workflowOperations"); workflowOperationListItem.Operation.Parameters.Clear(); int paramPosition = 0; foreach (DataGridViewRow row in this.parametersGrid.Rows) { string name = row.Cells[this.nameColumn.Index].Value as string; object typeCell = row.Cells[this.typeColumn.Index].Value; string direction = row.Cells[this.directionColumn.Index].Value as string; if (string.IsNullOrEmpty(name) || name.Equals(this.ParameterTemplateRowName)) { continue; } if (typeCell == null) { continue; } if (string.IsNullOrEmpty(direction)) { continue; } OperationParameterInfo operationParameterInfo = new OperationParameterInfo(name); operationParameterInfo.ParameterType = typeCell as Type; if (direction.Equals(SR2.GetString(SR2.ParameterDirectionIn))) { operationParameterInfo.Attributes |= ParameterAttributes.In; } if (direction.Equals(SR2.GetString(SR2.ParameterDirectionOut))) { operationParameterInfo.Attributes |= ParameterAttributes.Out; } if (direction.Equals(SR2.GetString(SR2.ParameterDirectionRef))) { operationParameterInfo.Attributes |= ParameterAttributes.In; operationParameterInfo.Attributes |= ParameterAttributes.Out; } if (name.Equals(SR2.GetString(SR2.ReturnValueString))) { operationParameterInfo.Attributes |= ParameterAttributes.Retval; operationParameterInfo.Position = -1; } else { operationParameterInfo.Position = paramPosition; paramPosition++; } workflowOperationListItem.Operation.Parameters.Add(operationParameterInfo); } UpdateImplementingActivities(); }
private void addOperationButton_Click(object sender, EventArgs e) { ServiceContractListItem serviceContractListItem = this.operationsListBox.SelectedItem as ServiceContractListItem; Fx.Assert(serviceContractListItem != null, "service contract list item cannot be null"); Fx.Assert(serviceContractListItem.IsCustomContract, " this should work only on a custom contract item"); WorkflowServiceOperationListItem newWorkflowServiceOperationListItem = serviceContractListItem.CreateOperation(); newWorkflowServiceOperationListItem.Validating += new CancelEventHandler(ServiceOperationValidating); this.AddServiceOperation(newWorkflowServiceOperationListItem); serviceContractListItem.SelectionOperation(newWorkflowServiceOperationListItem); }
void NewContractButtonClicked(object sender, EventArgs e) { ServiceContractListItem contractItem = this.serviceContracts.CreateWithUniqueName(); contractItem.Validating += new CancelEventHandler(ServiceContractValidating); contractItem.IsCustomContract = true; this.AddServiceContract(contractItem); WorkflowServiceOperationListItem newWorkflowServiceOperationListItem = contractItem.CreateOperation(); newWorkflowServiceOperationListItem.Validating += new CancelEventHandler(ServiceOperationValidating); this.AddServiceOperation(newWorkflowServiceOperationListItem); contractItem.SelectionOperation(newWorkflowServiceOperationListItem); }
void protectionLevelComboBoxSelectedValueChanged(object sender, EventArgs e) { WorkflowServiceOperationListItem item = (WorkflowServiceOperationListItem)this.Item; if (this.protectionLevelComboBox.SelectedItem.Equals(SR2.GetString(SR2.UseRuntimeDefaults))) { item.Operation.ResetProtectionLevel(); } else { item.Operation.ProtectionLevel = (ProtectionLevel)this.protectionLevelComboBox.SelectedItem; } OnOperationPropertiesChanged(); }
void permissionRoleTextChanged(object sender, EventArgs e) { WorkflowServiceOperationListItem workflowOperationListItem = this.Item as WorkflowServiceOperationListItem; if (workflowOperationListItem != null) { workflowOperationListItem.Operation.PrincipalPermissionRole = this.permissionRoleTextBox.Text; } else { TypedServiceOperationListItem reflectedOperationListItem = this.Item as TypedServiceOperationListItem; if (reflectedOperationListItem != null) { reflectedOperationListItem.Operation.PrincipalPermissionRole = this.permissionRoleTextBox.Text; } } OnOperationPropertiesChanged(); }
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); } }
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 override void UpdateView() { // set the dialog fonts from vs. IUIService uisvc = (IUIService)this.ServiceProvider.GetService(typeof(IUIService)); if (uisvc != null) { this.Font = (Font)uisvc.Styles["DialogFont"]; } TypedServiceOperationListItem operationListItem = this.Item as TypedServiceOperationListItem; WorkflowServiceOperationListItem workflowOperationListItem = this.Item as WorkflowServiceOperationListItem; if (operationListItem != null) { operationInfoBase = operationListItem.Operation; SetEditability(false); } if (workflowOperationListItem != null) { operationInfoBase = workflowOperationListItem.Operation; if (workflowOperationListItem.Operation.HasProtectionLevel) { this.protectionLevelComboBox.SelectedItem = workflowOperationListItem.Operation.ProtectionLevel; } else { this.protectionLevelComboBox.SelectedItem = SR2.GetString(SR2.UseRuntimeDefaults); } SetEditability(true); } Fx.Assert(operationInfoBase != null, "list Item should be either ReflectedServiceOperationListItem or WorkflowServiceOperationListItem"); this.oneWayCheckBox.Checked = operationInfoBase.GetIsOneWay(ServiceProvider); Fx.Assert(operationInfoBase != null, "Operation Info should be non-null at this point"); SetupColumns(); PopulateParametersGrid(operationInfoBase); if (!this.parametersGrid.ReadOnly) { this.parametersGrid.Rows.Add(this.ParameterTemplateRowName, null, null); } this.operationNameTextBox.Text = operationInfoBase.Name; this.permissionRoleTextBox.Text = operationInfoBase.PrincipalPermissionRole; this.permissionNameTextBox.Text = operationInfoBase.PrincipalPermissionName; this.permissionRoleTextBox.TextChanged += new EventHandler(permissionRoleTextChanged); if (workflowOperationListItem != null) { this.operationNameTextBox.Validating += new CancelEventHandler(operationNameTextBox_Validating); this.operationNameTextBox.Validated += new EventHandler(operationNameTextBox_Validated); } this.oneWayCheckBox.CheckedChanged += new EventHandler(oneWayCheckBoxCheckedChanged); this.permissionNameTextBox.TextChanged += new EventHandler(permissionNameTextChanged); this.parametersGrid.SelectionChanged += new EventHandler(parametersGrid_SelectionChanged); if (!this.parametersGrid.ReadOnly) { this.parametersGrid.CellValidating += new DataGridViewCellValidatingEventHandler(parametersGrid_CellValidating); this.parametersGrid.CellEndEdit += new DataGridViewCellEventHandler(parametersGridCellEndEdit); this.parametersGrid.EditingControlShowing += new DataGridViewEditingControlShowingEventHandler(parametersGrid_EditingControlShowing); this.parametersGrid.KeyDown += new KeyEventHandler(parametersGrid_KeyDown); } this.protectionLevelComboBox.SelectedValueChanged += new System.EventHandler(this.protectionLevelComboBoxSelectedValueChanged); RefreshParameterOperationButtons(); }