Exemplo n.º 1
1
        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);
        }
Exemplo n.º 2
0
        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);
        }