static XmlSchemaElement GenerateValidElementsComment(XmlSchemaElement element, HelpExampleGeneratorContext context)
        {
            XmlSchemaElement firstNonAbstractElement = element;
            StringBuilder    validTypes = new StringBuilder();

            foreach (XmlSchemaElement derivedElement in GetDerivedTypes(element, context))
            {
                if (firstNonAbstractElement == element)
                {
                    firstNonAbstractElement = derivedElement;
                }
                if (validTypes.Length > 0)
                {
                    validTypes.AppendFormat(", {0}", derivedElement.Name);
                }
                else
                {
                    validTypes.AppendFormat(SR2.GetString(SR2.HelpPageValidElementOfType, derivedElement.Name));
                }
            }
            if (validTypes.Length > 0)
            {
                context.writer.WriteComment(validTypes.ToString());
            }
            return(firstNonAbstractElement);
        }
Ejemplo n.º 2
0
        public override InstanceContext GetExistingInstanceContext(Message message, IContextChannel channel)
        {
            InstanceContext instanceContext = base.GetExistingInstanceContext(message, channel);

            if (instanceContext != null && this.InstanceLifeTimeManager != null)
            {
                WorkflowDurableInstance workflowDurableInstance = instanceContext.Extensions.Find <WorkflowDurableInstance>();

                if (workflowDurableInstance == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                              new InvalidOperationException(
                                  SR2.GetString(
                                      SR2.RequiredInstanceContextExtensionNotFound,
                                      typeof(WorkflowDurableInstance).Name)));
                }

                this.InstanceLifeTimeManager.NotifyWorkflowActivationComplete(
                    workflowDurableInstance.InstanceId,
                    this.workflowActivationCompleteCallback,
                    new WorkflowActivationCompletedCallbackState
                    (
                        workflowDurableInstance.InstanceId,
                        instanceContext),
                    false);
            }

            return(instanceContext);
        }
Ejemplo n.º 3
0
            public object[] GetInputs(SendActivity activity, WorkflowParameterBindingCollection bindings)
            {
                if (activity == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("activity");
                }

                object[] inputs = new object[this.parameterCount];

                if (inputParameters.Count > 0)
                {
                    for (int index = 0; index < inputParameters.Count; index++)
                    {
                        KeyValuePair <int, string> parameterInfo = inputParameters[index];

                        if (bindings.Contains(parameterInfo.Value))
                        {
                            inputs[parameterInfo.Key] = bindings[parameterInfo.Value].Value;
                        }
                        else
                        {
                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                                      new InvalidOperationException(SR2.GetString(SR2.Error_ParameterBindingMissing,
                                                                                  parameterInfo.Value,
                                                                                  this.operationName,
                                                                                  activity.Name)));
                        }
                    }
                }

                return(inputs);
            }
Ejemplo n.º 4
0
        public static XDocument CreateOperationHelpPage(Uri baseUri, OperationHelpInformation operationInfo)
        {
            XDocument document = CreateBaseDocument(SR2.GetString(SR2.HelpPageReferenceFor, BuildFullUriTemplate(baseUri, operationInfo.UriTemplate)));
            XElement  table    = new XElement(HtmlTableElementName,
                                              new XElement(HtmlTrElementName,
                                                           new XElement(HtmlThElementName, SR2.GetString(SR2.HelpPageMessageDirection)),
                                                           new XElement(HtmlThElementName, SR2.GetString(SR2.HelpPageFormat)),
                                                           new XElement(HtmlThElementName, SR2.GetString(SR2.HelpPageBody))));

            RenderMessageInformation(table, operationInfo, true);
            RenderMessageInformation(table, operationInfo, false);

            XElement div = new XElement(HtmlDivElementName, new XAttribute(HtmlIdAttributeName, HtmlContentClass),
                                        new XElement(HtmlPElementName, new XAttribute(HtmlClassAttributeName, HtmlHeading1Class), SR2.GetString(SR2.HelpPageReferenceFor, BuildFullUriTemplate(baseUri, operationInfo.UriTemplate))),
                                        new XElement(HtmlPElementName, operationInfo.Description),
                                        XElement.Parse(SR2.GetString(SR2.HelpPageOperationUri, HttpUtility.HtmlEncode(BuildFullUriTemplate(baseUri, operationInfo.UriTemplate)))),
                                        XElement.Parse(SR2.GetString(SR2.HelpPageOperationMethod, HttpUtility.HtmlEncode(operationInfo.Method))));

            if (!String.IsNullOrEmpty(operationInfo.JavascriptCallbackParameterName))
            {
                div.Add(XElement.Parse(SR2.GetString(SR2.HelpPageCallbackText, HttpUtility.HtmlEncode(operationInfo.JavascriptCallbackParameterName))), table);
            }
            else
            {
                div.Add(table);
            }
            document.Descendants(HtmlBodyElementName).First().Add(div);

            CreateOperationSamples(document.Descendants(HtmlDivElementName).First(), operationInfo);

            return(document);
        }
        internal static LogicalChannel Register(Activity activity,
                                                ChannelToken endpoint,
                                                Type contractType)
        {
            if (activity == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("activity");
            }
            if (endpoint == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("endpoint");
            }
            if (contractType == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("contractType");
            }

            LogicalChannel logicalChannel = GetLogicalChannel(activity, endpoint, contractType);

            if (logicalChannel == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                          new InvalidOperationException(SR2.GetString(SR2.Error_FailedToRegisterChannel, endpoint.Name)));
            }

            return(logicalChannel);
        }
