Пример #1
0
        private MBeanInternalInfo(Type intfType)
        {
            List<MBeanOperationInfo> operations = new List<MBeanOperationInfo>();
             List<MBeanConstructorInfo> constructors = new List<MBeanConstructorInfo>();
             List<MBeanAttributeInfo> attributes = new List<MBeanAttributeInfo>();
             List<MBeanNotificationInfo> notifications = new List<MBeanNotificationInfo>();

             Dictionary<string, MBeanInternalOperationInfo> internalOperations = new Dictionary<string, MBeanInternalOperationInfo>();
             Dictionary<string, MBeanInternalConstructorInfo> internalConstructors = new Dictionary<string, MBeanInternalConstructorInfo>();
             Dictionary<string, MBeanInternalAttributeInfo> internalAttributes = new Dictionary<string, MBeanInternalAttributeInfo>();
             List<MBeanInternalNotificationInfo> internalNotifications = new List<MBeanInternalNotificationInfo>();

             List<Type> types = new List<Type>();
             types.Add(intfType);
             types.AddRange(intfType.GetInterfaces());
             IMBeanInfoFactory factory;
             if (intfType.IsDefined(typeof(OpenMBeanAttribute), true))
             {
            factory = new OpenMBeanBeanInfoFactory();
             }
             else
             {
            factory = new StandardBeanInfoFactory();
             }
             foreach (Type t in types)
             {
            foreach (PropertyInfo propInfo in t.GetProperties())
            {
               MBeanInternalAttributeInfo attrInfo = new MBeanInternalAttributeInfo(propInfo, factory);
               attributes.Add(attrInfo.AttributeInfo);
               internalAttributes.Add(attrInfo.AttributeInfo.Name, attrInfo);
            }
            foreach (EventInfo eventInfo in t.GetEvents())
            {
               if (eventInfo.IsDefined(typeof(MBeanNotificationAttribute), true))
               {
                  MBeanInternalNotificationInfo notifInfo = new MBeanInternalNotificationInfo(eventInfo, factory);
                  notifications.Add(notifInfo.NotificationInfo);
                  internalNotifications.Add(notifInfo);
               }
            }
            foreach (ConstructorInfo methInfo in t.GetConstructors())
            {
               MBeanInternalConstructorInfo constructorInfo = new MBeanInternalConstructorInfo(methInfo, factory);
               constructors.Add(constructorInfo.ConstructorInfo);
               internalConstructors.Add(constructorInfo.ConstructorInfo.Name, constructorInfo);
            }
            foreach (MethodInfo methInfo in t.GetMethods())
            {
               if (!methInfo.IsSpecialName)
               {
                  MBeanInternalOperationInfo operationInfo = new MBeanInternalOperationInfo(methInfo, factory);
                  operations.Add(operationInfo.OperationInfo);
                  internalOperations.Add(operationInfo.OperationInfo.Name, operationInfo);
               }
            }
             }
             _info = factory.CreateMBeanInfo(intfType, attributes, constructors, operations, notifications);
             _attributes = internalAttributes;
             _constructors = internalConstructors;
             _operations = internalOperations;
             _notifications = internalNotifications;
        }
Пример #2
0
        private MBeanInternalInfo(Type intfType)
        {
            List <MBeanOperationInfo>    operations    = new List <MBeanOperationInfo>();
            List <MBeanConstructorInfo>  constructors  = new List <MBeanConstructorInfo>();
            List <MBeanAttributeInfo>    attributes    = new List <MBeanAttributeInfo>();
            List <MBeanNotificationInfo> notifications = new List <MBeanNotificationInfo>();

            Dictionary <string, MBeanInternalOperationInfo>   internalOperations   = new Dictionary <string, MBeanInternalOperationInfo>();
            Dictionary <string, MBeanInternalConstructorInfo> internalConstructors = new Dictionary <string, MBeanInternalConstructorInfo>();
            Dictionary <string, MBeanInternalAttributeInfo>   internalAttributes   = new Dictionary <string, MBeanInternalAttributeInfo>();
            List <MBeanInternalNotificationInfo> internalNotifications             = new List <MBeanInternalNotificationInfo>();

            List <Type> types = new List <Type>();

            types.Add(intfType);
            types.AddRange(intfType.GetInterfaces());
            IMBeanInfoFactory factory;

            if (intfType.IsDefined(typeof(OpenMBeanAttribute), true))
            {
                factory = new OpenMBeanBeanInfoFactory();
            }
            else
            {
                factory = new StandardBeanInfoFactory();
            }
            foreach (Type t in types)
            {
                foreach (PropertyInfo propInfo in t.GetProperties())
                {
                    MBeanInternalAttributeInfo attrInfo = new MBeanInternalAttributeInfo(propInfo, factory);
                    attributes.Add(attrInfo.AttributeInfo);
                    internalAttributes.Add(attrInfo.AttributeInfo.Name, attrInfo);
                }
                foreach (EventInfo eventInfo in t.GetEvents())
                {
                    if (eventInfo.IsDefined(typeof(MBeanNotificationAttribute), true))
                    {
                        MBeanInternalNotificationInfo notifInfo = new MBeanInternalNotificationInfo(eventInfo, factory);
                        notifications.Add(notifInfo.NotificationInfo);
                        internalNotifications.Add(notifInfo);
                    }
                }
                foreach (ConstructorInfo methInfo in t.GetConstructors())
                {
                    MBeanInternalConstructorInfo constructorInfo = new MBeanInternalConstructorInfo(methInfo, factory);
                    constructors.Add(constructorInfo.ConstructorInfo);
                    internalConstructors.Add(constructorInfo.ConstructorInfo.Name, constructorInfo);
                }
                foreach (MethodInfo methInfo in t.GetMethods())
                {
                    if (!methInfo.IsSpecialName)
                    {
                        MBeanInternalOperationInfo operationInfo = new MBeanInternalOperationInfo(methInfo, factory);
                        operations.Add(operationInfo.OperationInfo);
                        internalOperations.Add(operationInfo.OperationInfo.Name, operationInfo);
                    }
                }
            }
            _info          = factory.CreateMBeanInfo(intfType, attributes, constructors, operations, notifications);
            _attributes    = internalAttributes;
            _constructors  = internalConstructors;
            _operations    = internalOperations;
            _notifications = internalNotifications;
        }