Пример #1
0
        static ChoMetadataTypesRegister()
        {
            foreach (Type type in ChoType.GetTypes(typeof(MetadataTypeAttribute)))
            {
                MetadataTypeAttribute attrib = type.GetCustomAttribute <MetadataTypeAttribute>();
                if (attrib == null || attrib.MetadataClassType == null)
                {
                    continue;
                }

                TypeDescriptor.AddProviderTransparent(
                    new AssociatedMetadataTypeTypeDescriptionProvider(type, attrib.MetadataClassType), type);
            }

            foreach (Type type in ChoType.GetTypes(typeof(ChoMetadataRefTypeAttribute)))
            {
                ChoMetadataRefTypeAttribute attrib = type.GetCustomAttribute <ChoMetadataRefTypeAttribute>();
                if (attrib == null || attrib.MetadataRefClassType == null)
                {
                    continue;
                }

                TypeDescriptor.AddProviderTransparent(
                    new AssociatedMetadataTypeTypeDescriptionProvider(attrib.MetadataRefClassType, type), attrib.MetadataRefClassType);
            }
        }
Пример #2
0
        public static void Register(Type type)
        {
            if (type == null)
            {
                return;
            }

            MetadataTypeAttribute attrib = type.GetCustomAttribute <MetadataTypeAttribute>();

            if (attrib != null && attrib.MetadataClassType != null)
            {
                Register(type, attrib.MetadataClassType);
            }
            else
            {
                ChoMetadataRefTypeAttribute attrib1 = type.GetCustomAttribute <ChoMetadataRefTypeAttribute>();
                if (attrib1 != null && attrib1.MetadataRefClassType != null)
                {
                    Register(attrib1.MetadataRefClassType, type);
                }
            }
        }