Esempio n. 1
0
        static Packet()
        {
            m_Table      = new Type[0x100];
            m_PropsTable = new PacketProp[0x100][];

            Type[] types = Assembly.GetExecutingAssembly().GetTypes();
            foreach (Type type in types)
            {
                PacketInfoAttribute[] attrs = (PacketInfoAttribute[])type.GetCustomAttributes(typeof(PacketInfoAttribute), false);
                if (attrs.Length > 0)
                {
                    byte cmd = attrs[0].Cmd;
                    m_Table[cmd] = type;

                    PropertyInfo[] properties = type.GetProperties();

                    ArrayList list = new ArrayList();
                    foreach (PropertyInfo propInfo in properties)
                    {
                        PacketPropAttribute[] propsAttrs = (PacketPropAttribute[])propInfo.GetCustomAttributes(typeof(PacketPropAttribute), true);

                        if (propsAttrs.Length > 0)
                        {
                            PacketProp pp = new PacketProp(propInfo, propsAttrs[0], null);

                            list.Add(pp);
                        }
                    }
                    list.Sort();

                    m_PropsTable[cmd] = (PacketProp[])list.ToArray(typeof(PacketProp));
                }
            }
        }
Esempio n. 2
0
        public PacketProp[] GetPacketProperties()
        {
            byte id = PacketID;

            PacketProp[] tableProps = null;

            if (id == 0xBF)
            {
                tableProps = m_CommandPropsTable[Command];
            }
            else
            {
                tableProps = m_PropsTable[id];
            }

            if (tableProps != null)
            {
                PacketProp[] props = new PacketProp[tableProps.Length];

                for (int i = 0; i < props.Length; i++)
                {
                    PacketProp pp = tableProps[i];
                    props[i] = new PacketProp(pp, pp.PropInfo.GetValue(this, null));
                }

                return(props);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 3
0
		static Packet()
		{
			m_Table = new Type[0x100];
			m_PropsTable = new PacketProp[0x100][];

			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			foreach ( Type type in types )
			{
				PacketInfoAttribute[] attrs = (PacketInfoAttribute[])type.GetCustomAttributes( typeof( PacketInfoAttribute ), false );
				if ( attrs.Length > 0 )
				{
					byte cmd = attrs[0].Cmd;
					m_Table[cmd] = type;

					PropertyInfo[] properties = type.GetProperties();

					ArrayList list = new ArrayList();
					foreach ( PropertyInfo propInfo in properties )
					{
						PacketPropAttribute[] propsAttrs = (PacketPropAttribute[])propInfo.GetCustomAttributes( typeof( PacketPropAttribute ), true );

						if ( propsAttrs.Length > 0 )
						{
							PacketProp pp = new PacketProp( propInfo, propsAttrs[0], null );

							list.Add( pp );
						}
					}
					list.Sort();

					m_PropsTable[cmd] = (PacketProp[])list.ToArray( typeof( PacketProp ) );
				}
			}
		}
Esempio n. 4
0
        public int CompareTo(object obj)
        {
            PacketProp pp = obj as PacketProp;

            if (pp == null)
            {
                return(-1);
            }
            else
            {
                return(m_Attribute.CompareTo(pp.m_Attribute));
            }
        }
Esempio n. 5
0
        public PacketProp[] GetPacketProperties()
        {
            PacketProp[] tableProps = m_PropsTable[Cmd];
            if (tableProps != null)
            {
                PacketProp[] props = new PacketProp[tableProps.Length];

                for (int i = 0; i < props.Length; i++)
                {
                    PacketProp pp = tableProps[i];
                    props[i] = new PacketProp(pp, pp.PropInfo.GetValue(this, null));
                }

                return(props);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 6
0
 public PacketProp(PacketProp packetProp, object newValue)
 {
     m_PropInfo  = packetProp.m_PropInfo;
     m_Attribute = packetProp.m_Attribute;
     m_Value     = newValue;
 }
Esempio n. 7
0
		public PacketProp( PacketProp packetProp, object newValue )
		{
			m_PropInfo = packetProp.m_PropInfo;
			m_Attribute = packetProp.m_Attribute;
			m_Value = newValue;
		}
Esempio n. 8
0
		public PacketProp[] GetPacketProperties()
		{
			PacketProp[] tableProps = m_PropsTable[Cmd];
			if ( tableProps != null )
			{
				PacketProp[] props = new PacketProp[tableProps.Length];

				for ( int i = 0; i < props.Length; i++ )
				{
					PacketProp pp = tableProps[i];
					props[i] = new PacketProp( pp, pp.PropInfo.GetValue( this, null ) );
				}

				return props;
			}
			else
				return null;
		}