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


C# Activity.GetType方法代码示例

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


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

示例1: printActivityTree

        static void printActivityTree(Activity activity, string tag)
        {
            Console.WriteLine("{0} DisplayName:{1},type:{2}", tag, activity.DisplayName, activity.GetType());

            System.Collections.Generic.IEnumerator<Activity> list = WorkflowInspectionServices.GetActivities(activity).GetEnumerator();

            while (list.MoveNext())
            {
                printActivityTree(list.Current, "  " + tag);
            }
        }
开发者ID:xiluo,项目名称:document-management,代码行数:11,代码来源:xamlTool.cs

示例2: ChannelActivity

        /// <summary>
        /// Initializes a new instance of the <see cref="ChannelActivity" /> class.
        /// </summary>
        /// <param name="activity">The activity.</param>
        /// <param name="level">The level.</param>
        internal ChannelActivity(Activity activity, int level = 0)
        {
            Id = activity.Id;
            DisplayName = activity.DisplayName;
            ActivityType = activity.GetType().Name;
            Level = level;

            Children = WorkflowInspectionServices.GetActivities(activity)
                .Select(child => new ChannelActivity(child, level+1) as IChannelActivity)
                .ToList();
        }
开发者ID:bradsjm,项目名称:DataflowPipe,代码行数:16,代码来源:ChannelActivity.cs

