Example #1
0
        public bool Equals(IPartView other)
        {
            var junc = other as IPartViewJunction;

            if (junc != null)
            {
                if (this.Count == junc.Count)
                {
                    // ensure all elements are equal, otherwise false
                    for (int i = 0; i < this.Count; i++)
                    {
                        if (!this[i].Equals(junc[i]))
                        {
                            return(false);
                        }
                    }

                    // all elements equal, so check type
                    return(this.Type.Equals(junc.Type));
                }

                // different number of parts, therefore not equal
                return(false);
            }
            return(false);
        }
Example #2
0
 public void Insert(int index, IPartView item)
 {
     if (item == null)
     {
         return;
     }
     _parts.Insert(index, item);
 }
Example #3
0
 public void Add(IPartView item)
 {
     if (item == null)
     {
         return;
     }
     _parts.Add(item);
 }
Example #4
0
        /// <summary>
        /// PresetPart will only copy values from the other view and will only do so if Equals(IPartView) is true.
        /// The reasoning is that PresetPart has no way to update the UIElement if the SelectedBuilder changes.
        /// </summary>
        /// <param name="other"></param>
        public void CopyFrom(IPartView other)
        {
            if (other == null || !Equals(other))
            {
                return;
            }

            this.Values = ((IPartViewNode)other).Values;
        }
Example #5
0
 /// <summary>
 /// StandardPart will update all properties as long as the other SelectedPath and SelectedBuilder
 /// are part of this StandardPart's lists (SelectedBuilder checked from builders generated by SelectedPath).
 /// </summary>
 /// <param name="other"></param>
 public virtual void CopyFrom(IPartView other)
 {
     if (CanCopyFrom(other))
     {
         var node = (IPartViewNode)other;
         SelectedPath    = node.SelectedPath;    // this will call SelectedBuilder and UIElement setters
         SelectedBuilder = node.SelectedBuilder; // this will call UIElement setter
         Values          = node.Values;
         Parser          = node.Parser;
     }
 }
Example #6
0
 public override void CopyFrom(IPartView other)
 {
     if (other is IPartViewNode)
     {
         var node = ((IPartViewNode)other);
         this.SelectedPath    = node.SelectedPath;
         this.SelectedBuilder = node.SelectedBuilder;
         this.Parser          = node.Parser;
         this.Values          = node.Values;
     }
 }
Example #7
0
            /// <summary>
            /// Considered equal when the path, builder and parser are equal.
            /// Note: value is ignored in equality test.
            /// </summary>
            public bool Equals(IPartView other)
            {
                if (other == null || !(other is IPartViewNode))
                {
                    return(false);
                }

                var node = (IPartViewNode)other;

                return(SelectedPath.Equals(node.SelectedPath) &&
                       SelectedBuilder.Equals(node.SelectedBuilder) &&
                       dbqf.Parsers.Parser.Equals(Parser, node.Parser));
            }
Example #8
0
        /// <summary>
        /// AdvancedPart considered equal when the path, builder and parser are equal.
        /// Note: value is ignored in equality test.
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public bool Equals(IPartView other)
        {
            if (other == null || !(other is IPartViewNode))
            {
                return(false);
            }

            var node = (IPartViewNode)other;

            return(SelectedPath.Equals(node.SelectedPath) &&
                   SelectedBuilder.Equals(node.SelectedBuilder) &&
                   Parser.Equals(Parser, node.Parser) &&
                   (Values != null ? Values.Equals(node.Values) : true));
        }
Example #9
0
        public void CopyFrom(IPartView other)
        {
            var junc = other as IPartViewJunction;

            if (junc != null)
            {
                _parts.Clear();
                Type = junc.Type;
                foreach (var p in junc)
                {
                    Add(p);
                }
            }
        }
Example #10
0
        /// <summary>
        /// StandardPart considered equal based on reference.
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public virtual bool Equals(IPartView other)
        {
            if (other == null)
            {
                return(false);
            }

            // we can't use SelectedPath/SelectedBuilder/Parser since
            // there may be more than one StandardPart with the same set of values
            // For example:
            //   [0] = Name contains 'john'
            //   [1] = Name contains 'smith'

            return(base.Equals(other));
        }
Example #11
0
        /// <summary>
        /// Creates a new node optionally from a template part.  If no template provided, logic ensures a
        /// node can be added at this time by checking UIElement for values.
        /// </summary>
        /// <param name="template"></param>
        /// <returns></returns>
        protected virtual AdvancedPartNode CreateNode(IPartView template)
        {
            if (template != null)
            {
                var node = CreateNode();
                node.CopyFrom(template);
                return(node);
            }
            else
            {
                if (UIElement != null && UIElement.GetValues() == null)
                {
                    return(null);
                }

                return(CreateNode());
            }
        }
Example #12
0
        public virtual bool CanCopyFrom(IPartView other)
        {
            if (other == null || !(other is IPartViewNode))
            {
                return(false);
            }

            // ensure we can represent the path
            var node = (IPartViewNode)other;

            if (Paths.Contains(node.SelectedPath))
            {
                // ensure there is a builder that can represent the incoming builder
                return(_builderFactory.Build(node.SelectedPath).Contains(node.SelectedBuilder));

                // value and parser are irrelevant here
            }

            return(false);
        }
