繁体   English   中英

动态对象反序列化到类

[英]Dynamic Object Deserialization to class

所以这在最后一两天一直困扰着我,但我根本不知道为什么会这样。

当前,我正在尝试将动态对象反序列化为一个类以供使用。 但是由于某种原因,我收到此错误:(我的班级)有一些无效的参数。 我用来反序列化的代码:

dynamic BaseOffsets = JsonConvert.DeserializeObject(File.ReadAllText(Environment.CurrentDirectory + @"\Offsets.json"));
            Netvars = JsonConvert.DeserializeObject<netvars>(BaseOffsets.netvars);
            Signatures = JsonConvert.DeserializeObject<signatures>(BaseOffsets.signatures);

因此,首先,我对照类检查了值。 他们都匹配。 但是,调试器仍然告诉我,类中有一个额外的魔术变量。 即使直接比较之后,我也无法在引起它的任何一个类中找到该变量。

因此,我分解了JSON结构,看是否有我错过的东西。 但是没有变量仍然相同。 我的班级代码:

public class netvars
{
    public Int32 m_ArmorValue { get; set; }
    public Int32 m_Collision { get; set; }
    public Int32 m_CollisionGroup { get; set; }
    public Int32 m_Local { get; set; }
    public Int32 m_MoveType { get; set; }
    public Int32 m_OriginalOwnerXuidHigh { get; set; }
    public Int32 m_OriginalOwnerXuidLow { get; set; }
    public Int32 m_aimPunchAngle { get; set; }
    public Int32 m_aimPunchAngleVel { get; set; }
    public Int32 m_bGunGameImmunity { get; set; }
    public Int32 m_bHasDefuser { get; set; }
    public Int32 m_bHasHelmet { get; set; }
    public Int32 m_bInReload { get; set; }
    public Int32 m_bIsDefusing { get; set; }
    public Int32 m_bIsScoped { get; set; }
    public Int32 m_bSpotted { get; set; }
    public Int32 m_bSpottedByMask { get; set; }
    public Int32 m_clrRender { get; set; }
    public Int32 m_dwBoneMatrix { get; set; }
    public Int32 m_fAccuracyPenalty { get; set; }
    public Int32 m_fFlags { get; set; }
    public Int32 m_flFallbackWear { get; set; }
    public Int32 m_flFlashDuration { get; set; }
    public Int32 m_flFlashMaxAlpha { get; set; }
    public Int32 m_flNextPrimaryAttack { get; set; }
    public Int32 m_hActiveWeapon { get; set; }
    public Int32 m_hMyWeapons { get; set; }
    public Int32 m_hObserverTarget { get; set; }
    public Int32 m_hOwner { get; set; }
    public Int32 m_hOwnerEntity { get; set; }
    public Int32 m_iAccountID { get; set; }
    public Int32 m_iClip1 { get; set; }
    public Int32 m_iCompetitiveRanking { get; set; }
    public Int32 m_iCompetitiveWins { get; set; }
    public Int32 m_iCrosshairId { get; set; }
    public Int32 m_iEntityQuality { get; set; }
    public Int32 m_iFOVStart { get; set; }
    public Int32 m_iGlowIndex { get; set; }
    public Int32 m_iHealth { get; set; }
    public Int32 m_iItemDefinitionIndex { get; set; }
    public Int32 m_iItemIDHigh { get; set; }
    public Int32 m_iObserverMode { get; set; }
    public Int32 m_iShotsFired { get; set; }
    public Int32 m_iState { get; set; }
    public Int32 m_iTeamNum { get; set; }
    public Int32 m_lifeState { get; set; }
    public Int32 m_nFallbackPaintKit { get; set; }
    public Int32 m_nFallbackSeed { get; set; }
    public Int32 m_nFallbackStatTrak { get; set; }
    public Int32 m_nForceBone { get; set; }
    public Int32 m_nTickBase { get; set; }
    public Int32 m_rgflCoordinateFrame { get; set; }
    public Int32 m_szCustomName { get; set; }
    public Int32 m_szLastPlaceName { get; set; }
    public Int32 m_thirdPersonViewAngles { get; set; }
    public Int32 m_vecOrigin { get; set; }
    public Int32 m_vecVelocity { get; set; }
    public Int32 m_vecViewOffset { get; set; }
    public Int32 m_viewPunchAngle { get; set; }
}

public class signatures
{
    public Int32 dwClientState { get; set; }
    public Int32 dwClientState_GetLocalPlayer { get; set; }
    public Int32 dwClientState_IsHLTV { get; set; }
    public Int32 dwClientState_Map { get; set; }
    public Int32 dwClientState_MapDirectory { get; set; }
    public Int32 dwClientState_MaxPlayer { get; set; }
    public Int32 dwClientState_PlayerInfo { get; set; }
    public Int32 dwClientState_State { get; set; }
    public Int32 dwClientState_ViewAngles { get; set; }
    public Int32 dwEntityList { get; set; }
    public Int32 dwForceAttack { get; set; }
    public Int32 dwForceAttack2 { get; set; }
    public Int32 dwForceBackward { get; set; }
    public Int32 dwForceForward { get; set; }
    public Int32 dwForceJump { get; set; }
    public Int32 dwForceLeft { get; set; }
    public Int32 dwForceRight { get; set; }
    public Int32 dwGameDir { get; set; }
    public Int32 dwGameRulesProxy { get; set; }
    public Int32 dwGetAllClasses { get; set; }
    public Int32 dwGlobalVars { get; set; }
    public Int32 dwGlowObjectManager { get; set; }
    public Int32 dwInput { get; set; }
    public Int32 dwInterfaceLinkList { get; set; }
    public Int32 dwLocalPlayer { get; set; }
    public Int32 dwMouseEnable { get; set; }
    public Int32 dwMouseEnablePtr { get; set; }
    public Int32 dwPlayerResource { get; set; }
    public Int32 dwRadarBase { get; set; }
    public Int32 dwSensitivity { get; set; }
    public Int32 dwSensitivityPtr { get; set; }
    public Int32 dwSetClanTag { get; set; }
    public Int32 dwViewMatrix { get; set; }
    public Int32 dwWeaponTable { get; set; }
    public Int32 dwWeaponTableIndex { get; set; }
    public Int32 dwYawPtr { get; set; }
    public Int32 dwZoomSensitivityRatioPtr { get; set; }
    public Int32 dwbSendPackets { get; set; }
    public Int32 dwppDirect3DDevice9 { get; set; }
    public Int32 m_pStudioHdr { get; set; }
    public Int32 m_pitchClassPtr { get; set; }
    public Int32 m_yawClassPtr { get; set; }
}

如果有人可以帮助我,我将非常感激,我已经搜索了几个小时,但我仍然很受挫。

通过反序列化主类并随后取出两个子类来解决我的问题。 这不是我想要的,但是有效

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM