当前位置: 首页>>代码示例>>C#>>正文


C# Activity.GetValue方法代码示例

本文整理汇总了C#中Activity.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Activity.GetValue方法的具体用法?C# Activity.GetValue怎么用?C# Activity.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Activity的用法示例。


在下文中一共展示了Activity.GetValue方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetActivityType

        internal static Type GetActivityType(IServiceProvider serviceProvider, Activity refActivity)
        {
            Type type = null;
            string typeName = refActivity.GetValue(WorkflowMarkupSerializer.XClassProperty) as string;
            if (refActivity.Site != null && !string.IsNullOrEmpty(typeName))
            {
                ITypeProvider typeProvider = serviceProvider.GetService(typeof(ITypeProvider)) as ITypeProvider;
                if (typeProvider != null && !string.IsNullOrEmpty(typeName))
                    type = typeProvider.GetType(typeName, false);
            }
            else
            {
                type = refActivity.GetType();
            }

            return type;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:17,代码来源:BindValidator.cs

示例2: InvalidOperationException

 void IWorkflowCoreRuntime.SaveContextActivity(Activity contextActivity)
 {
     if (!ServiceEnvironment.IsInServiceThread(this.InstanceId))
         throw new InvalidOperationException(ExecutionStringManager.MustUseRuntimeThread);
     this.completedContextActivities.Add((ActivityExecutionContextInfo)contextActivity.GetValue(Activity.ActivityExecutionContextInfoProperty), contextActivity);
 }
开发者ID:uQr,项目名称:referencesource,代码行数:6,代码来源:WorkflowExecutor.cs

示例3: ReloadHelper

        // Used to recreate the root schedule executor from its persisted state
        private void ReloadHelper(Activity rootActivity)
        {
            // assign activity state
            this.rootActivity = rootActivity;
            this.InstanceId = (Guid)rootActivity.GetValue(WorkflowInstanceIdProperty);

            // set workflow executor
            this.rootActivity.SetValue(WorkflowExecutor.WorkflowExecutorProperty, this);

            this._schedulerLock = LockFactory.CreateWorkflowSchedulerLock(this.InstanceId);

            this.schedulingContext = new Scheduler(this, false);
            this.qService = new WorkflowQueuingService(this);

            WorkflowTrace.Runtime.TraceEvent(TraceEventType.Information, 0, "Workflow Runtime: WorkflowExecutor: Loading instance {0}", this.InstanceIdString);
            DiagnosticStackTrace("load request");

            using (new ServiceEnvironment(this.rootActivity))
            {

                // check if this instance can be loaded
                switch (this.WorkflowStatus)
                {
                    case WorkflowStatus.Completed:
                    case WorkflowStatus.Terminated:
                        WorkflowTrace.Runtime.TraceEvent(TraceEventType.Error, 0, "Workflow Runtime: WorkflowExecutor: attempt to load a completed/terminated instance: {0}", this.InstanceIdString);
                        throw new InvalidOperationException(
                            ExecutionStringManager.InvalidAttemptToLoad);

                    default:
                        break;
                }

                // new nonSerialized members
                _resourceManager = new VolatileResourceManager();
                _runtime = _workflowInstance.WorkflowRuntime;

                // register all dynamic activities for loading
                Queue<Activity> dynamicActivitiesQueue = new Queue<Activity>();
                dynamicActivitiesQueue.Enqueue(this.rootActivity);
                while (dynamicActivitiesQueue.Count > 0)
                {
                    Activity dynamicActivity = dynamicActivitiesQueue.Dequeue();
                    ((IDependencyObjectAccessor)dynamicActivity).InitializeInstanceForRuntime(this);
                    this.RegisterDynamicActivity(dynamicActivity, true);

                    IList<Activity> nestedDynamicActivities = (IList<Activity>)dynamicActivity.GetValue(Activity.ActiveExecutionContextsProperty);
                    if (nestedDynamicActivities != null)
                    {
                        foreach (Activity nestedDynamicActivity in nestedDynamicActivities)
                            dynamicActivitiesQueue.Enqueue(nestedDynamicActivity);
                    }
                }
            }

            this.isInstanceIdle = (bool)this.rootActivity.GetValue(IsIdleProperty);
            RefreshWorkflowDefinition();
        }
开发者ID:uQr,项目名称:referencesource,代码行数:59,代码来源:WorkflowExecutor.cs

示例4: ScheduleDelayedItems

        private void ScheduleDelayedItems(Activity atomicActivity)
        {
            List<SchedulableItem> items = null;
            TransactionalProperties transactionalProperties = (TransactionalProperties)atomicActivity.GetValue(TransactionalPropertiesProperty);

            if (transactionalProperties == null)
                return;

            lock (transactionalProperties)
            {
                items = transactionalProperties.ItemsToBeScheduledAtCompletion;
                if (items == null)
                    return;

                WorkflowTrace.Runtime.TraceEvent(TraceEventType.Information, 0,
                    "Workflow Runtime: WorkflowExecutor: instanceId: " + this.InstanceIdString +
                    " .Scheduling delayed " + items.Count + " number of items");

                foreach (SchedulableItem item in items)
                {
                    this.Scheduler.ScheduleItem(item, false, true);
                }
                items.Clear();

                transactionalProperties.ItemsToBeScheduledAtCompletion = null;
            }
        }
开发者ID:uQr,项目名称:referencesource,代码行数:27,代码来源:WorkflowExecutor.cs

示例5: AddItemToBeScheduledLater

        private void AddItemToBeScheduledLater(Activity atomicActivity, SchedulableItem item)
        {
            if (atomicActivity == null)
                return;

            // Activity may not be atomic and is an activity which is not
            // yet scheduled for execution (typically receive case)
            if (!atomicActivity.SupportsTransaction)
                return;

            TransactionalProperties transactionalProperties = (TransactionalProperties)atomicActivity.GetValue(TransactionalPropertiesProperty);
            if (transactionalProperties != null)
            {
                lock (transactionalProperties)
                {
                    List<SchedulableItem> notifications = null;
                    notifications = transactionalProperties.ItemsToBeScheduledAtCompletion;
                    if (notifications == null)
                    {
                        notifications = new List<SchedulableItem>();
                        transactionalProperties.ItemsToBeScheduledAtCompletion = notifications;
                    }
                    notifications.Add(item);
                }
            }
        }
开发者ID:uQr,项目名称:referencesource,代码行数:26,代码来源:WorkflowExecutor.cs

示例6: RollbackTransaction

        private void RollbackTransaction(Exception exp, Activity activityContext)
        {
            if (activityContext == this.currentAtomicActivity)
            {
                Debug.Assert((activityContext == this.currentAtomicActivity),
                    "Activity context " + activityContext.Name + " different from currentAtomicActivity " + this.currentAtomicActivity.Name);

                TransactionalProperties transactionalProperties = (TransactionalProperties)activityContext.GetValue(TransactionalPropertiesProperty);
                if (transactionalProperties.TransactionState != TransactionProcessState.AbortProcessed)
                {
                    // If TransactionState is not already AbortProcessed, Set it to AbortProcessed as we have raised exception for it already
                    // Possible call paths for which it's not already AbortProcessed:
                    // TransactionState == Aborted if due to transaction failure notified through TransactionCompletionHandler
                    // TransactionState == Ok if Called from external exception raising (e.g. a throw activity in Atomic context)
                    transactionalProperties.TransactionState = TransactionProcessState.AbortProcessed;
                }

                Debug.Assert((transactionalProperties.Transaction != null), "Null Transaction while transaction is present");
                Debug.Assert((transactionalProperties.LocalQueuingService != null), "Null LocalQueuingService while transaction is present");

                try
                {
                    DisposeTransactionScope(transactionalProperties);

                    // roll back transaction
                    System.Transactions.Transaction transaction = transactionalProperties.Transaction;
                    if (System.Transactions.TransactionStatus.Aborted != transaction.TransactionInformation.Status)
                        transaction.Rollback();
                    WorkflowTrace.Runtime.TraceEvent(TraceEventType.Information, 0,
                        "Workflow Runtime: WorkflowExecutor: instanceId: " + this.InstanceIdString +
                        " .Aborted enlistable transaction " +
                        ((System.Transactions.Transaction)transaction).GetHashCode());
                }
                finally
                {
                    // roolback queuing service state
                    WorkflowQueuingService queuingService = transactionalProperties.LocalQueuingService;
                    queuingService.Complete(false);

                    // dispose transaction. However, do not reset the currentAtomicActivity member here
                    // because a complete reversal of a TransactionScopeActivity will restore the 
                    // workflow instance state to a prior checkpointed state.                    
                    DisposeTransaction(this.currentAtomicActivity);
                }
            }
        }
开发者ID:uQr,项目名称:referencesource,代码行数:46,代码来源:WorkflowExecutor.cs

示例7: CommitTransaction

        private void CommitTransaction(Activity activityContext)
        {
            if (null == Transaction.Current)
            {
                //
                // No TxScopeActivity or external tx
                // Ask the TxService to commit
                // In this scenario retries are OK as it owns the tx
                try
                {
                    //
                    // Pass a delegate that does the batch commit 
                    // so that it can do retries
                    this.WorkflowRuntime.TransactionService.CommitWorkBatch(DoResourceManagerCommit);
                    this.ResourceManager.Complete();
                }
                catch
                {
                    this.ResourceManager.HandleFault();
                    throw;
                }
            }
            else
            {
                Debug.Assert(activityContext != null, "null activityContext");

                TransactionalProperties transactionalProperties = null;
                bool inTxScope = (activityContext == this.currentAtomicActivity);
                //
                // Tx is either from TxScopeActivity or it is external                
                if (inTxScope)
                {
                    transactionalProperties = (TransactionalProperties)activityContext.GetValue(TransactionalPropertiesProperty);
                    if (CheckAndProcessTransactionAborted(transactionalProperties))
                        return;
                }
                //
                // Commit the batches and rely on the enlistment to do completion/rollback work for the batches
                // TxService must use the ambient transaction directly or do a dependent clone.
                try
                {
                    this.WorkflowRuntime.TransactionService.CommitWorkBatch(DoResourceManagerCommit);
                }
                catch
                {
                    //
                    // This tx is doomed, clean up batches
                    ResourceManager.HandleFault();
                    throw;
                }
                finally
                {
                    if (inTxScope)
                    {
                        // DTC transaction commit needs to be done after TransactionScope Complete
                        // because the Commit Voting needs to happen on the the original thread 
                        // that created the transaction.  Otherwise the transaction will abort after timing out.
                        Debug.Assert(null != transactionalProperties, "TransactionProperties from TransactionScopeActivity should not be null.");
                        DisposeTransactionScope(transactionalProperties);
                    }
                }
                //
                // If we are in a tx scope we need to commit our tx
                if (inTxScope)
                {
                    //
                    // The tx will be Committable if there was not ambient tx when the scope started
                    // It will be Dependent if there was an ambient tx when the scope started
                    // (The external case is explicitly disabled for V1)
                    try
                    {
                        CommittableTransaction ctx = transactionalProperties.Transaction as CommittableTransaction;
                        if (null != ctx)
                        {
                            try
                            {
                                ctx.Commit();
                            }
                            catch
                            {
                                qService.PostPersist(false);
                                throw;
                            }

                            WorkflowTrace.Runtime.TraceEvent(TraceEventType.Information, 0,
                                "Workflow Runtime: WorkflowExecutor: instanceId: " + this.InstanceIdString +
                                " .Committed CommittableTransaction " +
                                ((System.Transactions.Transaction)transactionalProperties.Transaction).GetHashCode());
                        }

                        DependentTransaction dtx = transactionalProperties.Transaction as DependentTransaction;
                        if (null != dtx)
                        {
                            try
                            {
                                dtx.Complete();
                            }
                            catch
                            {
                                qService.PostPersist(false);
//.........这里部分代码省略.........
开发者ID:uQr,项目名称:referencesource,代码行数:101,代码来源:WorkflowExecutor.cs

示例8: DisposeTransaction

        private void DisposeTransaction(Activity atomicActivity)
        {
            // Validates the assumption that only one atomic activity in execution at a time
            //Debug.Assert((atomicActivity == this.currentAtomicActivity),
            //    "Activity context " + atomicActivity.Name + " different from currentAtomicActivity " + this.currentAtomicActivity.Name);

            // Cleanup work following a transaction commit or Rollback
            TransactionalProperties transactionalProperties = (TransactionalProperties)atomicActivity.GetValue(TransactionalPropertiesProperty);

            // release transaction
            transactionalProperties.Transaction.Dispose();
            WorkflowTrace.Runtime.TraceEvent(TraceEventType.Information, 0,
                "Workflow Runtime: WorkflowExecutor: instanceId: " + this.InstanceIdString +
                " .Disposed enlistable transaction " +
                ((System.Transactions.Transaction)transactionalProperties.Transaction).GetHashCode());

            // cleanup properties
            transactionalProperties.Transaction = null;
            transactionalProperties.LocalQueuingService = null;
            transactionalProperties.Transaction = null;

            // We no longer clear the currentAtomicActivity member here
            // but only in the callers of this method (CommitTransaction and RollbackTransaction).
            // However, we do this only in CommitTransaction but omit resetting it in RollbackTransaction
            // because a complete reversal of a TransactionScopeActivity will restore the 
            // workflow instance state to a prior checkpointed state.
            atomicActivityEvent.Set();
            atomicActivityEvent.Close();

        }
开发者ID:uQr,项目名称:referencesource,代码行数:30,代码来源:WorkflowExecutor.cs

示例9: ProcessDefTag

        internal static void ProcessDefTag(WorkflowMarkupSerializationManager serializationManager, XmlReader reader, Activity activity, bool newSegment, string fileName)
        {
            System.Resources.ResourceManager resourceManager = new System.Resources.ResourceManager("System.Workflow.ComponentModel.StringResources", typeof(System.Workflow.ComponentModel.ActivityBind).Assembly);
            if (reader.NodeType == XmlNodeType.Attribute)
            {
                switch (reader.LocalName)
                {
                    case StandardXomlKeys.Definitions_Class_LocalName:
                        activity.SetValue(WorkflowMarkupSerializer.XClassProperty, reader.Value);
                        break;
                    default:
                        serializationManager.ReportError(new WorkflowMarkupSerializationException(string.Format(CultureInfo.CurrentCulture, resourceManager.GetString("UnknownDefinitionTag"), new object[] { StandardXomlKeys.Definitions_XmlNs_Prefix, reader.LocalName, StandardXomlKeys.Definitions_XmlNs }), (reader is IXmlLineInfo) ? ((IXmlLineInfo)reader).LineNumber : 1, (reader is IXmlLineInfo) ? ((IXmlLineInfo)reader).LinePosition : 1));
                        break;
                }
                return;
            }

            bool exitLoop = false;
            bool isEmptyElement = reader.IsEmptyElement;
            int initialDepth = reader.Depth;
            do
            {
                XmlNodeType currNodeType = reader.NodeType;
                switch (currNodeType)
                {
                    case XmlNodeType.Element:
                        {
                            /*
                            if (!reader.LocalName.Equals(localName))
                            {
                                serializationManager.ReportError(new WorkflowMarkupSerializationException(string.Format(resourceManager.GetString("DefnTagsCannotBeNested"), "def", localName, reader.LocalName), reader.LineNumber, reader.LinePosition));
                                return;
                            }
                            */

                            switch (reader.LocalName)
                            {
                                case StandardXomlKeys.Definitions_Code_LocalName:
                                    break;

                                case "Constructor":
                                default:
                                    serializationManager.ReportError(new WorkflowMarkupSerializationException(string.Format(CultureInfo.CurrentCulture, resourceManager.GetString("UnknownDefinitionTag"), StandardXomlKeys.Definitions_XmlNs_Prefix, reader.LocalName, StandardXomlKeys.Definitions_XmlNs), (reader is IXmlLineInfo) ? ((IXmlLineInfo)reader).LineNumber : 1, (reader is IXmlLineInfo) ? ((IXmlLineInfo)reader).LinePosition : 1));
                                    return;
                            }

                            // if an empty element do a Reader then exit
                            if (isEmptyElement)
                                exitLoop = true;
                            break;
                        }

                    case XmlNodeType.EndElement:
                        {
                            //reader.Read();
                            if (reader.Depth == initialDepth)
                                exitLoop = true;
                            break;
                        }

                    case XmlNodeType.CDATA:
                    case XmlNodeType.Text:
                        {
                            // 


                            int lineNumber = (reader is IXmlLineInfo) ? ((IXmlLineInfo)reader).LineNumber : 1;
                            int linePosition = (reader is IXmlLineInfo) ? ((IXmlLineInfo)reader).LinePosition : 1;
                            CodeSnippetTypeMember codeSegment = new CodeSnippetTypeMember(reader.Value);
                            codeSegment.LinePragma = new CodeLinePragma(fileName, Math.Max(lineNumber - 1, 1));
                            codeSegment.UserData[UserDataKeys.CodeSegment_New] = newSegment;
                            codeSegment.UserData[UserDataKeys.CodeSegment_ColumnNumber] = linePosition + reader.Name.Length - 1;

                            CodeTypeMemberCollection codeSegments = activity.GetValue(WorkflowMarkupSerializer.XCodeProperty) as CodeTypeMemberCollection;
                            if (codeSegments == null)
                            {
                                codeSegments = new CodeTypeMemberCollection();
                                activity.SetValue(WorkflowMarkupSerializer.XCodeProperty, codeSegments);
                            }
                            codeSegments.Add(codeSegment);
                            //}
                            /*else
                            {
                                serializationManager.ReportError( new WorkflowMarkupSerializationException(
                                                                            string.Format(resourceManager.GetString("IllegalCDataTextScoping"), 
                                                                                        "def", 
                                                                                        reader.LocalName,
                                                                                        (currNodeType == XmlNodeType.CDATA ? resourceManager.GetString("CDATASection") : resourceManager.GetString("TextSection"))), 
                                                                            reader.LineNumber, 
                                                                            reader.LinePosition)
                                                                );
                            }
                            */
                            break;
                        }
                }
            }
            while (!exitLoop && reader.Read());
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:99,代码来源:XomlSerializationHelpers.cs

示例10: GenerateCodeFromXomlDocument

        internal static CodeNamespaceCollection GenerateCodeFromXomlDocument(Activity rootActivity, string filePath, string rootNamespace, SupportedLanguages language, IServiceProvider serviceProvider)
        {
            CodeNamespaceCollection codeNamespaces = new CodeNamespaceCollection();
            CodeDomProvider codeDomProvider = CompilerHelpers.GetCodeDomProvider(language);

            // generate activity class
            string activityFullClassName = rootActivity.GetValue(WorkflowMarkupSerializer.XClassProperty) as string;
            CodeTypeDeclaration activityTypeDeclaration = null;
            if (codeDomProvider != null && !string.IsNullOrEmpty(activityFullClassName))
            {
                // get class and namespace names
                string activityNamespaceName, activityClassName;
                Helpers.GetNamespaceAndClassName(activityFullClassName, out activityNamespaceName, out activityClassName);
                if (codeDomProvider.IsValidIdentifier(activityClassName))
                {
                    DesignerSerializationManager designerSerializationManager = new DesignerSerializationManager(serviceProvider);
                    using (designerSerializationManager.CreateSession())
                    {
                        ActivityCodeDomSerializationManager codeDomSerializationManager = new ActivityCodeDomSerializationManager(designerSerializationManager);
                        TypeCodeDomSerializer typeCodeDomSerializer = codeDomSerializationManager.GetSerializer(rootActivity.GetType(), typeof(TypeCodeDomSerializer)) as TypeCodeDomSerializer;

                        // get all activities
                        bool generateCode = true;

                        ArrayList allActivities = new ArrayList();
                        allActivities.Add(rootActivity);
                        if (rootActivity is CompositeActivity)
                        {
                            foreach (Activity activity in Helpers.GetNestedActivities((CompositeActivity)rootActivity))
                            {
                                if (Helpers.IsActivityLocked(activity))
                                    continue;
                                if (codeDomProvider.IsValidIdentifier(codeDomSerializationManager.GetName(activity)))
                                {
                                    // WinOE Bug 14561.  This is to fix a performance problem.  When an activity is added to the activity
                                    // tree at the runtime, it's much faster if the ID of the activity is already set.  The code that
                                    // the CodeDomSerializer generates will add the activity first before it sets the ID for the child
                                    // activity.  We can change that order by always serializing the children first.  Therefore, we 
                                    // construct a list where we guarantee that the child will be serialized before its parent.
                                    allActivities.Insert(0, activity);
                                }
                                else
                                {
                                    generateCode = false;
                                    break;
                                }
                            }
                        }

                        if (generateCode)
                        {
                            // Work around!! TypeCodeDomSerializer checks that root component has a site or not, otherwise it
                            // does not serialize it look at ComponentTypeCodeDomSerializer.cs
                            DummySite dummySite = new DummySite();
                            foreach (Activity nestedActivity in allActivities)
                                ((IComponent)nestedActivity).Site = dummySite;
                            ((IComponent)rootActivity).Site = dummySite;

                            // create activity partial class
                            activityTypeDeclaration = typeCodeDomSerializer.Serialize(codeDomSerializationManager, rootActivity, allActivities);
                            activityTypeDeclaration.IsPartial = true;

                            // add checksum attribute
                            if (filePath != null && filePath.Length > 0)
                            {
                                MD5 md5 = new MD5CryptoServiceProvider();
                                byte[] checksumBytes = null;
                                using (StreamReader streamReader = new StreamReader(filePath))
                                    checksumBytes = md5.ComputeHash(streamReader.BaseStream);
                                string checksum = string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}", new object[] { checksumBytes[0].ToString("X2", CultureInfo.InvariantCulture), checksumBytes[1].ToString("X2", CultureInfo.InvariantCulture), checksumBytes[2].ToString("X2", CultureInfo.InvariantCulture), checksumBytes[3].ToString("X2", CultureInfo.InvariantCulture), checksumBytes[4].ToString("X2", CultureInfo.InvariantCulture), checksumBytes[5].ToString("X2", CultureInfo.InvariantCulture), checksumBytes[6].ToString("X2", CultureInfo.InvariantCulture), checksumBytes[7].ToString("X2", CultureInfo.InvariantCulture), checksumBytes[8].ToString("X2", CultureInfo.InvariantCulture), checksumBytes[9].ToString("X2", CultureInfo.InvariantCulture), checksumBytes[10].ToString("X2", CultureInfo.InvariantCulture), checksumBytes[11].ToString("X2", CultureInfo.InvariantCulture), checksumBytes[12].ToString("X2", CultureInfo.InvariantCulture), checksumBytes[13].ToString("X2", CultureInfo.InvariantCulture), checksumBytes[14].ToString("X2", CultureInfo.InvariantCulture), checksumBytes[15].ToString("X2", CultureInfo.InvariantCulture) });
                                CodeAttributeDeclaration xomlSourceAttribute = new CodeAttributeDeclaration(typeof(WorkflowMarkupSourceAttribute).FullName);
                                xomlSourceAttribute.Arguments.Add(new CodeAttributeArgument(new CodePrimitiveExpression(filePath)));
                                xomlSourceAttribute.Arguments.Add(new CodeAttributeArgument(new CodePrimitiveExpression(checksum)));
                                activityTypeDeclaration.CustomAttributes.Add(xomlSourceAttribute);
                            }

                            // create a new namespace and add activity class into that
                            CodeNamespace activityCodeNamespace = new CodeNamespace(activityNamespaceName);
                            activityCodeNamespace.Types.Add(activityTypeDeclaration);
                            codeNamespaces.Add(activityCodeNamespace);
                        }
                    }
                }
            }

            // generate code for x:Code
            if (activityTypeDeclaration != null)
            {
                Queue activitiesQueue = new Queue(new object[] { rootActivity });
                while (activitiesQueue.Count > 0)
                {
                    Activity activity = (Activity)activitiesQueue.Dequeue();
                    if (Helpers.IsActivityLocked(activity))
                        continue;

                    Queue childActivities = new Queue(new object[] { activity });
                    while (childActivities.Count > 0)
                    {
                        Activity childActivity = (Activity)childActivities.Dequeue();
                        if (childActivity is CompositeActivity)
//.........这里部分代码省略.........
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:101,代码来源:XomlSerializationHelpers.cs

示例11: AddActivityToDesigner

        public void AddActivityToDesigner(Activity activity)
        {
            if (activity == null)
                throw new ArgumentNullException("activity");

            IDesignerHost designerHost = GetService(typeof(IDesignerHost)) as IDesignerHost;
            if (designerHost == null)
                throw new InvalidOperationException(SR.GetString(SR.General_MissingService, typeof(IDesignerHost).FullName));

            if (activity.Parent == null && designerHost.RootComponent == null)
            {
                string fullClassName = activity.GetValue(WorkflowMarkupSerializer.XClassProperty) as String;
                string rootSiteName = (!string.IsNullOrEmpty(fullClassName)) ? Helpers.GetClassName(fullClassName) : Helpers.GetClassName(activity.GetType().FullName);
                designerHost.Container.Add(activity, rootSiteName);
                AddTargetFrameworkProvider(activity);
            }
            else
            {
                designerHost.Container.Add(activity, activity.QualifiedName);
                AddTargetFrameworkProvider(activity);
            }

            if (activity is CompositeActivity)
            {
                foreach (Activity activity2 in Helpers.GetNestedActivities(activity as CompositeActivity))
                {
                    designerHost.Container.Add(activity2, activity2.QualifiedName);
                    AddTargetFrameworkProvider(activity2);
                }
            }
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:31,代码来源:XomlDesignerLoader.cs


注:本文中的Activity.GetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。