public ConstrainedDataSource Get(Type targetType, string propertyName) { ConstrainedDataSource constraint = null; if (stressConstraints.ContainsKey(targetType)) { Dictionary <string, ConstrainedDataSource> typeConstraints = stressConstraints[targetType]; if (typeConstraints.ContainsKey(propertyName)) { constraint = typeConstraints[propertyName]; } else { throw new ArgumentException("PropertyName: " + propertyName + " is not registered for constraints"); } } else { throw new ArgumentException("TargetType: " + targetType + " is not registered for constraints"); } return(constraint); }
public List <Type> CheckConstraints(Type t) { List <Type> types = new List <Type>(); foreach (PropertyDescriptor prop in DiscoverableInputHelper.GetInputProperties(t)) { Trace.WriteLine(String.Format("[ConstraintsTable] Checking Property Constraint {0} on {1}.", prop.Name, t)); Type inputType = prop.PropertyType; if (prop.Attributes.Contains(InputAttribute.CreateFromConstraints)) { ConstrainedDataSource datasource = Get(TargetTypeAttribute.FindTarget(t), prop.Name); if (null == datasource) { throw new InvalidOperationException("Missing constraint entry for" + t + " property: " + prop.Name); } else { datasource.Validate(); } } } return(types); }