public Registrations(int capacity, LinkedNode <Type, IRegistry <string, IPolicySet> > head) : this(capacity) { for (var node = head; node != null; node = node.Next) { this[node.Key] = node.Value; } }
public HashRegistry(int capacity, LinkedNode <string, IPolicySet> head) : this(capacity) { for (var node = head; node != null; node = node.Next) { this[node.Key] = node.Value; } }
public IPolicySet this[string key] { get { IPolicySet match = null; for (var node = (LinkedNode <string, IPolicySet>) this; node != null; node = node.Next) { // Exact match if (Equals(node.Key, key)) { return(node.Value); } // Cover all match if (ReferenceEquals(node.Key, UnityContainer.All)) { match = node.Value; } } return(match); } set { LinkedNode <string, IPolicySet> node; LinkedNode <string, IPolicySet> last = null; for (node = this; node != null; node = node.Next) { if (Equals(node.Key, key)) { // Found it node.Value = value; return; } last = node; } // Not found, so add a new one last.Next = new LinkedNode <string, IPolicySet> { Key = key, Value = value }; _count++; } }
public HashRegistry(int capacity, LinkedNode <TKey, TValue> head) { var size = Prime.GetPrime(capacity); Buckets = new int[size]; Entries = new Entry[size]; for (var i = 0; i < Buckets.Length; i++) { Buckets[i] = -1; } for (var node = head; node != null; node = node.Next) { this[node.Key] = node.Value; } }
public IPolicySet this[string key] { get { for (var node = (LinkedNode <string, IPolicySet>) this; node != null; node = node.Next) { if (Equals(node.Key, key)) { return(node.Value); } } return(default(IPolicySet)); } set { LinkedNode <string, IPolicySet> node; LinkedNode <string, IPolicySet> last = null; for (node = this; node != null; node = node.Next) { if (Equals(node.Key, key)) { // Found it node.Value = value; return; } last = node; } // Not found, so add a new one last.Next = new LinkedNode <string, IPolicySet> { Key = key, Value = value }; _count++; } }
public void Append(string name, IPolicySet value) { LinkedNode <string, IPolicySet> node; LinkedNode <string, IPolicySet> last = null; for (node = this; node != null; node = node.Next) { if (name == node.Key) { node.Key = Guid.NewGuid().ToString(); } last = node; } // Not found, so add a new one last.Next = new LinkedNode <string, IPolicySet> { Key = name, Value = value }; _count++; }