예제 #1
0
 internal static Type GetDynamicObjectBuilderType(ThrowingHashSet<IPropertyInfo> properties)
 {
     lock (SyncRoot)
     {
         TypeSignature signature = new TypeSignature(properties);
         Type type;
         if (!TypesCache.TryGetValue(signature, out type))
         {
             type = CreateDynamicObjectBuilderType(properties);
             TypesCache.Add(signature, type);
         }
         return type;
     }
 }
예제 #2
0
        internal static Record CreateRecord(IEnumerable<SchemaInfo> schemas)
        {
            EnsureSchemaInfo(schemas);

            ThrowingHashSet<IPropertyInfo> propertyInfos = new ThrowingHashSet<IPropertyInfo>();
            foreach (SchemaInfo schema in schemas)
            {
                propertyInfos.Add(ConverterFactory.CreatePropertyInfo(schema));
            }

            Record ret = (Record)Activator.CreateInstance(RecordBuilder.GetDynamicObjectBuilderType(propertyInfos));

            foreach (IPropertyInfo propInfo in propertyInfos)
            {
                ICell cell = propInfo.CreateCell(ret);
                ret.valuesStorage.Add(propInfo.PropertyName, cell);
            }

            return ret;
        }