public RecordInfo(Type type) { if (!typeof(Record).IsAssignableFrom(type)) { throw new ArgumentException("Record type is not derived from Record: " + type.FullName); } var attribute = type.GetCustomAttributes(typeof(RecordAttribute), false).Cast<RecordAttribute>().FirstOrDefault();// .NET 4.5: type.GetCustomAttribute<RecordAttribute>(); if (attribute == null) { throw new ArgumentException("Record type is missing required atribute: " + type.FullName); } signature = attribute.Signature; var va = type.GetCustomAttributes(typeof(VersionAttribute), false).Cast<VersionAttribute>().FirstOrDefault();// .NET 4.5: type.GetCustomAttribute<RecordAttribute>(); if (va != null) { version = va.Version; } var da = type.GetCustomAttributes(typeof(DummyAttribute), false).Cast<DummyAttribute>().FirstOrDefault(); isDummyRecord = da != null; ctor = type.GetConstructor(paramlessTypes); compound = InfoProvider.GetCompoundInfo(type); }
public RecordInfo(Type type) { if (!typeof(Record).IsAssignableFrom(type)) { throw new ArgumentException("Record type is not derived from Record: " + type.FullName); } var attribute = type.GetCustomAttributes(typeof(RecordAttribute), false).Cast <RecordAttribute>().FirstOrDefault();// .NET 4.5: type.GetCustomAttribute<RecordAttribute>(); if (attribute == null) { throw new ArgumentException("Record type is missing required atribute: " + type.FullName); } signature = attribute.Signature; var va = type.GetCustomAttributes(typeof(VersionAttribute), false).Cast <VersionAttribute>().FirstOrDefault();// .NET 4.5: type.GetCustomAttribute<RecordAttribute>(); if (va != null) { version = va.Version; } var da = type.GetCustomAttributes(typeof(DummyAttribute), false).Cast <DummyAttribute>().FirstOrDefault(); isDummyRecord = da != null; ctor = type.GetConstructor(paramlessTypes); compound = InfoProvider.GetCompoundInfo(type); }