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 void Insert(int index, IPartView item) { if (item == null) { return; } _parts.Insert(index, item); }
public void Add(IPartView item) { if (item == null) { return; } _parts.Add(item); }
/// <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; }
/// <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; } }
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; } }
/// <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)); }
/// <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)); }
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); } } }
/// <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)); }
/// <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()); } }
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); }
public bool Contains(IPartView item) { return Parts.Contains((AdvancedPart)item); }
public override void Given() { view = Moq.Mock <IPartView>(); }
public int IndexOf(IPartView item) { return(Parts.IndexOf((AdvancedPart)item)); }
public void CopyTo(IPartView[] array, int arrayIndex) { _parts.CopyTo(array, arrayIndex); }
public int IndexOf(IPartView item) { return(_parts.IndexOf(item)); }
public bool Contains(IPartView item) { return(Parts.Contains((AdvancedPart)item)); }
public bool Contains(IPartView item) { return(_parts.Contains(item)); }
public PartViewModel(IPartView view) { _view = view; }
public void Add(IPartView item) { Parts.Add((AdvancedPart)item); }
public virtual void CopyFrom(IPartView other) { }
public bool Remove(IPartView item) { return Parts.Remove((AdvancedPart)item); }
public void Insert(int index, IPartView item) { Parts.Insert(index, (AdvancedPart)item); }
public int IndexOf(IPartView item) { return Parts.IndexOf((AdvancedPart)item); }
public void CopyTo(IPartView[] array, int arrayIndex) { Parts.CopyTo((AdvancedPart[])array, arrayIndex); }
public void CopyFrom(IPartView other) { }
public PartLoader(IPartView current, AdvancedPartJunction junction) : this(current) { Junction = junction; }
public bool Remove(IPartView item) { return(_parts.Remove(item)); }
/// <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); }
public PartLoader(IPartView current) { Current = current; Junction = null; }
public int IndexOf(IPartView item) { return _parts.IndexOf(item); }
public bool Remove(IPartView item) { return _parts.Remove(item); }
public bool Remove(IPartView item) { return(Parts.Remove((AdvancedPart)item)); }
public bool Contains(IPartView item) { return _parts.Contains(item); }
public virtual bool Equals(IPartView other) { return(false); }
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>(); }
public void Insert(int index, IPartView item) { if (item == null) return; _parts.Insert(index, item); }
public void Add(IPartView item) { if (item == null) return; _parts.Add(item); }
public virtual bool Equals(IPartView other) { return false; }
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); } }