Example #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));
                }
            }
        }
Example #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);
            }
        }
Example #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 ) );
				}
			}
		}
Example #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));
            }
        }
Example #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);
            }
        }
Example #6
0
 public PacketProp(PacketProp packetProp, object newValue)
 {
     m_PropInfo  = packetProp.m_PropInfo;
     m_Attribute = packetProp.m_Attribute;
     m_Value     = newValue;
 }
Example #7
0
		public PacketProp( PacketProp packetProp, object newValue )
		{
			m_PropInfo = packetProp.m_PropInfo;
			m_Attribute = packetProp.m_Attribute;
			m_Value = newValue;
		}
Example #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;
		}