/// <summary> /// Initializes a new instance. /// </summary> /// <param name="owner">The owner object.</param> /// <param name="prop">The property.</param> /// <exception cref="ArgumentNullException">Any of the arguments is <see langword="null"/>.</exception> public PropertyTypeInfo(ParametrizedObjectsFactory <T> owner, PropertyInfo prop) { if (owner == null) { throw new ArgumentNullException(nameof(owner)); } if (prop == null) { throw new ArgumentNullException(nameof(prop)); } Property = prop; CollectionPropertyAdapter = owner.collectionPropertyHandlers.Value.Select(cph => cph.CreateAdapter(prop)).FirstOrDefault(cpa => cpa != null); }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="owner">The owner instance.</param> /// <param name="type">The parametrized type.</param> /// <exception cref="ArgumentNullException">Any of the arguments is <see langword="null"/>.</exception> public ParametrizedTypeInfo(ParametrizedObjectsFactory <T> owner, Type type) { if (owner == null) { throw new ArgumentNullException(nameof(owner)); } if (type == null) { throw new ArgumentNullException(nameof(type)); } Type = type; props = type.GetProperties().Select(p => Tuple.Create(p, p.GetCustomAttributes(typeof(ObjectParameterAttribute), false).OfType <ObjectParameterAttribute>().FirstOrDefault())).Where(pInfo => pInfo.Item2 != null).OrderBy(pInfo => pInfo.Item2.Sorting).ToArray(); expr = owner.GenerateRegex(props, false); }