示例3: VerifyParentIsObjectContextScope

        public static Constraint VerifyParentIsObjectContextScope(Activity activity)
        {
            DelegateInArgument<Activity> element = new DelegateInArgument<Activity>();
            DelegateInArgument<ValidationContext> context = new DelegateInArgument<ValidationContext>();
            DelegateInArgument<Activity> child = new DelegateInArgument<Activity>();
            Variable<bool> result = new Variable<bool>();

            return new Constraint<Activity>
            {
                Body = new ActivityAction<Activity, ValidationContext>
                {
                    Argument1 = element,
                    Argument2 = context,
                    Handler = new Sequence
                    {
                        Variables = { result },
                        Activities =
                        {
                            new ForEach<Activity>
                            {
                                Values = new GetParentChain
                                {
                                    ValidationContext = context
                                },
                                Body = new ActivityAction<Activity>
                                {
                                    Argument = child,
                                    Handler = new If
                                    {
                                        Condition = new InArgument<bool>((env) => object.Equals(child.Get(env).GetType(), typeof(ObjectContextScope))),
                                        Then = new Assign<bool>
                                        {
                                            Value = true,
                                            To = result
                                        }
                                    }
                                }
                            },
                            new AssertValidation
                            {
                                Assertion = new InArgument<bool>(env => result.Get(env)),
                                Message = new InArgument<string> (string.Format("{0} can only be added inside an ObjectContextScope activity.", activity.GetType().Name)),
                                PropertyName = new InArgument<string>((env) => element.Get(env).DisplayName)
                            }
                        }
                    }
                }
            };
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:49,代码来源:ConstraintHelper.cs

示例4: RunInActivityController

		public virtual bool RunInActivityController(Activity activity)
		{
			if (activity != null)
			{
				string name = activity.GetType().Name;
				if (!this._inProcActivityLookup.ContainsKey(name))
				{
					ActivityRunMode activityRunMode = this._runtime.Configuration.GetActivityRunMode(activity);
					bool flag = activityRunMode == ActivityRunMode.InProcess;
					return this._inProcActivityLookup.GetOrAdd(name, flag);
				}
				else
				{
					return this._inProcActivityLookup[name];
				}
			}
			else
			{
				throw new ArgumentNullException("activity");
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:21,代码来源:PSActivityHostController.cs

示例5: CheckIfSuspendable

        private bool CheckIfSuspendable(Activity activity)
        {
            if (string.Equals(activity.GetType().ToString(), "Microsoft.PowerShell.Activities.PSPersist", StringComparison.OrdinalIgnoreCase))
            {
                return true;
            }

            if (string.Equals(activity.GetType().ToString(), "Microsoft.PowerShell.Activities.Suspend", StringComparison.OrdinalIgnoreCase))
            {
                return true;
            }

            PSActivity psactivity = activity as PSActivity;
            if (psactivity != null && psactivity.PSPersist != null && psactivity.PSPersist.Expression != null)
            {
                return true;
            }

            Sequence seqActivity = activity as Sequence;
            if (seqActivity != null && seqActivity.Variables != null && seqActivity.Variables.Count > 0)
            {
                foreach (Variable var in seqActivity.Variables)
                {
                    if (string.Equals(var.Name, WorkflowPreferenceVariables.PSPersistPreference, StringComparison.OrdinalIgnoreCase))
                        return true;
                }
            }
            
            Parallel parActivity = activity as Parallel;
            if (parActivity != null && parActivity.Variables != null && parActivity.Variables.Count > 0)
            {
                foreach (Variable var in parActivity.Variables)
                {
                    if (string.Equals(var.Name, WorkflowPreferenceVariables.PSPersistPreference, StringComparison.OrdinalIgnoreCase))
                        return true;
                }
            }

            return false;
        }
开发者ID:40a,项目名称:PowerShell,代码行数:40,代码来源:WorkflowValidation.cs

示例6: ValidateActivity

        private bool ValidateActivity(Activity activity, string runtimeAssembly, PSWorkflowValidationResults validationResult)
        {
            if (validationResult != null && validationResult.IsWorkflowSuspendable == false)
            {
                validationResult.IsWorkflowSuspendable = CheckIfSuspendable(activity);
            }

            bool allowed = false;
            Type activityType = activity.GetType();

            // If there is a custom validator activity, then call it. If it returns true
            // then just return the activity.
            if (Validation.CustomHandler != null && Validation.CustomHandler.Invoke(activity))
            {
                allowed = true;
            }
            else if (MandatorySystemActivities.Contains(activityType.Name))
            {
                allowed = true;
            }
            else if (string.Equals(activityType.Assembly.FullName, "System.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", StringComparison.OrdinalIgnoreCase))
            {
                allowed = AllowedSystemActivities.Contains(activityType.Name);
            }
            else if (string.Equals(runtimeAssembly, activityType.Assembly.GetName().Name, StringComparison.OrdinalIgnoreCase))
            {
                // Allow the activities which belong to runtime assembly containing dependent Xamls.
                allowed = true;
            }
            else if (Configuration.PSDefaultActivitiesAreAllowed
              && PowerShellActivitiesAssemblies.Contains(activityType.Assembly.GetName().Name.ToLowerInvariant()))
            {
                // Allow any of the activities from our product assemblies provided that product activities were
                // specified as allowed activities
                allowed = true;
            }
            else
            {
                //  Check if the activityId matches any activity in the allowed list
                //  as a full name or as  pattern.
                foreach (string allowedActivity in Configuration.AllowedActivity ?? new string[0])
                {
                    // skipping * because it has already been checked above
                    if (string.Equals(allowedActivity, PSWorkflowConfigurationProvider.PSDefaultActivities, StringComparison.OrdinalIgnoreCase))
                        continue;

                    if (activity is System.Activities.Activity)
                    {
                        if (false
                            || IsMatched(allowedActivity, activityType.Name)
                            || IsMatched(allowedActivity, activityType.FullName)
                            || IsMatched(allowedActivity, activityType.Assembly.GetName().Name + "\\" + activityType.Name)
                            || IsMatched(allowedActivity, activityType.Assembly.GetName().Name + "\\" + activityType.FullName)
                            || IsMatched(allowedActivity, activityType.Assembly.GetName().FullName + "\\" + activityType.Name)
                            || IsMatched(allowedActivity, activityType.Assembly.GetName().FullName + "\\" + activityType.FullName))
                        {
                            allowed = true;
                            break;
                        }
                    }
                }
            }

            string displayName = activity.DisplayName;

            if (string.IsNullOrEmpty(displayName))
                displayName = this.GetType().Name;

            if (allowed)
            {
                _structuredTracer.WorkflowActivityValidated(Guid.Empty, displayName, activityType.FullName);
            }
            else
            {
                _structuredTracer.WorkflowActivityValidationFailed(Guid.Empty, displayName, activityType.FullName);
            }

            return allowed;
        }
开发者ID:40a,项目名称:PowerShell,代码行数:79,代码来源:WorkflowValidation.cs

示例7: AssertIsCodeActivity

 static void AssertIsCodeActivity(Activity activity)
 {
     Type codeActivityOfTType = null;
     ActivityWithResult activityWithResult = activity as ActivityWithResult;
     if (activityWithResult != null)
     {
         codeActivityOfTType = typeof(CodeActivity<>).MakeGenericType(activityWithResult.ResultType);
     }
     Fx.Assert(activity is CodeActivity || (codeActivityOfTType != null && codeActivityOfTType.IsAssignableFrom(activity.GetType())), "Expected CodeActivity or CodeActivity<T>");
 }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:10,代码来源:CodeActivityPublicEnvironmentAccessor.cs

示例8: RunInActivityController

        public virtual bool RunInActivityController(Activity activity)
        {
            if (activity == null)
            {
                throw new ArgumentNullException("activity");
            }

            String name = activity.GetType().Name;

            if (_inProcActivityLookup.ContainsKey(name)) return _inProcActivityLookup[name];


            ActivityRunMode runMode = _runtime.Configuration.GetActivityRunMode(activity);
            bool runInProc = runMode == ActivityRunMode.InProcess;

            return _inProcActivityLookup.GetOrAdd(name, runInProc);
        }
开发者ID:dfinke,项目名称:powershell,代码行数:17,代码来源:PSActivityHostManager.cs

示例9: PublishAndCollectMapping

 private static Dictionary<object, SourceLocation> PublishAndCollectMapping(Activity activity, string path)
 {
     Dictionary<object, SourceLocation> mapping = new Dictionary<object, SourceLocation>();
     using (MemoryStream stream = new MemoryStream())
     {
         Serialize(stream, activity);
         stream.Position = 0L;
         Activity activity2 = Deserialize(stream.GetBuffer(), activity.GetType().Assembly) as Activity;
         using (StreamWriter writer = new StreamWriter(path))
         {
             stream.Position = 0L;
             using (StreamReader reader = new StreamReader(stream))
             {
                 writer.Write(reader.ReadToEnd());
             }
         }
         CollectMapping(activity, activity2, mapping, path);
     }
     return mapping;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:20,代码来源:SourceLocationProvider.cs

示例10: GetSourceLocations

 internal static Dictionary<object, SourceLocation> GetSourceLocations(Activity rootActivity, out string sourcePath, out bool isTemporaryFile)
 {
     sourcePath = XamlDebuggerXmlReader.GetFileName(rootActivity) as string;
     isTemporaryFile = false;
     Assembly localAssembly = rootActivity.GetType().Assembly;
     if (rootActivity.Parent != null)
     {
         localAssembly = rootActivity.Parent.GetType().Assembly;
     }
     if ((rootActivity.Children != null) && (rootActivity.Children.Count > 0))
     {
         Activity instance = rootActivity.Children[0];
         string fileName = XamlDebuggerXmlReader.GetFileName(instance) as string;
         if (!string.IsNullOrEmpty(fileName))
         {
             rootActivity = instance;
             sourcePath = fileName;
         }
     }
     if (!string.IsNullOrEmpty(sourcePath))
     {
         SourceLocation location;
         Activity workflowRoot;
         if (TryGetSourceLocation(rootActivity, sourcePath, out location))
         {
             workflowRoot = rootActivity;
         }
         else
         {
             FileInfo info = new FileInfo(sourcePath);
             byte[] buffer = new byte[info.Length];
             using (FileStream stream = new FileStream(sourcePath, FileMode.Open, FileAccess.Read))
             {
                 stream.Read(buffer, 0, buffer.Length);
             }
             object obj2 = Deserialize(buffer, localAssembly);
             IDebuggableWorkflowTree tree = obj2 as IDebuggableWorkflowTree;
             if (tree != null)
             {
                 workflowRoot = tree.GetWorkflowRoot();
             }
             else
             {
                 workflowRoot = obj2 as Activity;
             }
         }
         Dictionary<object, SourceLocation> mapping = new Dictionary<object, SourceLocation>();
         if (workflowRoot != null)
         {
             CollectMapping(rootActivity, workflowRoot, mapping, sourcePath);
         }
         return mapping;
     }
     string tempFileName = Path.GetTempFileName();
     sourcePath = Path.ChangeExtension(tempFileName, ".xaml");
     File.Move(tempFileName, sourcePath);
     isTemporaryFile = true;
     return PublishAndCollectMapping(rootActivity, sourcePath);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:59,代码来源:SourceLocationProvider.cs

示例11: IsActivityInlineScript

		internal static bool IsActivityInlineScript(Activity activity)
		{
			return string.Equals(activity.GetType().FullName, "Microsoft.PowerShell.Activities.InlineScript", StringComparison.OrdinalIgnoreCase);
		}
开发者ID:nickchal,项目名称:pash,代码行数:4,代码来源:PSActivity.cs

示例12: IsArgument

        /// <summary>
        /// Return activity has argment
        /// </summary>
        public static bool IsArgument(Activity arg)
        {
            Contract.Requires(arg != null);

               return (typeof(ActivityWithResult).IsAssignableFrom(arg.GetType()));
        }
开发者ID:barbarossia,项目名称:CWF,代码行数:9,代码来源:ArgumentService.cs

示例13: ValidateActivity

		private bool ValidateActivity(Activity activity, string runtimeAssembly, PSWorkflowValidationResults validationResult)
		{
			bool flag;
			if (validationResult != null && !validationResult.IsWorkflowSuspendable)
			{
				validationResult.IsWorkflowSuspendable = this.CheckIfSuspendable(activity);
			}
			Type type = activity.GetType();
			if (Validation.CustomHandler == null || !Validation.CustomHandler(activity))
			{
				if (!string.Equals(type.Assembly.FullName, "System.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", StringComparison.OrdinalIgnoreCase))
				{
					if (!string.Equals(runtimeAssembly, type.Assembly.GetName().Name, StringComparison.OrdinalIgnoreCase))
					{
						if (!this.Configuration.PSDefaultActivitiesAreAllowed || !PSWorkflowValidator.PowerShellActivitiesAssemblies.Contains(type.Assembly.GetName().Name.ToLowerInvariant()))
						{
							IEnumerable<string> allowedActivity = this.Configuration.AllowedActivity;
							IEnumerable<string> strs = allowedActivity;
							if (allowedActivity == null)
							{
								strs = (IEnumerable<string>)(new string[0]);
							}
							foreach (string str in strs)
							{
								if (string.Equals(str, "PSDefaultActivities", StringComparison.OrdinalIgnoreCase) || activity == null || !PSWorkflowValidator.IsMatched(str, type.Name) && !PSWorkflowValidator.IsMatched(str, type.FullName) && !PSWorkflowValidator.IsMatched(str, string.Concat(type.Assembly.GetName().Name, "\\", type.Name)) && !PSWorkflowValidator.IsMatched(str, string.Concat(type.Assembly.GetName().Name, "\\", type.FullName)) && !PSWorkflowValidator.IsMatched(str, string.Concat(type.Assembly.GetName().FullName, "\\", type.Name)) && !PSWorkflowValidator.IsMatched(str, string.Concat(type.Assembly.GetName().FullName, "\\", type.FullName)))
								{
									continue;
								}
								flag = true;
								break;
							}
						}
						else
						{
							flag = true;
						}
					}
					else
					{
						flag = true;
					}
				}
				else
				{
					flag = PSWorkflowValidator.AllowedSystemActivities.Contains(type.Name);
				}
			}
			else
			{
				flag = true;
			}
			string displayName = activity.DisplayName;
			if (string.IsNullOrEmpty(displayName))
			{
				displayName = this.GetType().Name;
			}
			if (!flag)
			{
				PSWorkflowValidator._structuredTracer.WorkflowActivityValidationFailed(Guid.Empty, displayName, type.FullName);
			}
			else
			{
				PSWorkflowValidator._structuredTracer.WorkflowActivityValidated(Guid.Empty, displayName, type.FullName);
			}
			return flag;
		}
开发者ID:nickchal,项目名称:pash,代码行数:66,代码来源:PSWorkflowValidator.cs

示例14: CheckIfSuspendable

		private bool CheckIfSuspendable(Activity activity)
		{
			bool flag;
			if (!string.Equals(activity.GetType().ToString(), "Microsoft.PowerShell.Activities.PSPersist", StringComparison.OrdinalIgnoreCase))
			{
				if (!string.Equals(activity.GetType().ToString(), "Microsoft.PowerShell.Activities.Suspend", StringComparison.OrdinalIgnoreCase))
				{
					PSActivity pSActivity = activity as PSActivity;
					if (pSActivity == null || pSActivity.PSPersist == null || pSActivity.PSPersist.Expression == null)
					{
						Sequence sequence = activity as Sequence;
						if (sequence != null && sequence.Variables != null && sequence.Variables.Count > 0)
						{
							foreach (Variable variable in sequence.Variables)
							{
								if (!string.Equals(variable.Name, "PSPersistPreference", StringComparison.OrdinalIgnoreCase))
								{
									continue;
								}
								flag = true;
								return flag;
							}
						}
						Parallel parallel = activity as Parallel;
						if (parallel != null && parallel.Variables != null && parallel.Variables.Count > 0)
						{
							foreach (Variable variable1 in parallel.Variables)
							{
								if (!string.Equals(variable1.Name, "PSPersistPreference", StringComparison.OrdinalIgnoreCase))
								{
									continue;
								}
								flag = true;
								return flag;
							}
						}
						return false;
					}
					else
					{
						return true;
					}
				}
				else
				{
					return true;
				}
			}
			else
			{
				return true;
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:53,代码来源:PSWorkflowValidator.cs

示例15: IsParallelActivity

 private static bool IsParallelActivity(Activity activity)
 {
     return ((activity is Parallel) || (activity.GetType().IsGenericType && (activity.GetType().GetGenericTypeDefinition() == typeof(ParallelForEach<>))));
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:4,代码来源:DebugManager.cs


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