// will return either a PropBlock or a LitBlock #region Modified code - Added entityMetadataProvider parameter public static BaseBlock CreateRHSBlock(Object exprSource, Type entityType, DataType otherExprDataType, IEntityMetadataProvider entityMetadataProvider) { if (exprSource == null) { return(new LitBlock(exprSource, otherExprDataType)); } if (exprSource is String) { String source = (String)exprSource; if (entityType == null) { // if entityType is unknown then assume that the rhs is a // literal return(new LitBlock(source, otherExprDataType)); } if (PropertySignature.IsProperty(entityType, source, entityMetadataProvider)) { return(new PropBlock(source, entityType, entityMetadataProvider)); } else { return(new LitBlock(source, otherExprDataType)); } } if (TypeFns.IsPredefinedType(exprSource.GetType())) { return(new LitBlock(exprSource, otherExprDataType)); } if (exprSource is IDictionary <string, Object> ) { var exprMap = (IDictionary <string, Object>)exprSource; // note that this is NOT the same a using get and checking for null // because null is a valid 'value'. if (!exprMap.ContainsKey("value")) { throw new Exception( "Unable to locate a 'value' property on: " + exprMap.ToString()); } Object value = exprMap["value"]; if (exprMap.ContainsKey("isProperty")) { return(new PropBlock((String)value, entityType, entityMetadataProvider)); } else { String dt = (String)exprMap["dataType"]; DataType dataType = (dt != null) ? DataType.FromName(dt) : otherExprDataType; return(new LitBlock(value, dataType)); } } if (exprSource is IList) { // right now this pretty much implies the values on an 'in' clause return(new LitBlock(exprSource, otherExprDataType)); } if (TypeFns.IsEnumType(exprSource.GetType())) { return(new LitBlock(exprSource, otherExprDataType)); } throw new Exception( "Unable to parse the right hand side of this BinaryExpression: " + exprSource.ToString()); }
public void Validate(Type entityType) { Property = new PropertySignature(entityType, PropertyPath); }
public void Validate(Type entityType, IEntityMetadataProvider entityMetadataProvider) { Property = new PropertySignature(entityType, PropertyPath, entityMetadataProvider); }