Ejemplo n.º 1
0
 private string CoerceValue(string value, IType valueType)
 {
     if (valueType == this.stringType || value == null)
     {
         return(value);
     }
     XmlToSampleDataAdapter.ValueInfo valueInfo = new XmlToSampleDataAdapter.ValueInfo(value);
     this.InferValueTypeInternal(valueInfo);
     return(valueInfo.CoercedValue);
 }
Ejemplo n.º 2
0
 private IType InferValueTypeInternal(XmlToSampleDataAdapter.ValueInfo valueInfo)
 {
     foreach (XmlToSampleDataAdapter.BasicTypeInfo typeInfo in this.basicTypes)
     {
         if (this.IsTypeOf(valueInfo, typeInfo))
         {
             return(typeInfo.Type);
         }
     }
     return(this.stringType);
 }
Ejemplo n.º 3
0
 private bool IsTypeOf(XmlToSampleDataAdapter.ValueInfo valueInfo, XmlToSampleDataAdapter.BasicTypeInfo typeInfo)
 {
     try
     {
         object obj = typeInfo.Converter.ConvertFromString(valueInfo.Value);
         if (obj != null)
         {
             valueInfo.CoercedValue = typeInfo.Converter.ConvertToInvariantString(obj);
             return(true);
         }
     }
     catch (Exception ex)
     {
     }
     return(false);
 }