Wanzyee Studio
CryptoObject< T, U >

Wrapper to encrypt and store an object supported by UnityEngine.JsonUtility. More...

Inherits CryptoValue< T, U >.

Public Member Functions

 CryptoObject (T value=default)
 Initialize by serializing the specified object value. More...
 
override string ToString ()
 Return the plain text. More...
 
virtual void OnBeforeSerialize ()
 OnBeforeSerialize, check if saving to obfuscate the plain data, otherwise prepare the editee value. More...
 
virtual void OnAfterDeserialize ()
 OnAfterDeserialize, check if to store and clean the editee value. More...
 

Protected Member Functions

CryptoObject(string json) override T ToValue (string text)
 Initialize with the specified JSON string. More...
 
override string ToText (T value)
 Convert the real value to the text to encrypt. More...
 
ReadValue ()
 Read the stored real value. More...
 
void WriteValue (T value)
 Write the real value to store. More...
 
string ReadText ()
 Read the decrypted plain text. More...
 
void WriteText (string text, bool force=false)
 Encrypt the plain text and write with a new key. More...
 
virtual U ReadEditee ()
 Read the stored value to the editee value. More...
 
virtual void WriteEditee (U editee)
 Write the editee value to the stored value. More...
 
virtual string ValidateEditee ()
 Validate the editee value, return null if correct, otherwise the warning message. More...
 

Properties

virtual T value [get, set]
 The stored value. More...
 

Detailed Description

Wrapper to encrypt and store an object supported by UnityEngine.JsonUtility.

Template Parameters
TThe object type.
UThe property type for editing, commonly use T or string.

Constructor & Destructor Documentation

CryptoObject ( value = default)

Initialize by serializing the specified object value.

Parameters
valueValue.

Member Function Documentation

CryptoObject (string json) override T ToValue ( string  text)
protectedvirtual

Initialize with the specified JSON string.

Parameters
jsonThe JSON string.

Convert the decrypted text to the real value.

Parameters
textText.
Returns
Value.

Reimplemented from CryptoValue< T, U >.

override string ToText ( value)
protectedvirtual

Convert the real value to the text to encrypt.

Parameters
valueValue.
Returns
Text.

Reimplemented from CryptoValue< T, U >.

override string ToString ( )
inherited

Return the plain text.

Returns
A string represents this.
T ReadValue ( )
protectedinherited

Read the stored real value.

Returns
Value.
void WriteValue ( value)
protectedinherited

Write the real value to store.

Parameters
valueValue.
string ReadText ( )
protectedinherited

Read the decrypted plain text.

Returns
Plain text.
void WriteText ( string  text,
bool  force = false 
)
protectedinherited

Encrypt the plain text and write with a new key.

Parameters
textPlain text.
forceIf to force update, otherwise check changed in editor.
virtual void OnBeforeSerialize ( )
virtualinherited

OnBeforeSerialize, check if saving to obfuscate the plain data, otherwise prepare the editee value.

Reimplemented in CryptoCache< T, U >.

virtual void OnAfterDeserialize ( )
virtualinherited

OnAfterDeserialize, check if to store and clean the editee value.

Reimplemented in CryptoCache< T, U >.

virtual U ReadEditee ( )
protectedvirtualinherited

Read the stored value to the editee value.

Returns
Editee.
virtual void WriteEditee ( editee)
protectedvirtualinherited

Write the editee value to the stored value.

Parameters
editeeEditee.
virtual string ValidateEditee ( )
protectedvirtualinherited

Validate the editee value, return null if correct, otherwise the warning message.

Returns
Message.

Property Documentation

virtual T value
getsetinherited

The stored value.