public SqlSerializer(DbProviderFactory factory) { this.database = new Database(factory); Type[] types = Assembly.GetCallingAssembly().GetTypes(); foreach (Type t in types) { if (Attribute.IsDefined(t, typeof(SerializableAttribute))) { Type thisType = typeof(Table<>); Type newType = thisType.MakeGenericType(t); this.database.Tables.Add((ITable)Activator.CreateInstance(newType)); } } this.database.Initalize(); }
public SqlSerializer(Type type, DbProviderFactory factory) { this.database = new Database(factory); Type thisType = typeof(Table<>); Type newType = thisType.MakeGenericType(type); this.database.Tables.Add((ITable)Activator.CreateInstance(newType)); foreach (Type t in (from MemberInfo member in type.GetMembers() where Attribute.IsDefined(member.GetType(), typeof(SerializableAttribute)) select member.GetType())) { newType = thisType.MakeGenericType(t); this.database.Tables.Add((ITable)Activator.CreateInstance(newType)); } this.database.Initalize(); }