예제 #1
0
        private void OnComponentAdded(object sender, ComponentEventArgs eventArgs)
        {
            IDesignerHost service = (IDesignerHost)this.serviceProvider.GetService(typeof(IDesignerHost));

            if (service != null)
            {
                if (service.RootComponent == eventArgs.Component)
                {
                    Activity rootComponent = service.RootComponent as Activity;
                    if (rootComponent != null)
                    {
                        if ((rootComponent is CompositeActivity) && (this.ensureChildHierarchyHandler == null))
                        {
                            this.ensureChildHierarchyHandler = new EventHandler(this.OnEnsureChildHierarchy);
                            Application.Idle += this.ensureChildHierarchyHandler;
                        }
                        rootComponent.UserData[UserDataKeys.CustomActivity] = false;
                    }
                }
                else if (eventArgs.Component is Activity)
                {
                    if ((eventArgs.Component is CompositeActivity) && Helpers.IsCustomActivity(eventArgs.Component as CompositeActivity))
                    {
                        (eventArgs.Component as Activity).UserData[UserDataKeys.CustomActivity] = true;
                    }
                    else
                    {
                        (eventArgs.Component as Activity).UserData[UserDataKeys.CustomActivity] = false;
                    }
                }
            }
        }
 private static bool IsPreBuiltActivity(Activity activity)
 {
     for (CompositeActivity activity2 = activity.Parent; activity2 != null; activity2 = activity2.Parent)
     {
         if (Helpers.IsCustomActivity(activity2))
         {
             return(true);
         }
     }
     return(false);
 }
        private static bool IsPreBuiltActivity(Activity activity)
        {
            CompositeActivity parent = activity.Parent;

            while (parent != null)
            {
                // Any custom activity found, then locked
                if (Helpers.IsCustomActivity(parent))
                {
                    return(true);
                }

                parent = parent.Parent;
            }

            return(false);
        }
        internal static Activity ParseActivity(Activity parsingContext, string activityName)
        {
            if (parsingContext == null)
            {
                throw new ArgumentNullException("parsingContext");
            }
            if (activityName == null)
            {
                throw new ArgumentNullException("activityName");
            }
            string id    = activityName;
            string str2  = string.Empty;
            int    index = activityName.IndexOf(".");

            if (index != -1)
            {
                id   = activityName.Substring(0, index);
                str2 = activityName.Substring(index + 1);
                if (str2.Length == 0)
                {
                    return(null);
                }
            }
            Activity containerActivity = null;

            containerActivity = GetActivity(parsingContext, id);
            if (((containerActivity == null) && (parsingContext is CompositeActivity)) && ((parsingContext.Parent != null) && Helpers.IsCustomActivity(parsingContext as CompositeActivity)))
            {
                containerActivity = GetActivity(parsingContext, parsingContext.QualifiedName + "." + id);
            }
            if (containerActivity == null)
            {
                return(null);
            }
            if (str2.Length > 0)
            {
                if (!(containerActivity is CompositeActivity) || !Helpers.IsCustomActivity(containerActivity as CompositeActivity))
                {
                    return(null);
                }
                string[] strArray = str2.Split(new char[] { '.' });
                for (int i = 0; i < strArray.Length; i++)
                {
                    Activity activity = GetActivity(containerActivity, containerActivity.QualifiedName + "." + strArray[i]);
                    if ((activity == null) || !Helpers.IsActivityLocked(activity))
                    {
                        return(null);
                    }
                    CompositeActivity declaringActivity = Helpers.GetDeclaringActivity(activity);
                    if (containerActivity != declaringActivity)
                    {
                        return(null);
                    }
                    containerActivity = activity;
                }
                return(containerActivity);
            }
            if (Helpers.IsActivityLocked(containerActivity) && !IsDeclaringActivityMatchesContext(containerActivity, parsingContext))
            {
                return(null);
            }
            return(containerActivity);
        }
        private static bool IsDeclaringActivityMatchesContext(Activity currentActivity, Activity context)
        {
            CompositeActivity compositeActivity = context as CompositeActivity;
            CompositeActivity declaringActivity = Helpers.GetDeclaringActivity(currentActivity);

            if (Helpers.IsActivityLocked(context) && ((compositeActivity == null) || !Helpers.IsCustomActivity(compositeActivity)))
            {
                compositeActivity = Helpers.GetDeclaringActivity(context);
            }
            return(compositeActivity == declaringActivity);
        }