public static IReadOnlyDictionary <string, int> CreateIndex(RecordSchema schema) { var map = new Dictionary <string, int>(schema.Count); var fields = schema.ToArray(); for (int i = 0; i < fields.Length; i++) { map.Add(fields[i].Name, i); } return(new ReadOnlyDictionary <string, int>(map)); }
public static IReadOnlyList <ValueTuple <int, Func <object> > > CreateDefaultInitializers(RecordSchema schema) { var initializers = new List <ValueTuple <int, Func <object> > >(); var fields = schema.ToArray(); for (int i = 0; i < fields.Length; i++) { if (fields[i].Default != null) { initializers.Add(new ValueTuple <int, Func <object> >(i, GetDefaultInitialization(fields[i].Type, fields[i].Default))); } } return(initializers.AsReadOnly()); }