i will discuss my case to make a good understand for my question at first i am getting data from my api client as my class :
return JsonConvert.DeserializeObject<TestRespone>(responseContent);
so i get the data of my class : which is
public enum TestStatus
{
Sucess,
Error
}
public class TestRespone
{
public enum TestStatus{ get; set; }
public string Message { get; set; }
}
However i get the Teststatus from api as a string but i want to apply as an enum immediatly in my code : i wrote extra code :
public static TestStatus ToTestStatus(this string s)
{
switch (s)
{
case "INITIALIZED":
return SignatureStatus.Sucess;
case "SIGNED":
return SignatureStatus.Error;
}
}
my question is how to custmize public enum TestStatus to be immediatly an enum cause it alreay come as a sring ? i mean i get it from api as string but i want it in class like enum