示例#1
0
 public CNamedEvent(MethodBase m, EventMetaInfoAttribute a, string eventName) : base(m, a, eventName)
 {
 }
示例#2
0
 private static void RegisterType(Type type, bool bIsAgentType)
 {
     Attribute[] array = (Attribute[])type.GetCustomAttributes(typeof(TypeMetaInfoAttribute), false);
     if (!bIsAgentType || array.Length > 0)
     {
         TypeMetaInfoAttribute      typeMetaInfoAttribute = (array.Length <= 0) ? null : ((TypeMetaInfoAttribute)array[0]);
         Agent.CTagObjectDescriptor descriptorByName      = Agent.GetDescriptorByName(type.get_FullName());
         if (type.get_BaseType() == typeof(Agent) || type.get_BaseType().IsSubclassOf(typeof(Agent)))
         {
             Agent.CTagObjectDescriptor descriptorByName2 = Agent.GetDescriptorByName(type.get_BaseType().get_FullName());
             descriptorByName.m_parent = descriptorByName2;
         }
         descriptorByName.type        = type;
         descriptorByName.displayName = ((typeMetaInfoAttribute != null && !string.IsNullOrEmpty(typeMetaInfoAttribute.DisplayName)) ? typeMetaInfoAttribute.DisplayName : type.get_FullName());
         descriptorByName.desc        = ((typeMetaInfoAttribute != null && !string.IsNullOrEmpty(typeMetaInfoAttribute.Description)) ? typeMetaInfoAttribute.Description : descriptorByName.displayName);
         if (Utils.IsEnumType(type))
         {
             return;
         }
         BindingFlags bindingFlags = 62;
         FieldInfo[]  fields       = type.GetFields(bindingFlags);
         FieldInfo[]  array2       = fields;
         for (int i = 0; i < array2.Length; i++)
         {
             FieldInfo fieldInfo       = array2[i];
             bool      flag            = false;
             MemberMetaInfoAttribute a = null;
             if (bIsAgentType)
             {
                 Attribute[] array3 = (Attribute[])fieldInfo.GetCustomAttributes(typeof(MemberMetaInfoAttribute), false);
                 if (array3.Length > 0)
                 {
                     a    = (MemberMetaInfoAttribute)array3[0];
                     flag = true;
                 }
             }
             else
             {
                 flag = true;
             }
             if (flag)
             {
                 CMemberBase cMemberBase = new CMemberBase(fieldInfo, a);
                 for (int j = 0; j < descriptorByName.ms_members.get_Count(); j++)
                 {
                     if (cMemberBase.GetId() == descriptorByName.ms_members.get_Item(j).GetId())
                     {
                         CMemberBase cMemberBase2 = descriptorByName.ms_members.get_Item(j);
                         break;
                     }
                 }
                 descriptorByName.ms_members.Add(cMemberBase);
                 if ((Utils.IsCustomClassType(fieldInfo.get_FieldType()) || Utils.IsEnumType(fieldInfo.get_FieldType())) && !Agent.IsTypeRegisterd(fieldInfo.get_FieldType().get_FullName()))
                 {
                     Workspace.RegisterType(fieldInfo.get_FieldType(), false);
                 }
             }
         }
         if (bIsAgentType)
         {
             MethodInfo[] methods = type.GetMethods(bindingFlags);
             MethodInfo[] array4  = methods;
             for (int k = 0; k < array4.Length; k++)
             {
                 MethodInfo  methodInfo = array4[k];
                 Attribute[] array5     = (Attribute[])methodInfo.GetCustomAttributes(typeof(MethodMetaInfoAttribute), false);
                 if (array5.Length > 0)
                 {
                     MethodMetaInfoAttribute a2          = (MethodMetaInfoAttribute)array5[0];
                     CMethodBase             cMethodBase = new CMethodBase(methodInfo, a2, null);
                     descriptorByName.ms_methods.Add(cMethodBase);
                     ParameterInfo[] parameters = methodInfo.GetParameters();
                     ParameterInfo[] array6     = parameters;
                     for (int l = 0; l < array6.Length; l++)
                     {
                         ParameterInfo parameterInfo = array6[l];
                         if ((Utils.IsCustomClassType(parameterInfo.get_ParameterType()) || Utils.IsEnumType(parameterInfo.get_ParameterType())) && !Agent.IsTypeRegisterd(parameterInfo.get_ParameterType().get_FullName()))
                         {
                             Workspace.RegisterType(parameterInfo.get_ParameterType(), false);
                         }
                     }
                     if ((Utils.IsCustomClassType(methodInfo.get_ReturnType()) || Utils.IsEnumType(methodInfo.get_ReturnType())) && !Agent.IsTypeRegisterd(methodInfo.get_ReturnType().get_FullName()))
                     {
                         Workspace.RegisterType(methodInfo.get_ReturnType(), false);
                     }
                 }
             }
             Type[] nestedTypes = type.GetNestedTypes(bindingFlags);
             Type[] array7      = nestedTypes;
             for (int m = 0; m < array7.Length; m++)
             {
                 Type        type2  = array7[m];
                 Attribute[] array8 = (Attribute[])type2.GetCustomAttributes(typeof(EventMetaInfoAttribute), false);
                 if (array8.Length > 0)
                 {
                     EventMetaInfoAttribute a3          = (EventMetaInfoAttribute)array8[0];
                     MethodInfo             method      = type2.GetMethod("Invoke");
                     CNamedEvent            cNamedEvent = new CNamedEvent(method, a3, type2.get_Name());
                     descriptorByName.ms_methods.Add(cNamedEvent);
                 }
             }
         }
     }
 }