public override IDictionary <int, PropertyInfo> DeterminePropertyOrder() { int order = 0; IList <bool> orderAttributes = new List <bool>(); foreach (var p in Properties) { if (p.GetCustomAttributes(false).Any(x => x.GetType() == typeof(PropertyOrderAttribute))) { orderAttributes.Add(true); order = ((PropertyOrderAttribute)(p.GetCustomAttributes(false).First(x => x.GetType() == typeof(PropertyOrderAttribute)))).Order; if (order >= Properties.Count()) { throw new OrderOutOfValuesRange(p, typeof(T), order); } } else { orderAttributes.Add(false); } if (orderAttributes.Distinct().Count() > 1) { throw new PartlyOrderAttribute(typeof(T)); } PropertyOrder.Add(order, p); order++; } return(PropertyOrder); }
public override IDictionary <int, PropertyInfo> DeterminePropertyOrder() { for (int i = 0; i < FirstArray.Length; i++) { try { var p = Properties.First(x => x.Name.ToLower() == FirstArray[i].ToLower()); PropertyOrder.Add(i, p); } catch (InvalidOperationException) { throw new PropertyNotFound(FirstArray[i], typeof(T)); } } return(PropertyOrder); }