Example #13
0
 public bool Contains(IPartView item)
 {
     return Parts.Contains((AdvancedPart)item);
 }
Example #14
0
 public override void Given()
 {
     view = Moq.Mock <IPartView>();
 }
Example #15
0
 public int IndexOf(IPartView item)
 {
     return(Parts.IndexOf((AdvancedPart)item));
 }
Example #16
0
 public void CopyTo(IPartView[] array, int arrayIndex)
 {
     _parts.CopyTo(array, arrayIndex);
 }
Example #17
0
 public int IndexOf(IPartView item)
 {
     return(_parts.IndexOf(item));
 }
Example #18
0
 public bool Contains(IPartView item)
 {
     return(Parts.Contains((AdvancedPart)item));
 }
Example #19
0
 public bool Contains(IPartView item)
 {
     return(_parts.Contains(item));
 }
Example #20
0
 public PartViewModel(IPartView view)
 {
     _view = view;
 }
Example #21
0
 public void Add(IPartView item)
 {
     Parts.Add((AdvancedPart)item);
 }
Example #22
0
 public virtual void CopyFrom(IPartView other)
 {
 }
Example #23
0
 public bool Remove(IPartView item)
 {
     return Parts.Remove((AdvancedPart)item);
 }
Example #24
0
 public void Insert(int index, IPartView item)
 {
     Parts.Insert(index, (AdvancedPart)item);
 }
Example #25
0
 public int IndexOf(IPartView item)
 {
     return Parts.IndexOf((AdvancedPart)item);
 }
Example #26
0
 public void CopyTo(IPartView[] array, int arrayIndex)
 {
     Parts.CopyTo((AdvancedPart[])array, arrayIndex);
 }
Example #27
0
 public void CopyFrom(IPartView other)
 {
 }
Example #28
0
 public PartLoader(IPartView current, AdvancedPartJunction junction)
     : this(current)
 {
     Junction = junction;
 }
Example #29
0
 public override void CopyFrom(IPartView other)
 {
     if (other is IPartViewNode)
     {
         var node = ((IPartViewNode)other);
         this.SelectedPath = node.SelectedPath;
         this.SelectedBuilder = node.SelectedBuilder;
         this.Parser = node.Parser;
         this.Values = node.Values;
     }
 }
Example #30
0
 public bool Remove(IPartView item)
 {
     return(_parts.Remove(item));
 }
Example #31
0
        /// <summary>
        /// AdvancedPart considered equal when the path, builder and parser are equal.
        /// Note: value is ignored in equality test.
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public bool Equals(IPartView other)
        {
            if (other == null || !(other is IPartViewNode))
                return false;

            var node = (IPartViewNode)other;
            return SelectedPath.Equals(node.SelectedPath)
                && SelectedBuilder.Equals(node.SelectedBuilder)
                && Parser.Equals(Parser, node.Parser)
                && (Values != null ? Values.Equals(node.Values) : true);
        }
Example #32
0
 public PartLoader(IPartView current)
 {
     Current  = current;
     Junction = null;
 }
Example #33
0
 public int IndexOf(IPartView item)
 {
     return _parts.IndexOf(item);
 }
Example #34
0
 public void Add(IPartView item)
 {
     Parts.Add((AdvancedPart)item);
 }
Example #35
0
 public bool Remove(IPartView item)
 {
     return _parts.Remove(item);
 }
Example #36
0
 public bool Remove(IPartView item)
 {
     return(Parts.Remove((AdvancedPart)item));
 }
Example #37
0
 public bool Contains(IPartView item)
 {
     return _parts.Contains(item);
 }
Example #38
0
 public void Insert(int index, IPartView item)
 {
     Parts.Insert(index, (AdvancedPart)item);
 }
Example #39
0
 public virtual bool Equals(IPartView other)
 {
     return(false);
 }
Example #40
0
        public bool Equals(IPartView other)
        {
            var junc = other as IPartViewJunction;
            if (junc != null)
            {
                if (this.Count == junc.Count)
                {
                    // ensure all elements are equal, otherwise false
                    for (int i = 0; i < this.Count; i++)
                        if (!this[i].Equals(junc[i]))
                            return false;

                    // all elements equal, so check type
                    return this.Type.Equals(junc.Type);
                }

                // different number of parts, therefore not equal
                return false;
            }
            return false;
        }
 public override void Given()
 {
     view = Moq.Mock<IPartView>();
 }
Example #42
0
 public void Insert(int index, IPartView item)
 {
     if (item == null)
         return;
     _parts.Insert(index, item);
 }
Example #43
0
 public virtual void CopyFrom(IPartView other)
 {
 }
Example #44
0
 public void Add(IPartView item)
 {
     if (item == null)
         return;
     _parts.Add(item);
 }
Example #45
0
 public virtual bool Equals(IPartView other)
 {
     return false;
 }
Example #46
0
 public void CopyFrom(IPartView other)
 {
     var junc = other as IPartViewJunction;
     if (junc != null)
     {
         _parts.Clear();
         Type = junc.Type;
         foreach (var p in junc)
             Add(p);
     }
 }
Example #47
0
 public PartViewModel(IPartView view)
 {
     _view = view;
 }