Ejemplo n.º 6
0
        public void AbortInstance()
        {
            ConcurrencyMode concurrencyMode = this.runtimeValidator.ConcurrencyMode;

            if (concurrencyMode != ConcurrencyMode.Single)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                          new InvalidOperationException(
                              SR2.GetString(SR2.AbortInstanceRequiresSingle)));
            }

            if (this.saveStateInOperationTransaction)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                          new InvalidOperationException(
                              SR2.GetString(SR2.CannotAbortWithSaveStateInTransaction)));
            }

            if (this.markedForCompletion)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                          new InvalidOperationException(
                              SR2.GetString(
                                  SR2.DurableOperationMethodInvalid,
                                  "AbortInstance",
                                  "CompleteInstance")));
            }

            this.abortInstance = true;
        }
        private void SetupColumns()
        {
            this.parametersGrid.Columns.Clear();

            nameColumn            = new DataGridViewTextBoxColumn();
            nameColumn.HeaderText = SR2.GetString(SR2.ParameterColumnHeaderName);
            nameColumn.Name       = "Name";
            nameColumn.SortMode   = DataGridViewColumnSortMode.NotSortable;
            this.parametersGrid.Columns.Add(nameColumn);

            typeColumn              = new DataGridViewComboBoxColumn();
            typeColumn.HeaderText   = SR2.GetString(SR2.ParameterColumnHeaderType);
            typeColumn.Name         = "Type";
            typeColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            typeColumn.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;
            typeColumn.AutoComplete = true;
            typeColumn.SortMode     = DataGridViewColumnSortMode.NotSortable;
            typeChooserCellItem     = new TypeChooserCellItem();
            typeColumn.Items.Add(typeChooserCellItem);
            AddPrimitiveTypesToTypesList(); typeColumn.ValueMember = "Type";
            typeColumn.DisplayMember = "DisplayString";
            this.parametersGrid.Columns.Add(typeColumn);

            directionColumn = new DataGridViewComboBoxColumn();
            directionColumn.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;
            directionColumn.AutoComplete = true;
            directionColumn.Items.Add(SR2.GetString(SR2.ParameterDirectionIn));
            directionColumn.Items.Add(SR2.GetString(SR2.ParameterDirectionOut));
            directionColumn.Items.Add(SR2.GetString(SR2.ParameterDirectionRef));
            directionColumn.HeaderText = SR2.GetString(SR2.ParameterColumnHeaderDirection);
            directionColumn.Name       = "Direction";
            directionColumn.SortMode   = DataGridViewColumnSortMode.NotSortable;
            this.parametersGrid.Columns.Add(directionColumn);
            this.operationsToolStrip.BackColor = this.parametersTabPage.BackColor;
        }
Ejemplo n.º 8
0
        public override bool IsIdle(InstanceContext instanceContext)
        {
            if (instanceContext == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("instanceContext");
            }

            WorkflowDurableInstance workflowDurableInstance = instanceContext.Extensions.Find <WorkflowDurableInstance>();

            if (workflowDurableInstance == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                          new InvalidOperationException(
                              SR2.GetString(
                                  SR2.RequiredInstanceContextExtensionNotFound,
                                  typeof(WorkflowDurableInstance).Name)));
            }

            if (this.InstanceLifeTimeManager != null)
            {
                return((!this.InstanceLifeTimeManager.IsInstanceInMemory(workflowDurableInstance.InstanceId)) &&
                       base.IsIdle(instanceContext));
            }
            return(base.IsIdle(instanceContext));
        }
