Пример #1
0
        Windows.ActionDescriptor AddAction(Windows.WindowDescriptor window, String actionKey, String actionName, Log.LogicTransaction ltr)
        {
            var action = window.ChildActions.FirstOrDefault(act => act.ActionKey.Equals(actionKey, StringComparison.OrdinalIgnoreCase));

            if (action == null)
            {
                window.ChildActions.Add(action = new Windows.ActionDescriptor(this, actionKey, window)
                {
                    ActionName = actionName
                });
                if (ltr != null)
                {
                    ltr.AddCreatedObject(action, this);
                }
            }
            else if (!String.Equals(action.ActionName, actionName, StringComparison.Ordinal))
            {
                if (ltr != null)
                {
                    ltr.AddUpdatedObjectBefore(action, this);
                }
                action.ActionName = actionName;
                if (ltr != null)
                {
                    ltr.AddUpatedObjectAfter(action, this);
                }
            }
            return(action);
        }
 public ActionDescriptor(BaseContext context, String actionKey, WindowDescriptor parent)
     : base(context)
 {
     if (String.IsNullOrEmpty(actionKey))
     {
         throw new ArgumentNullException(actionKey);
     }
     if (parent == null)
     {
         throw new ArgumentNullException("parent");
     }
     this.ParentWindow = parent;
     parent.ChildActions.Add(this);
 }
Пример #3
0
        protected Windows.WindowDescriptor AddWindow(String windowId, String windowName, Windows.WindowDescriptor parentWindow, IEnumerable <Tuple <String, String> > actions, Log.LogicTransaction ltr)
        {
            var window = this.Windows.FirstOrDefault(wnd => wnd.Iid.Equals(windowId, StringComparison.OrdinalIgnoreCase));

            if (window == null)
            {
                window = this.Windows.Add(new Windows.WindowDescriptor(this, windowId, windowName)
                {
                    ChildActions = new List <Windows.ActionDescriptor>(),
                    ChildWindows = new List <Windows.WindowDescriptor>()
                });
                if (ltr != null)
                {
                    ltr.AddCreatedObject(window, this);
                }
            }
            else if (!window.Name.Equals(windowName, StringComparison.Ordinal) || window.ParentWindow != parentWindow)
            {
                if (ltr != null)
                {
                    ltr.AddUpdatedObjectBefore(window, this);
                }
                window.ParentWindow = parentWindow;
                if (parentWindow != null && !parentWindow.ChildWindows.Contains(window))
                {
                    parentWindow.ChildWindows.Add(window);
                }
                window.Name = windowName;
                if (ltr != null)
                {
                    ltr.AddUpatedObjectAfter(window, this);
                }
            }

            if (actions == null && window.ChildActions.Count > 0)
            {
                foreach (var action in window.ChildActions)
                {
                    action.RemoveObject(this, ltr);
                }
                window.ChildActions.Clear();
            }
            else if (actions != null)
            {
                var addedActions = new HashSet <String>(actions.Select(act =>
                {
                    AddAction(window, act.Item1, act.Item2, ltr);
                    return(act.Item1);
                }));

                foreach (var action in window.ChildActions.Where(act => !addedActions.Contains(act.ActionKey)))
                {
                    action.RemoveObject(this, ltr);
                    window.ChildActions.Remove(action);
                }
            }

            return(window);
        }