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)); } } }
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); } }
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 ) ); } } }
public int CompareTo(object obj) { PacketProp pp = obj as PacketProp; if (pp == null) { return(-1); } else { return(m_Attribute.CompareTo(pp.m_Attribute)); } }
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); } }
public PacketProp(PacketProp packetProp, object newValue) { m_PropInfo = packetProp.m_PropInfo; m_Attribute = packetProp.m_Attribute; m_Value = newValue; }
public PacketProp( PacketProp packetProp, object newValue ) { m_PropInfo = packetProp.m_PropInfo; m_Attribute = packetProp.m_Attribute; m_Value = newValue; }
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; }