private MysteryClassAttribute getMysteryDefaultClassAttribute(Type type, Type attr_type) { MysteryClassAttribute ma = (MysteryClassAttribute)this.getGlobalObject <FastActivator>().createInstance(attr_type); ma.used_in = type; ma.setUp(); _mystery_attributes[type].Add(ma); _mystery_attributes_dict[type][ma.GetType()] = ma; return(ma); }
public void registerType(Type type) { if (_registered_types.Contains(type)) { return; } _registered_types.Add(type); _types_by_name[type.FullName] = type; object[] CustomAttributes = type.GetCustomAttributes(false); _mystery_attributes[type] = new HashSet <MysteryClassAttribute>(); _mystery_attributes_dict[type] = new Dictionary <Type, MysteryClassAttribute>(); _mystery_property_attributes[type] = new HashSet <MysteryPropertyAttribute>(); //registering the type attributes foreach (Attribute cs in CustomAttributes) { Type at = cs.GetType(); if (!_attributes.ContainsKey(at)) { _attributes[at] = new HashSet <Type>(); } _attributes[at].Add(type); if ((cs) is MysteryClassAttribute) { MysteryClassAttribute ma = (MysteryClassAttribute)cs; ma.used_in = type; ma.setUp(); _mystery_attributes[type].Add(ma); _mystery_attributes_dict[type][ma.GetType()] = ma; } } Type generic_helper_type = typeof(MysteryPropertyAttributeHelper <,>); foreach (PropertyInfo pi in type.GetProperties()) { _mystery_property_attributes_map[pi] = new HashSet <MysteryPropertyAttribute>(); foreach (Attribute attr in pi.GetCustomAttributes(false)) { if (!(attr is MysteryPropertyAttribute)) { continue; } MysteryPropertyAttribute mi_attr = (MysteryPropertyAttribute)attr; mi_attr.used_in = pi; Type this_property = generic_helper_type.MakeGenericType(pi.DeclaringType, pi.PropertyType); MysteryPropertyAttributeBaseHelper helper = (MysteryPropertyAttributeBaseHelper)Activator.CreateInstance(this_property, pi); mi_attr.save = helper.save; mi_attr.retrive = helper.retrive; mi_attr.setup(); _mystery_property_attributes[type].Add(mi_attr); _mystery_property_attributes_map[pi].Add(mi_attr); } } //inheritance recording Type parent = type.BaseType; while (parent != null) { if (!_childs.ContainsKey(parent)) { _childs[parent] = new HashSet <Type>(); } _childs[parent].Add(type); parent = parent.BaseType; } foreach (Type implemented_interface in type.GetInterfaces()) { if (!_childs.ContainsKey(implemented_interface)) { _childs[implemented_interface] = new HashSet <Type>(); } _childs[implemented_interface].Add(type); } }