Ejemplo n.º 9
0
        public static void SetContext(Activity activity,
                                      string endpointName,
                                      string ownerActivityName,
                                      Type contractType,
                                      IDictionary <string, string> context)
        {
            if (activity == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("activity");
            }
            if (string.IsNullOrEmpty(endpointName))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("endpointName",
                                                                             SR2.GetString(SR2.Error_ArgumentValueNullOrEmptyString));
            }
            if (contractType == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("contractType");
            }

            LogicalChannel logicalChannel = ChannelToken.GetLogicalChannel(activity, endpointName, ownerActivityName, contractType);

            if (logicalChannel != null)
            {
                if (context != null)
                {
                    logicalChannel.Context = context;
                }
                else
                {
                    logicalChannel.Context = ContextMessageProperty.Empty.Context;
                }
            }
        }
Ejemplo n.º 10
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;
                    }
                }
            }
        public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
        {
            if (manager == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("manager");
            }

            ValidationErrorCollection validationErrors = ValidationHelpers.ValidateObject(manager, obj);

            if (validationErrors.Count == 0)
            {
                if (manager.Context == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                              new InvalidOperationException(SR2.GetString(SR2.Error_ContextStackMissing)));
                }

                Activity rootActivity = manager.Context[typeof(Activity)] as Activity;
                if (rootActivity == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                              new InvalidOperationException(SR2.GetString(SR2.Error_ContextStackItemMissing, typeof(Activity).Name)));
                }
                else
                {
                    validationErrors.AddRange(ValidationHelper.ValidateAllServiceOperationsImplemented(manager, rootActivity));
                }
            }

            return(validationErrors);
        }
        void parametersGrid_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            string errorString = string.Empty;
            bool   valid       = true;

            if (e.ColumnIndex == this.nameColumn.Index)
            {
                valid = ValidateParamaterName((string)e.FormattedValue, e, out errorString);
            }
            // void is not valid for parameters other than returnvalue
            if (e.ColumnIndex == this.typeColumn.Index)
            {
                if (typeof(void).ToString().Equals(e.FormattedValue) && !(this.parametersGrid.Rows[e.RowIndex].Cells[this.nameColumn.Index].Value.Equals(SR2.GetString(SR2.ReturnValueString))))
                {
                    valid       = false;
                    errorString = SR2.GetString(SR2.VoidIsNotAValidParameterType);
                }
            }
            if (!valid)
            {
                e.Cancel = true;
                DesignerHelpers.ShowMessage(this.ServiceProvider, errorString, DR.GetString(DR.WorkflowDesignerTitle), MessageBoxButtons.OK,
                                            MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
        }
        void parametersGridCellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            EnableFormCancelButton();
            if (!this.parametersGrid.Rows[this.parametersGrid.RowCount - 1].Cells[this.nameColumn.Index].Value.Equals(this.ParameterTemplateRowName))
            {
                DataGridViewRow editedRow = this.parametersGrid.Rows[e.RowIndex];
                editedRow.Cells[this.typeColumn.Index].Value      = typeof(string);
                editedRow.Cells[this.directionColumn.Index].Value = SR2.GetString(SR2.ParameterDirectionIn);
                // add a new template row to the end of the list.
                this.parametersGrid.Rows.Add(this.ParameterTemplateRowName, null, null);
                RefreshParameterOperationButtons();
            }

            DataGridViewCell currentCell = this.parametersGrid.Rows[e.RowIndex].Cells[e.ColumnIndex];

            if (typeof(TypeChooserCellItem).Equals(currentCell.Value))
            {
                // need this check beacuse one of the ways of choosing browse types( keyboard selection from dropdown)
                // overwrites the value of the cell with BrowseType.. again after setting the type, thus bringing up the type browser,
                // for the second time here.
                if (!typeChooserCellItem.TypeChosen)
                {
                    BrowseAndSelectType(currentCell);
                }
                else
                {
                    currentCell.Value = typeChooserCellItem.ChosenType;
                }
            }
            if (e.ColumnIndex.Equals(this.typeColumn.Index))
            {
                typeChooserCellItem.Reset();
            }
            UpdateOperationParameters();
        }
