示例#1
0
            public SendOperationInfoHelper(IServiceProvider serviceProvider, SendActivity activity)
            {
                outputParameters = new List <KeyValuePair <int, string> >();
                inputParameters  = new List <KeyValuePair <int, string> >();
                hasReturnValue   = false;

                if (activity == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("activity");
                }

                OperationInfoBase serviceOperationInfo = activity.ServiceOperationInfo;

                if (serviceOperationInfo == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                              new InvalidOperationException(SR2.GetString(SR2.Error_ServiceOperationInfoNotSpecified, activity.Name)));
                }

                MethodInfo methodInfo = serviceOperationInfo.GetMethodInfo(serviceProvider);

                if (methodInfo == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                              new InvalidOperationException(SR2.GetString(SR2.Error_MethodInfoNotAvailable, activity.Name)));
                }

                if (methodInfo.ReturnType != null && methodInfo.ReturnType != typeof(void))
                {
                    hasReturnValue = true;
                }

                foreach (ParameterInfo parameter in methodInfo.GetParameters())
                {
                    if (parameter.ParameterType.IsByRef ||
                        parameter.IsOut || (parameter.IsIn && parameter.IsOut))
                    {
                        outputParameters.Add(new KeyValuePair <int, string>(parameter.Position, parameter.Name));
                    }

                    if (!parameter.IsOut || (parameter.IsIn && parameter.IsOut))
                    {
                        inputParameters.Add(new KeyValuePair <int, string>(parameter.Position, parameter.Name));
                    }
                }

                this.parameterCount = methodInfo.GetParameters().Length;

                this.operationName = serviceOperationInfo.Name;

                object[] operationContractAttribs = methodInfo.GetCustomAttributes(typeof(OperationContractAttribute), true);

                if (operationContractAttribs != null && operationContractAttribs.Length > 0)
                {
                    if (operationContractAttribs[0] is OperationContractAttribute)
                    {
                        this.isOneWay = ((OperationContractAttribute)operationContractAttribs[0]).IsOneWay;
                    }
                }
            }
示例#2
0
 internal static bool MatchByOperation(OperationInfoBase source, OperationInfoBase target)
 {
     if (!MatchByContract(source, target))
     {
         return(false);
     }
     return(MatchNames(source.Name, target.Name));
 }
        public OperationParameterInfoCollection(OperationInfoBase owner)
        {
            if (owner == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("owner");
            }

            this.owner = owner;
        }
        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);
            }

        }
        public virtual OperationInfoBase Clone()
        {
            OperationInfoBase clonedOperation = (OperationInfoBase)Activator.CreateInstance(this.GetType());

            clonedOperation.Name = this.Name;
            clonedOperation.PrincipalPermissionName = this.PrincipalPermissionName;
            clonedOperation.PrincipalPermissionRole = this.PrincipalPermissionRole;

            return(clonedOperation);
        }
示例#6
0
        internal static bool MatchByContract(OperationInfoBase source, OperationInfoBase target)
        {
            if ((source == null) || (target == null))
            {
                return(false);
            }
            string sourceContract = source.GetContractFullName(null);
            string targetContract = target.GetContractFullName(null);

            return(MatchNames(sourceContract, targetContract));
        }
示例#7
0
        protected override void OnMouseDoubleClick(System.Windows.Forms.MouseEventArgs e)
        {
            // Do not allow editing if activity is locked
            if (this.IsLocked)
            {
                return;
            }

            OperationInfoBase pickedServiceOperation = null;

            if (ServiceOperationUIEditor.TryPickOperation(this.Activity.Site, this.Activity, this.SendActivity.ServiceOperationInfo, out pickedServiceOperation))
            {
                PropertyDescriptorUtils.SetPropertyValue(this.Activity.Site, ServiceOperationHelpers.GetServiceOperationInfoPropertyDescriptor(this.Activity), this.Activity, pickedServiceOperation);
            }
        }
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture,
                                         object value, Type destinationType)
        {
            if (destinationType == typeof(string))
            {
                OperationInfoBase serviceOperationInfo = value as OperationInfoBase;
                if (serviceOperationInfo != null)
                {
                    string contractName = serviceOperationInfo.GetContractFullName(null);
                    if (string.IsNullOrEmpty(contractName) || string.IsNullOrEmpty(serviceOperationInfo.Name))
                    {
                        return(string.Empty);
                    }

                    return(string.Format(CultureInfo.InvariantCulture,
                                         "{0}.{1}",
                                         contractName,
                                         serviceOperationInfo.Name));
                }
            }
            return(base.ConvertTo(context, culture, value, destinationType));
        }
示例#9
0
        protected override void OnPaint(ActivityDesignerPaintEventArgs e)
        {
            base.OnPaint(e);

            Rectangle outgoingArrowRect = new Rectangle(this.Location.X + this.Size.Width - 24, this.Location.Y + 10, 24, 24);
            Rectangle incomingArrowRect = new Rectangle(this.Location.X + this.Size.Width, this.Location.Y + this.Size.Height - 35, -24, 24);

            e.Graphics.DrawImage(ImageResources.Arrow, outgoingArrowRect);
            bool isOneWay = false;


            if (SendActivity.ServiceOperationInfo != null)
            {
                OperationInfoBase operation = this.SendActivity.ServiceOperationInfo;
                // Refresh the contract type in the case the type is a Design Time type)
                //ServiceOperationHelpers.RefreshReferencedDesignTimeTypes(this.Activity.Site as IServiceProvider, operation);
                isOneWay = operation.GetIsOneWay(this.Activity.Site as IServiceProvider);
            }
            if (!isOneWay)
            {
                e.Graphics.DrawImage(ImageResources.Arrow, incomingArrowRect);
            }
        }
        public override bool Equals(object obj)
        {
            OperationInfoBase operationInfo = obj as OperationInfoBase;

            if (operationInfo == null)
            {
                return(false);
            }
            if (String.Compare(operationInfo.Name, this.Name, StringComparison.Ordinal) != 0)
            {
                return(false);
            }
            if (String.Compare(operationInfo.PrincipalPermissionName, this.PrincipalPermissionName, StringComparison.Ordinal) != 0)
            {
                return(false);
            }
            if (String.Compare(operationInfo.PrincipalPermissionRole, this.PrincipalPermissionRole, StringComparison.Ordinal) != 0)
            {
                return(false);
            }

            return(true);
        }
        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);
        }
 private void okButton_Click(object sender, EventArgs e)
 {
     object selectedObject = operationsListBox.SelectedItem;
     if (selectedObject == null)
     {
         selectedOperation = null;
     }
     if (selectedObject is TypedServiceOperationListItem)
     {
         selectedOperation = ((TypedServiceOperationListItem) selectedObject).Operation;
     }
     else if (selectedObject is WorkflowServiceOperationListItem)
     {
         selectedOperation = ((WorkflowServiceOperationListItem) selectedObject).Operation;
     }
     else
     {
         // dont close the dialog when contracts are selected
         return;
     }
     this.DialogResult = DialogResult.OK;
     this.Close();
 }
 internal static bool MatchByOperation(OperationInfoBase source, OperationInfoBase target)
 {
     if (!MatchByContract(source, target))
     {
         return false;
     }
     return MatchNames(source.Name, target.Name);
 }
 internal static bool MatchByContract(OperationInfoBase source, OperationInfoBase target)
 {
     if ((source == null) || (target == null))
     {
         return false;
     }
     string sourceContract = source.GetContractFullName(null);
     string targetContract = target.GetContractFullName(null);
     return MatchNames(sourceContract, targetContract);
 }