C
C#2y ago
nulled

❔ using data received from a Post to determine what property to set

Below will be attached text of two classes, one called PostReceiveStruct and the other UserAccount. UserAccount holds the structed for a json format that can be turned into an object. PostReceiveStruct holds the structure for how data received from a post request can be turned into an object as well Both of these classes work to what I need them for, what I would like to know is how can use DCName's value to use in UserAccount The easiest example that I can think of is something like what they do in rLua.
local DCName = "version"
UserAccount[DCName]
local DCName = "version"
UserAccount[DCName]
public class PostReceiveStruct
{
public ulong uid { get; set; }
public string DCName { get; set; }
public string DCValue { get; set; }
}
public class PostReceiveStruct
{
public ulong uid { get; set; }
public string DCName { get; set; }
public string DCValue { get; set; }
}
public class Medal
{
public string name { get; set; }
public int awarded { get; set; }
public int permission { get; set; }
}
public class BranchMedals
{
public List<Medal> medal { get; set; }
}
public class BranchList
{
public List<BranchMedals> branches { get; set; }
}
public class UserAccount
{
public ulong RID { get; set; }
public ulong ID { get; set; }
public string version { get; set; }
public dynamic medals {get;set;}
}
public class Medal
{
public string name { get; set; }
public int awarded { get; set; }
public int permission { get; set; }
}
public class BranchMedals
{
public List<Medal> medal { get; set; }
}
public class BranchList
{
public List<BranchMedals> branches { get; set; }
}
public class UserAccount
{
public ulong RID { get; set; }
public ulong ID { get; set; }
public string version { get; set; }
public dynamic medals {get;set;}
}
7 Replies
phaseshift
phaseshift2y ago
UserAccount doesnt have anywhere to use a name. So what do you mean? Do you want a dictionary of user accounts, and have the key be the DCName?
Angius
Angius2y ago
I think the OP wants something like
account.{post.DCName} = post.DCValue
account.{post.DCName} = post.DCValue
Accessing properties of an object like it was a dictionary
nulled
nulledOP2y ago
yes exactly
Angius
Angius2y ago
The answer is "no", then
phaseshift
phaseshift2y ago
python is >>> that way 😅
nulled
nulledOP2y ago
damn well alright thank you guys!
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server