示例#1
0
        private ServerClass CombineServerClasses(Type type)
        {
            var sp = new List <M_SendProp>();

            ServerClass sc = new ServerClass();

            sc.Name             = _EntityClasses[type].Name;
            sc.SendNetTableName = _EntityClasses[type].SendNetTableName;

            var baseType = type.BaseType;

            while (baseType.UnderlyingSystemType != typeof(object))
            {
                if (_EntityClasses[baseType].SendProps != null)
                {
                    sp.AddRange(_EntityClasses[baseType].SendProps);
                }

                baseType = baseType.BaseType;
            }

            if (_EntityClasses[type].SendProps != null)
            {
                sp.AddRange(_EntityClasses[type].SendProps);
            }

            sc.SendProps = sp.ToArray();
            return(sc);
        }
示例#2
0
        private bool ProcessServerClassType(Type type)
        {
            if (_EntityClasses.ContainsKey(type))
            {
                return(true);
            }
            else if (type.UnderlyingSystemType == typeof(Object))
            {
                return(true);
            }

            EntityMetaAttribute meta = null;

            foreach (var att in Attribute.GetCustomAttributes(type))
            {
                if (att.GetType() != typeof(EntityMetaAttribute))
                {
                    continue;
                }

                meta = att as EntityMetaAttribute;
                break;
            }

            ServerClass sc = null;

            if (meta != null)
            {
                sc = new ServerClass(type.Name, meta);
            }
            else
            {
                sc = new ServerClass(type.Name);
            }

            if (!ProcessServerProps(type, sc))
            {
                return(false);
            }

            _EntityClasses.Add(type, sc);
            return(ProcessServerClassType(type.BaseType));
        }
示例#3
0
        private bool ProcessServerProps(Type type, ServerClass sc)
        {
            var ret = new List <M_SendProp>();

            foreach (var prop in type.GetProperties(BindingFlags.DeclaredOnly | BindingFlags.GetProperty))
            {
                if (prop.GetCustomAttribute(typeof(EntitySendAttribute)) == null)
                {
                    continue;
                }

                PropType pt = PropType.DPT_Int;
                if (!M_SendProp.GetPropType(prop, out pt))
                {
                    _ConsoleManager.WriteLine(Color.Red, String.Format("Skipping property {0} in class {1} as it has an unsupported type", prop.Name, type.Name));
                    continue;
                }

                ret.Add(new M_SendProp(prop));
            }

            return(true);
        }