Ejemplo n.º 14
0
            bool TryGetContentTypeMapping(string contentType, out WebContentFormat format)
            {
                if (contentTypeMapper == null)
                {
                    format = WebContentFormat.Default;
                    return(false);
                }

                try
                {
                    format = contentTypeMapper.GetMessageFormatForContentType(contentType);
                    if (!WebContentFormatHelper.IsDefined(format))
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR2.GetString(SR2.UnknownWebEncodingFormat, contentType, format)));
                    }
                    return(true);
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }

                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(
                                                                                  SR2.GetString(SR2.ErrorEncounteredInContentTypeMapper), e));
                }
            }
Ejemplo n.º 15
0
        internal static ChannelTicket Take(ActivityExecutionContext executionContext, Guid workflowId, LogicalChannel logicalChannel)
        {
            if (executionContext == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("executionContext");
            }

            if (workflowId == Guid.Empty)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("workflowId",
                                                                             SR2.GetString(SR2.Error_Cache_InvalidWorkflowId));
            }

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

            ChannelManagerService channelManager = executionContext.GetService <ChannelManagerService>();

            ChannelTicket channel;

            if (channelManager != null)
            {
                channel = channelManager.TakeChannel(workflowId, logicalChannel);
            }
            else
            {
                channel = ChannelManagerService.CreateTransientChannel(logicalChannel);
            }

            return(channel);
        }
Ejemplo n.º 16
0
        protected internal override object CreateBehavior()
        {
            Fx.Assert(this.PersistenceOperationTimeout > TimeSpan.Zero,
                      "This should have been guaranteed by the validator on the setter.");

            PersistenceProviderFactory providerFactory;

            Type providerType = System.Type.GetType((string)base[typeParameter]);

            if (providerType == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                          new InvalidOperationException(SR2.GetString(SR2.PersistenceProviderTypeNotFound)));
            }

            ConstructorInfo cInfo = providerType.GetConstructor(new Type[] { typeof(NameValueCollection) });

            if (cInfo != null)
            {
                providerFactory = (PersistenceProviderFactory)cInfo.Invoke(new object[] { this.persistenceProviderArguments });
            }
            else
            {
                cInfo = providerType.GetConstructor(new Type[] { });

                Fx.Assert(cInfo != null,
                          "The constructor should have been found - this should have been validated elsewhere.");

                providerFactory = (PersistenceProviderFactory)cInfo.Invoke(null);
            }

            return(new PersistenceProviderBehavior(providerFactory, this.PersistenceOperationTimeout));
        }
            //Helper method to call from GetExistingInstanceContext
            //returns true  : If InstanceContext is found in cache & guaranteed to stay in cache until ReleaseReference is called.
            //returns false : If InstanceContext is not found in cache;
            //               reference & slot is created for the ID;
            //               InitializeInstanceContext to call AddInstanceContext.
            public bool TryGetInstanceContext(Guid instanceId, out InstanceContext instanceContext)
            {
                ContextItem contextItem;

                instanceContext = null;
                int referenceCount = -1;

                try
                {
                    lock (lockObject)
                    {
                        if (!contextCache.TryGetValue(instanceId, out contextItem))
                        {
                            contextItem    = new ContextItem(instanceId);
                            referenceCount = contextItem.AddReference();
                            contextCache.Add(instanceId, contextItem);
                            return(false);
                        }
                        referenceCount = contextItem.AddReference();
                    }
                }
                finally
                {
                    if (DiagnosticUtility.ShouldTraceInformation)
                    {
                        string traceText = SR2.GetString(SR2.DurableInstanceRefCountToInstanceContext, instanceId, referenceCount);
                        TraceUtility.TraceEvent(TraceEventType.Information,
                                                TraceCode.InstanceContextBoundToDurableInstance, SR.GetString(SR.TraceCodeInstanceContextBoundToDurableInstance),
                                                new StringTraceRecord("InstanceDetail", traceText),
                                                this, null);
                    }
                }
                instanceContext = contextItem.InstanceContext;
                return(true);
            }
            public void ReleaseReference(Guid instanceId)
            {
                int         referenceCount = -1;
                ContextItem contextItem;

                lock (lockObject)
                {
                    if (contextCache.TryGetValue(instanceId, out contextItem))
                    {
                        referenceCount = contextItem.ReleaseReference();
                    }
                    else
                    {
                        Fx.Assert(false, "Cannot Release Reference of non exisiting items");
                    }
                }

                if (DiagnosticUtility.ShouldTraceInformation)
                {
                    string traceText = SR2.GetString(SR2.DurableInstanceRefCountToInstanceContext, instanceId, referenceCount);
                    TraceUtility.TraceEvent(TraceEventType.Information,
                                            TraceCode.InstanceContextDetachedFromDurableInstance, SR.GetString(SR.TraceCodeInstanceContextDetachedFromDurableInstance),
                                            new StringTraceRecord("InstanceDetail", traceText),
                                            this, null);
                }
            }
            public void AddInstanceContext(Guid instanceId, InstanceContext instanceContext)
            {
                ContextItem contextItem;
                int?        referenceCount = null;

                lock (lockObject)
                {
                    if (!contextCache.TryGetValue(instanceId, out contextItem))
                    {
                        //This will be the case for activation request.
                        contextItem    = new ContextItem(instanceId);
                        referenceCount = contextItem.AddReference();
                        contextCache.Add(instanceId, contextItem);
                    }
                }
                contextItem.InstanceContext = instanceContext;

                if (DiagnosticUtility.ShouldTraceInformation && referenceCount.HasValue)
                {
                    string traceText = SR2.GetString(SR2.DurableInstanceRefCountToInstanceContext, instanceId, referenceCount.Value);
                    TraceUtility.TraceEvent(TraceEventType.Information,
                                            TraceCode.InstanceContextBoundToDurableInstance, SR.GetString(SR.TraceCodeInstanceContextBoundToDurableInstance),
                                            new StringTraceRecord("InstanceDetail", traceText),
                                            this, null);
                }
            }
        public ServiceOperationDetailViewControl()
        {
            InitializeComponent();

            this.protectionLevelComboBox.Items.Add(SR2.GetString(SR2.UseRuntimeDefaults));
            this.protectionLevelComboBox.Items.Add(ProtectionLevel.None);
            this.protectionLevelComboBox.Items.Add(ProtectionLevel.Sign);
            this.protectionLevelComboBox.Items.Add(ProtectionLevel.EncryptAndSign);
        }
