in CSharp/Library/Microsoft.Bot.Builder/FormFlow/FieldReflector.cs [233:341]
protected void AddField(Type type, string[] path, int ipath)
{
if (ipath < path.Length)
{
ProcessTemplates(type);
var step = path[ipath];
object field = type.GetField(step, BindingFlags.Public | BindingFlags.Instance);
Type ftype;
if (field == null)
{
var prop = type.GetProperty(step, BindingFlags.Public | BindingFlags.Instance);
if (prop == null)
{
throw new MissingFieldException($"{step} is not a field or property in your type.");
}
field = prop;
ftype = prop.PropertyType;
_path.Add(prop);
}
else
{
ftype = (field as FieldInfo).FieldType;
_path.Add(field);
}
if (ftype.IsNullable())
{
_isNullable = true;
_keepZero = true;
ftype = Nullable.GetUnderlyingType(ftype);
}
else if (ftype.IsEnum || ftype.IsClass)
{
_isNullable = true;
}
if (ftype.IsClass)
{
if (ftype == typeof(string) || ftype.IsAttachmentType())
{
_type = ftype;
ProcessFieldAttributes(field);
}
else if (ftype.IsIEnumerable())
{
var elt = ftype.GetGenericElementType();
_type = elt;
_allowsMultiple = true;
ProcessFieldAttributes(field);
if (elt.IsEnum)
{
ProcessEnumAttributes(elt);
}
}
else
{
AddField(ftype, path, ipath + 1);
}
}
else if (ftype.IsAttachmentCollection())
{
_isNullable = true;
_type = ftype;
ProcessFieldAttributes(field);
}
else
{
if (ftype.IsEnum)
{
ProcessFieldAttributes(field);
ProcessEnumAttributes(ftype);
}
else if (ftype == typeof(bool))
{
ProcessFieldAttributes(field);
}
else if (ftype.IsIntegral())
{
long min = long.MinValue;
long max = long.MaxValue;
if (ftype == typeof(sbyte)) { min = sbyte.MinValue; max = sbyte.MaxValue; }
else if (ftype == typeof(byte)) { min = byte.MinValue; max = byte.MaxValue; }
else if (ftype == typeof(short)) { min = short.MinValue; max = short.MaxValue; }
else if (ftype == typeof(ushort)) { min = ushort.MinValue; max = ushort.MaxValue; }
else if (ftype == typeof(int)) { min = int.MinValue; max = int.MaxValue; }
else if (ftype == typeof(uint)) { min = uint.MinValue; max = uint.MaxValue; }
else if (ftype == typeof(long)) { min = long.MinValue; max = long.MaxValue; }
else if (ftype == typeof(ulong)) { min = long.MinValue; max = long.MaxValue; }
SetLimits(min, max, false);
ProcessFieldAttributes(field);
}
else if (ftype.IsDouble())
{
double min = long.MinValue;
double max = long.MaxValue;
if (ftype == typeof(float)) { min = float.MinValue; max = float.MaxValue; }
else if (ftype == typeof(double)) { min = double.MinValue; max = double.MaxValue; }
SetLimits(min, max, false);
ProcessFieldAttributes(field);
}
else if (ftype == typeof(DateTime))
{
ProcessFieldAttributes(field);
}
_type = ftype;
}
}
}