internal static iTunesReader CreateReader(string ObjectID, iTunesReader ParentReader) { foreach (var type in Assembly.GetAssembly(typeof(iTunesReader)).GetTypes() .Where(t => t.IsClass && !t.IsAbstract && t.IsSubclassOf(typeof(iTunesReader)))) { var obj = ((iTunesReader)Activator.CreateInstance(type)); if (obj.ObjectID == ObjectID) { obj.ParentReader = ParentReader; return(obj); } } throw new ArgumentException("Unknown object ID \"" + (ObjectID ?? "NULL") + "\"."); }
internal static DataObjectReader CreateDataObjectReader(DataObjects DataObjectKind, iTunesReader ParentReader) { foreach (var type in Assembly.GetAssembly(typeof(DataObjectReader)).GetTypes() .Where(t => t.IsClass && !t.IsAbstract && t.IsSubclassOf(typeof(DataObjectReader)))) { var obj = ((DataObjectReader)Activator.CreateInstance(type)); if (obj.DataObjectTypes.Any(o => o == DataObjectKind)) { obj.ParentReader = ParentReader; return(obj); } } throw new ArgumentException("No data reader for data object \"" + DataObjectKind.ToString() + "\"."); }