Ejemplo n.º 21
0
 public ContextToken(string name)
 {
     if (string.IsNullOrEmpty(name))
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("name",
                                                                      SR2.GetString(SR2.Error_ArgumentValueNullOrEmptyString));
     }
     this.Name = name;
 }
Ejemplo n.º 22
0
 HttpResponseMessageProperty EnsureMessageProperty()
 {
     if (this.MessageProperty == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
                                                                       SR2.GetString(SR2.HttpContextNoIncomingMessageProperty, typeof(HttpResponseMessageProperty).Name)));
     }
     return(this.MessageProperty);
 }
 public override object Invoke(object obj,
                               BindingFlags invokeAttr,
                               Binder binder,
                               object[] parameters,
                               CultureInfo culture)
 {
     throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
               new NotImplementedException(SR2.GetString(SR2.Error_RuntimeNotSupported)));
 }
        public WorkflowOperationAsyncResult(WorkflowOperationInvoker workflowOperationInvoker,
                                            WorkflowDurableInstance workflowDurableInstance, object[] inputs,
                                            AsyncCallback callback, object state, long time)
            : base(callback, state)
        {
            if (inputs == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("inputs");
            }

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

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

            string queueName;

            WorkflowRequestContext workflowRequestContext = new WorkflowRequestContext(
                this,
                inputs,
                GetContextProperties());

            queueName = workflowOperationInvoker.StaticQueueName;

            if (workflowRequestContext.ContextProperties.Count > 1) //DurableDispatchContextProperty.
            {
                queueName = QueueNameHelper.Create(workflowOperationInvoker.StaticQueueName, workflowRequestContext.ContextProperties);
            }

            WorkflowInstance workflowInstance = workflowDurableInstance.GetWorkflowInstance
                                                    (workflowOperationInvoker.CanCreateInstance);

            AsyncCallbackState callbackState = new AsyncCallbackState(workflowRequestContext,
                                                                      workflowInstance, workflowOperationInvoker.DispatchRuntime.SynchronizationContext,
                                                                      workflowOperationInvoker.InstanceLifetimeManager, queueName);

            this.isOneway       = workflowOperationInvoker.IsOneWay;
            this.instanceIdGuid = workflowInstance.InstanceId;
            this.time           = time;

            ActionItem.Schedule(waitCallback, callbackState);

            if (DiagnosticUtility.ShouldTraceVerbose)
            {
                string traceText = SR2.GetString(SR2.WorkflowOperationInvokerItemQueued, this.InstanceId, queueName);
                TraceUtility.TraceEvent(TraceEventType.Verbose,
                                        TraceCode.WorkflowOperationInvokerItemQueued, SR.GetString(SR.TraceCodeWorkflowOperationInvokerItemQueued),
                                        new StringTraceRecord("ItemDetails", traceText),
                                        this, null);
            }
        }
 void IList.Remove(object value)
 {
     if (!(value is OperationParameterInfo))
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(
                   "value",
                   SR2.GetString(SR2.Error_InvalidListItem, typeof(OperationParameterInfo).FullName));
     }
     ((IList <OperationParameterInfo>) this).Remove((OperationParameterInfo)value);
 }
        void OnTimer(object state)
        {
            Guid instanceId = (Guid)state;

            try
            {
                if (this.hasPersistenceService)
                {
                    this.workflowRuntime.GetWorkflow(instanceId).TryUnload();
                }
                else
                {
                    this.workflowRuntime.GetWorkflow(instanceId).Abort();

                    if (DiagnosticUtility.ShouldTraceInformation)
                    {
                        string traceText = SR2.GetString(SR2.AutoAbortingInactiveInstance, instanceId);
                        TraceUtility.TraceEvent(TraceEventType.Information,
                                                TraceCode.WorkflowDurableInstanceAborted, SR.GetString(SR.TraceCodeWorkflowDurableInstanceAborted),
                                                new StringTraceRecord("InstanceDetail", traceText),
                                                this, null);
                    }
                }
            }
            catch (PersistenceException)
            {
                try
                {
                    this.workflowRuntime.GetWorkflow(instanceId).Abort();

                    if (DiagnosticUtility.ShouldTraceInformation)
                    {
                        string traceText = SR2.GetString(SR2.AutoAbortingInactiveInstance, instanceId);
                        TraceUtility.TraceEvent(TraceEventType.Information,
                                                TraceCode.WorkflowDurableInstanceAborted, SR.GetString(SR.TraceCodeWorkflowDurableInstanceAborted),
                                                new StringTraceRecord("InstanceDetail", traceText),
                                                this, null);
                    }
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }
                }
            }
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }
            }
        }
