Пример #1
0
        public ActionDescription(MethodInfo ai, SjsmpActionAttribute attr)
        {
            this.m_ai   = ai;
            this.m_attr = attr;

            ParameterInfo[] pInfos = m_ai.GetParameters();
            for (int i = 0; i < pInfos.Length; ++i)
            {
                ParameterInfo pInfo = pInfos[i];
                m_parameterInfo.Add(pInfo.Name, new Parameter(i, pInfo.ParameterType));
            }
            ;
        }
Пример #2
0
        public ObjectDescription(object obj, string name, string description, string group, bool acceptComponentModelAttrributes)
        {
            m_object      = obj;
            this.name     = name;
            m_description = description;
            m_group       = group;

            foreach (PropertyInfo pi in obj.GetType().GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public))
            {
                SjsmpPropertyAttribute attr = pi.GetCustomAttribute <SjsmpPropertyAttribute>();
                if (attr != null)
                {
                    m_properties.Add(pi.Name, PropertyDescription.CreateWithSjmpAttribute(pi, attr));
                }
            }
            if (acceptComponentModelAttrributes)
            {
                foreach (PropertyInfo pi in obj.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public))
                {
                    if (!m_properties.ContainsKey(pi.Name))
                    {
                        m_properties.Add(pi.Name, PropertyDescription.CreateWithComponentModel(pi));
                    }
                }
            }

            FieldInfo[] fieldInfos = obj.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
            foreach (FieldInfo fi in fieldInfos)
            {
                SjsmpPropertyAttribute attr = fi.GetCustomAttribute <SjsmpPropertyAttribute>();
                if (attr != null)
                {
                    m_properties.Add(fi.Name, new FieldDescription(fi, attr));
                }
            }

            MethodInfo[] methInfos = obj.GetType().GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
            foreach (MethodInfo ai in methInfos)
            {
                SjsmpActionAttribute attr = ai.GetCustomAttribute <SjsmpActionAttribute>();
                if (attr != null)
                {
                    if (m_actions.ContainsKey(ai.Name))
                    {
                        throw new SjsmpServerException("Duplicate action name " + ai.Name);
                    }
                    m_actions.Add(ai.Name, new ActionDescription(ai, attr));
                }
            }
        }
Пример #3
0
        public ActionDescription(MethodInfo ai, SjsmpActionAttribute attr)
        {
            this.m_ai = ai;
            this.m_attr = attr;

            ParameterInfo[] pInfos = m_ai.GetParameters();
            for (int i = 0; i < pInfos.Length; ++i)
            {
                ParameterInfo pInfo = pInfos[i];
                m_parameterInfo.Add(pInfo.Name, new Parameter(i, pInfo.ParameterType));
            };
        }