InfoBlockConvertor Class

public static class InfoBlockConvertor
{

private static JsonSerializerSettings theJsonSerializerSettings = new JsonSerializerSettings();
private static StringEncryptor myStringEncryptor = StringEncryptor.Instance;

//————————————————————————————————-
//— Create an Infoblock object out of an Encrypted String
//————————————————————————————————-
public static InfoBlock DecodeFromString(string aString)
{

InfoBlock myInfoBlock = null;
theJsonSerializerSettings.TypeNameHandling = TypeNameHandling.None;
try
{

string decryptedString = myStringEncryptor.Decrypt(aString);
myInfoBlock = JsonConvert.DeserializeObject<InfoBlock>(decryptedString, theJsonSerializerSettings);

}

catch (Exception ex)

{

}

return myInfoBlock;

}

//————————————————————————————————-
//— Create an Encrypted String out of an Infoblock object
//————————————————————————————————-
public static string EncodeToString(InfoBlock anInfoBlock)
{

string myEncryptedString = “”;
string myString;
theJsonSerializerSettings.TypeNameHandling = TypeNameHandling.None;
try
{

myString = JsonConvert.SerializeObject(anInfoBlock, theJsonSerializerSettings);
myEncryptedString = myStringEncryptor.Encrypt(myString);

}

catch (Exception ex)

{

}

return myEncryptedString;

}

}

 

Advertisements

Post a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s