Ejemplo n.º 27
0
        public static XDocument CreateTransferRedirectPage(string originalTo, string newLocation)
        {
            XDocument document = CreateBaseDocument(SR2.GetString(SR2.HelpPageTitleText));

            XElement div = new XElement(HtmlDivElementName, new XAttribute(HtmlIdAttributeName, HtmlContentClass),
                                        new XElement(HtmlPElementName, new XAttribute(HtmlClassAttributeName, HtmlHeading1Class), SR2.GetString(SR2.HelpPageTitleText)),
                                        XElement.Parse(SR2.GetString(SR2.HelpPageRedirect, HttpUtility.HtmlEncode(originalTo), HttpUtility.HtmlEncode(newLocation))));

            document.Descendants(HtmlBodyElementName).First().Add(div);
            return(document);
        }
Ejemplo n.º 28
0
        public T CreateWithUniqueName()
        {
            string generatedName;

            do
            {
                generatedName = SR2.GetString(this.GeneratedNameFormatResource, ++this.suffixGenerator);
            } while (this.Find(generatedName) != null);

            return(this.CreateObject(generatedName));
        }
Ejemplo n.º 29
0
            protected override void OnLoad(EventArgs e)
            {
                this.Width = this.Parent.Width - 10;
                Label label = new Label();

                label.ForeColor = System.Drawing.SystemColors.GrayText;
                label.Dock      = DockStyle.Fill;
                this.Font       = new Font(this.Font, FontStyle.Italic);
                label.Text      = SR2.GetString(SR2.AddOperationsUsingImportAddButtons);
                this.Controls.Add(label);
            }
 public void Initialize(string configurationName, string customAddress)
 {
     if (this.Initialized)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                   new InvalidOperationException(SR2.GetString(SR2.Error_LogicalChannelAlreadyInitialized, this.Name)));
     }
     this.configurationName = configurationName ?? string.Empty;
     this.customAddress     = customAddress;
     this.initialized       = true;
 }