private void Init() { var xmlPropertyAtt = Info.GetCustomAttribute<XmlPropertyAttribute>(true); IsRequired = xmlPropertyAtt.IsRequired; IsAssignableTypesAllowed = xmlPropertyAtt.IsAssignableTypesAllowed; IsPropertyTypeXml = PropertyType.GetCustomAttribute<XmlTypeAttribute>(true) == null; Description = xmlPropertyAtt.Description; Location = new Lazy<XmlLocation>(() => new XmlLocation(this)); if (PropertyType.IsGenericType || PropertyType.IsArray) ChildLocation = new Lazy<XmlLocation>(() => new XmlLocation(this, true)); Constraints = new Lazy<List<XmlConstraint>>(() => { var constraintList = new List<XmlConstraint>(); var constraintAtts = Info.GetCustomAttributes<XmlConstraintAttribute>(true).ToList(); foreach (var constraintAtt in constraintAtts) { var constraintProperty = ParentType.XmlProperties.FirstOrDefault(p => p.Info.Name == constraintAtt.PropertyName); if (constraintProperty == null) throw new TestLibsException($"Couldn't make constraint. Type {ParentType} doesn't contains property: {constraintAtt.PropertyName}"); var constraint = new XmlConstraint { Property = constraintProperty, RequiredValues = constraintAtt.RequiredValues, IsPosisitive = constraintAtt.IsPositive }; constraintList.Add(constraint); } return constraintList; } ); }
private void Init() { var xmlPropertyAtt = Info.GetCustomAttribute <XmlPropertyAttribute>(true); IsRequired = xmlPropertyAtt.IsRequired; IsAssignableTypesAllowed = xmlPropertyAtt.IsAssignableTypesAllowed; IsPropertyTypeXml = PropertyType.GetCustomAttribute <XmlTypeAttribute>(true) == null; Description = xmlPropertyAtt.Description; Location = new Lazy <XmlLocation>(() => new XmlLocation(this)); if (PropertyType.IsGenericType || PropertyType.IsArray) { ChildLocation = new Lazy <XmlLocation>(() => new XmlLocation(this, true)); } Constraints = new Lazy <List <XmlConstraint> >(() => { var constraintList = new List <XmlConstraint>(); var constraintAtts = Info.GetCustomAttributes <XmlConstraintAttribute>(true).ToList(); foreach (var constraintAtt in constraintAtts) { var constraintProperty = ParentType.XmlProperties.FirstOrDefault(p => p.Info.Name == constraintAtt.PropertyName); if (constraintProperty == null) { throw new TestLibsException($"Couldn't make constraint. Type {ParentType} doesn't contains property: {constraintAtt.PropertyName}"); } var constraint = new XmlConstraint { Property = constraintProperty, RequiredValues = constraintAtt.RequiredValues, IsPosisitive = constraintAtt.IsPositive }; constraintList.Add(constraint); } return(constraintList); } ); }