public static List <Error> MustExistOnType <T>(FuncEnumerable <T, string> fields) { var type = typeof(T); var list = new List <Error>(); foreach (var field in fields) { var valid = false; foreach (var member in AccessorMembers.Create(type)) { if (field.Equals(member.Name, StringComparison.OrdinalIgnoreCase)) { valid = true; } } if (!valid) { list.Add(new Error(ErrorEvents.FieldDoesNotMatch, string.Format(ErrorStrings.FieldToPropertyMismatch, field, type.Name), HttpStatusCode.BadRequest)); } } return(list); }
public IEnumerator <T> GetEnumerator() { foreach (var node in FuncEnumerable <WeakNode> .Get(GetNodeEnumerator)) { T current; if (node.TryGetValue(out current)) { yield return(current); } } }
/// <summary> /// Adds an item to the end of the enumerable. /// </summary> /// <remarks>This method requires the entire collection to be enumerated. /// If adding to the end is not required, use <see cref="Insert"/>. It's faster.</remarks> public void Add(T item) { Contract.Requires <ArgumentNullException>(item != null); var node = new WeakNode(item); var last = FuncEnumerable <WeakNode> .Get(GetNodeEnumerator).LastOrDefault(); if (last == null) { m_head = node; } else { last.Next = node; } }