Ejemplo n.º 1
0
        public void Walk(Activity seedActivity, bool walkChildren)
        {
            Queue queue = new Queue();

            queue.Enqueue(seedActivity);
            while (queue.Count > 0)
            {
                Activity activity = queue.Dequeue() as Activity;

                if (FoundActivity != null)
                {
                    WalkerEventArgs args = new WalkerEventArgs(activity);
                    FoundActivity(this, args);
                    if (args.Action == WalkerAction.Abort)
                    {
                        return;
                    }
                    if (args.Action == WalkerAction.Skip)
                    {
                        continue;
                    }
                }

                if (FoundProperty != null)
                {
                    if (!WalkProperties(activity))
                    {
                        return;
                    }
                }

                if (walkChildren && activity is CompositeActivity)
                {
                    if (useEnabledActivities)
                    {
                        foreach (Activity activity2 in Design.Helpers.GetAllEnabledActivities((CompositeActivity)activity))
                        {
                            queue.Enqueue(activity2);
                        }
                    }
                    else
                    {
                        foreach (Activity activity2 in ((CompositeActivity)activity).Activities)
                        {
                            queue.Enqueue(activity2);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void Walk(Activity seedActivity, bool walkChildren)
        {
            Queue queue = new Queue();

            queue.Enqueue(seedActivity);
            while (queue.Count > 0)
            {
                Activity currentActivity = queue.Dequeue() as Activity;
                if (this.FoundActivity != null)
                {
                    WalkerEventArgs eventArgs = new WalkerEventArgs(currentActivity);
                    this.FoundActivity(this, eventArgs);
                    if (eventArgs.Action == WalkerAction.Abort)
                    {
                        return;
                    }
                    if (eventArgs.Action == WalkerAction.Skip)
                    {
                        continue;
                    }
                }
                if ((this.FoundProperty != null) && !this.WalkProperties(currentActivity))
                {
                    return;
                }
                if (walkChildren && (currentActivity is CompositeActivity))
                {
                    if (this.useEnabledActivities)
                    {
                        foreach (Activity activity2 in Helpers.GetAllEnabledActivities((CompositeActivity)currentActivity))
                        {
                            queue.Enqueue(activity2);
                        }
                    }
                    else
                    {
                        foreach (Activity activity3 in ((CompositeActivity)currentActivity).Activities)
                        {
                            queue.Enqueue(activity3);
                        }
                    }
                }
            }
        }
 public void Walk(Activity seedActivity, bool walkChildren)
 {
     Queue queue = new Queue();
     queue.Enqueue(seedActivity);
     while (queue.Count > 0)
     {
         Activity currentActivity = queue.Dequeue() as Activity;
         if (this.FoundActivity != null)
         {
             WalkerEventArgs eventArgs = new WalkerEventArgs(currentActivity);
             this.FoundActivity(this, eventArgs);
             if (eventArgs.Action == WalkerAction.Abort)
             {
                 return;
             }
             if (eventArgs.Action == WalkerAction.Skip)
             {
                 continue;
             }
         }
         if ((this.FoundProperty != null) && !this.WalkProperties(currentActivity))
         {
             return;
         }
         if (walkChildren && (currentActivity is CompositeActivity))
         {
             if (this.useEnabledActivities)
             {
                 foreach (Activity activity2 in Helpers.GetAllEnabledActivities((CompositeActivity) currentActivity))
                 {
                     queue.Enqueue(activity2);
                 }
             }
             else
             {
                 foreach (Activity activity3 in ((CompositeActivity) currentActivity).Activities)
                 {
                     queue.Enqueue(activity3);
                 }
             }
         }
     }
 }
Ejemplo n.º 4
0
        public bool WalkProperties(Activity activity, object obj)
        {
            Activity currentActivity = obj as Activity;

            PropertyInfo[] props = obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
            foreach (PropertyInfo prop in props)
            {
                // !!Work around: no indexer property walking
                if (prop.GetIndexParameters() != null && prop.GetIndexParameters().Length > 0)
                    continue;

                DesignerSerializationVisibility visibility = GetSerializationVisibility(prop);
                if (visibility == DesignerSerializationVisibility.Hidden)
                    continue;

                //Try to see if we have dynamic property associated with the object on the same object
                //if so then we should compare if the dynamic property values match with the property type
                //if not we bail out
                object propValue = null;
                DependencyProperty dependencyProperty = DependencyProperty.FromName(prop.Name, obj.GetType());
                if (dependencyProperty != null && currentActivity != null)
                {
                    if (currentActivity.IsBindingSet(dependencyProperty))
                        propValue = currentActivity.GetBinding(dependencyProperty);
                    else
                        propValue = currentActivity.GetValue(dependencyProperty);
                }
                else
                {
                    try
                    {
                        propValue = prop.CanRead ? prop.GetValue(obj, null) : null;
                    }
                    catch
                    {
                        // Eat exceptions that occur while invoking the getter.
                    }
                }

                if (FoundProperty != null)
                {
                    WalkerEventArgs args = new WalkerEventArgs(activity, propValue, prop, obj);
                    FoundProperty(this, args);
                    if (args.Action == WalkerAction.Skip)
                        continue;
                    else if (args.Action == WalkerAction.Abort)
                        return false;
                }

                if (propValue is IList)
                {
                    //We do not need to reflect on the properties of the list
                    foreach (object childObj in (IList)propValue)
                    {
                        if (FoundProperty != null)
                        {
                            WalkerEventArgs args = new WalkerEventArgs(activity, childObj, null, propValue);
                            FoundProperty(this, args);
                            if (args.Action == WalkerAction.Skip)
                                continue;
                            else if (args.Action == WalkerAction.Abort)
                                return false;
                        }
                        if (childObj != null && IsBrowsableType(childObj.GetType()))
                        {
                            if (!WalkProperties(activity, childObj))
                                return false;
                        }
                    }
                }
                else if (propValue != null && IsBrowsableType(propValue.GetType()))
                {
                    if (!WalkProperties(activity, propValue))
                        return false;
                }
            }
            return true;
        }
Ejemplo n.º 5
0
        public void Walk(Activity seedActivity, bool walkChildren)
        {
            Queue queue = new Queue();

            queue.Enqueue(seedActivity);
            while (queue.Count > 0)
            {
                Activity activity = queue.Dequeue() as Activity;

                if (FoundActivity != null)
                {
                    WalkerEventArgs args = new WalkerEventArgs(activity);
                    FoundActivity(this, args);
                    if (args.Action == WalkerAction.Abort)
                        return;
                    if (args.Action == WalkerAction.Skip)
                        continue;
                }

                if (FoundProperty != null)
                {
                    if (!WalkProperties(activity))
                        return;
                }

                if (walkChildren && activity is CompositeActivity)
                {
                    if (useEnabledActivities)
                    {
                        foreach (Activity activity2 in Design.Helpers.GetAllEnabledActivities((CompositeActivity)activity))
                            queue.Enqueue(activity2);
                    }
                    else
                    {
                        foreach (Activity activity2 in ((CompositeActivity)activity).Activities)
                            queue.Enqueue(activity2);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        public bool WalkProperties(Activity activity, object obj)
        {
            Activity currentActivity = obj as Activity;

            PropertyInfo[] props = obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
            foreach (PropertyInfo prop in props)
            {
                // !!Work around: no indexer property walking
                if (prop.GetIndexParameters() != null && prop.GetIndexParameters().Length > 0)
                {
                    continue;
                }

                DesignerSerializationVisibility visibility = GetSerializationVisibility(prop);
                if (visibility == DesignerSerializationVisibility.Hidden)
                {
                    continue;
                }

                //Try to see if we have dynamic property associated with the object on the same object
                //if so then we should compare if the dynamic property values match with the property type
                //if not we bail out
                object             propValue          = null;
                DependencyProperty dependencyProperty = DependencyProperty.FromName(prop.Name, obj.GetType());
                if (dependencyProperty != null && currentActivity != null)
                {
                    if (currentActivity.IsBindingSet(dependencyProperty))
                    {
                        propValue = currentActivity.GetBinding(dependencyProperty);
                    }
                    else
                    {
                        propValue = currentActivity.GetValue(dependencyProperty);
                    }
                }
                else
                {
                    try
                    {
                        propValue = prop.CanRead ? prop.GetValue(obj, null) : null;
                    }
                    catch
                    {
                        // Eat exceptions that occur while invoking the getter.
                    }
                }

                if (FoundProperty != null)
                {
                    WalkerEventArgs args = new WalkerEventArgs(activity, propValue, prop, obj);
                    FoundProperty(this, args);
                    if (args.Action == WalkerAction.Skip)
                    {
                        continue;
                    }
                    else if (args.Action == WalkerAction.Abort)
                    {
                        return(false);
                    }
                }

                if (propValue is IList)
                {
                    //We do not need to reflect on the properties of the list
                    foreach (object childObj in (IList)propValue)
                    {
                        if (FoundProperty != null)
                        {
                            WalkerEventArgs args = new WalkerEventArgs(activity, childObj, null, propValue);
                            FoundProperty(this, args);
                            if (args.Action == WalkerAction.Skip)
                            {
                                continue;
                            }
                            else if (args.Action == WalkerAction.Abort)
                            {
                                return(false);
                            }
                        }
                        if (childObj != null && IsBrowsableType(childObj.GetType()))
                        {
                            if (!WalkProperties(activity, childObj))
                            {
                                return(false);
                            }
                        }
                    }
                }
                else if (propValue != null && IsBrowsableType(propValue.GetType()))
                {
                    if (!WalkProperties(activity, propValue))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
 public bool WalkProperties(Activity activity, object obj)
 {
     Activity activity2 = obj as Activity;
     foreach (PropertyInfo info in obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance))
     {
         if (((info.GetIndexParameters() == null) || (info.GetIndexParameters().Length <= 0)) && (GetSerializationVisibility(info) != DesignerSerializationVisibility.Hidden))
         {
             object currentValue = null;
             DependencyProperty dependencyProperty = DependencyProperty.FromName(info.Name, obj.GetType());
             if ((dependencyProperty != null) && (activity2 != null))
             {
                 if (activity2.IsBindingSet(dependencyProperty))
                 {
                     currentValue = activity2.GetBinding(dependencyProperty);
                 }
                 else
                 {
                     currentValue = activity2.GetValue(dependencyProperty);
                 }
             }
             else
             {
                 try
                 {
                     currentValue = info.CanRead ? info.GetValue(obj, null) : null;
                 }
                 catch
                 {
                 }
             }
             if (this.FoundProperty != null)
             {
                 WalkerEventArgs eventArgs = new WalkerEventArgs(activity, currentValue, info, obj);
                 this.FoundProperty(this, eventArgs);
                 if (eventArgs.Action == WalkerAction.Skip)
                 {
                     continue;
                 }
                 if (eventArgs.Action == WalkerAction.Abort)
                 {
                     return false;
                 }
             }
             if (currentValue is IList)
             {
                 foreach (object obj3 in (IList) currentValue)
                 {
                     if (this.FoundProperty != null)
                     {
                         WalkerEventArgs args2 = new WalkerEventArgs(activity, obj3, null, currentValue);
                         this.FoundProperty(this, args2);
                         if (args2.Action == WalkerAction.Skip)
                         {
                             continue;
                         }
                         if (args2.Action == WalkerAction.Abort)
                         {
                             return false;
                         }
                     }
                     if (((obj3 != null) && IsBrowsableType(obj3.GetType())) && !this.WalkProperties(activity, obj3))
                     {
                         return false;
                     }
                 }
             }
             else if (((currentValue != null) && IsBrowsableType(currentValue.GetType())) && !this.WalkProperties(activity, currentValue))
             {
                 return false;
             }
         }
     }
     return true;
 }
Ejemplo n.º 8
0
        public bool WalkProperties(Activity activity, object obj)
        {
            Activity activity2 = obj as Activity;

            foreach (PropertyInfo info in obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance))
            {
                if (((info.GetIndexParameters() == null) || (info.GetIndexParameters().Length <= 0)) && (GetSerializationVisibility(info) != DesignerSerializationVisibility.Hidden))
                {
                    object             currentValue       = null;
                    DependencyProperty dependencyProperty = DependencyProperty.FromName(info.Name, obj.GetType());
                    if ((dependencyProperty != null) && (activity2 != null))
                    {
                        if (activity2.IsBindingSet(dependencyProperty))
                        {
                            currentValue = activity2.GetBinding(dependencyProperty);
                        }
                        else
                        {
                            currentValue = activity2.GetValue(dependencyProperty);
                        }
                    }
                    else
                    {
                        try
                        {
                            currentValue = info.CanRead ? info.GetValue(obj, null) : null;
                        }
                        catch
                        {
                        }
                    }
                    if (this.FoundProperty != null)
                    {
                        WalkerEventArgs eventArgs = new WalkerEventArgs(activity, currentValue, info, obj);
                        this.FoundProperty(this, eventArgs);
                        if (eventArgs.Action == WalkerAction.Skip)
                        {
                            continue;
                        }
                        if (eventArgs.Action == WalkerAction.Abort)
                        {
                            return(false);
                        }
                    }
                    if (currentValue is IList)
                    {
                        foreach (object obj3 in (IList)currentValue)
                        {
                            if (this.FoundProperty != null)
                            {
                                WalkerEventArgs args2 = new WalkerEventArgs(activity, obj3, null, currentValue);
                                this.FoundProperty(this, args2);
                                if (args2.Action == WalkerAction.Skip)
                                {
                                    continue;
                                }
                                if (args2.Action == WalkerAction.Abort)
                                {
                                    return(false);
                                }
                            }
                            if (((obj3 != null) && IsBrowsableType(obj3.GetType())) && !this.WalkProperties(activity, obj3))
                            {
                                return(false);
                            }
                        }
                    }
                    else if (((currentValue != null) && IsBrowsableType(currentValue.GetType())) && !this.WalkProperties(activity, currentValue))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }