Exemplo n.º 1
0
        private ReadItem ResolveRecord(RecordSchema schema)
        {
            ReadItem recordReader;

            if (!_recordReaders.TryGetValue(schema, out recordReader))
            {
                lock (_recordReaders)
                {
                    if (!_recordReaders.TryGetValue(schema, out recordReader))
                    {
                        RecordAccess recordAccess = GetRecordAccess(schema);
                        var          fieldReaders = new List <FieldReader>();
                        recordReader = (r, d) => ReadRecord(r, d, recordAccess, fieldReaders);
                        _recordReaders.Add(schema, recordReader);
                        foreach (Field f in schema)
                        {
                            Field    field    = f;
                            ReadItem readItem = ResolveReader(field.Schema);
                            if (IsReusable(field.Schema.Type))
                            {
                                fieldReaders.Add((rec, d) => recordAccess.AddField(rec, field.Name, field.Pos,
                                                                                   readItem(recordAccess.GetField(rec, field.Name, field.Pos), d)));
                            }
                            else
                            {
                                fieldReaders.Add((rec, d) => recordAccess.AddField(rec, field.Name, field.Pos,
                                                                                   readItem(null, d)));
                            }
                        }
                    }
                }
            }
            return(recordReader);
        }