protected void EvaluateTargetStructure(Type t) { //evaluate target objet definition //check current table defintioin first *** MySqlSubTable subTable = reader.CurrentSubTable; //get all public instance fields from current type FieldInfo[] allFields = GetPublicInstanceFields(t); //we iterate all request fields int j = allFields.Length; mapFields.Clear(); for (int i = 0; i < j; ++i) { FieldInfo field = allFields[i]; MySqlFieldDefinition fieldDef = subTable.GetFieldDefinition(field.Name); //---------------------------------- //check field type conversion //1. some basic can do direct conversion //2. use can provide custom protocol for field conversion //3. some need user decision //---------------------------------- //in this version we support only primitive type *** MySqlDataConversionTechnique foundConv; if (!MySqlTypeConversionInfo.TryGetImplicitConversion((MySqlDataType)fieldDef.FieldType, field.FieldType, out foundConv)) { //not found //TODO: //so make notification by let use make a dicision throw new NotSupportedException(); } //----------------- MySqlFieldMap fieldMap = fieldDef.IsEmpty ? new MySqlFieldMap(-1, fieldDef.Name, foundConv) : new MySqlFieldMap(fieldDef.FieldIndex, fieldDef.Name, foundConv); fieldMap.resolvedFieldInfo = field; mapFields.Add(fieldMap); } }
protected void EvaluateTableDefinition(MethodInfo met) { //check current table defintioin first *** MySqlSubTable subTable = reader.CurrentSubTable; var metPars = met.GetParameters(); //target method that we need int j = metPars.Length;//** mapFields.Clear(); for (int i = 1; i < j; ++i) { //get parameter fieldname //and type and check proper type conversion ParameterInfo metPar = metPars[i]; MySqlFieldDefinition fieldDef = subTable.GetFieldDefinition(metPar.Name); //---------------------------------- //check field type conversion //1. some basic can do direct conversion //2. use can provide custom protocol for field conversion //3. some need user decision //---------------------------------- //in this version we support only primitive type *** MySqlDataConversionTechnique foundConv; if (!MySqlTypeConversionInfo.TryGetImplicitConversion((MySqlDataType)fieldDef.FieldType, metPar.ParameterType, out foundConv)) { //not found //TODO: //so make notification by let use make a dicision throw new NotSupportedException(); } //----------------- MySqlFieldMap fieldMap = fieldDef.IsEmpty ? new MySqlFieldMap(-1, fieldDef.Name, foundConv) : new MySqlFieldMap(fieldDef.FieldIndex, fieldDef.Name, foundConv); mapFields.Add(fieldMap); } }