Wanzyee Studio
CryptoCache< T, U >abstract

Wrapper to encrypt and store a value with obfuscated cache for performance. More...

Inherits CryptoValue< T, U >.

Public Member Functions

CryptoCache(T value=default) override void OnBeforeSerialize ()
 Initialize with the specified value. More...
 
override void OnAfterDeserialize ()
 OnAfterDeserialize, read the real value to the obfuscated cache. More...
 
override string ToString ()
 Return the plain text. More...
 

Protected Member Functions

abstract T ReadObfuscated ()
 Read the obfuscated cache value. More...
 
abstract void WriteObfuscated (T value)
 Write value to the obfuscated cache. More...
 
int RandomValue (int min=int.MinValue, int max=int.MaxValue)
 Get a random value in the specified range. 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 T ToValue (string text)
 Convert the decrypted text to the real value. More...
 
virtual string ToText (T value)
 Convert the real value to the text to encrypt. 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

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

Detailed Description

Wrapper to encrypt and store a value with obfuscated cache for performance.

A derived class should provide a simple algorithm to keep the obfuscated data in the memory.

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

Member Function Documentation

CryptoCache (T value = default) override void OnBeforeSerialize ( )
virtual

Initialize with the specified value.

Parameters
valueValue.

OnBeforeSerialize, write the obfuscated cache to the real value.

Reimplemented from CryptoValue< T, U >.

override void OnAfterDeserialize ( )
virtual

OnAfterDeserialize, read the real value to the obfuscated cache.

Reimplemented from CryptoValue< T, U >.

abstract T ReadObfuscated ( )
protectedpure virtual

Read the obfuscated cache value.

Returns
Value.

Implemented in CryptoDate, CryptoPeriod, CryptoFloat, CryptoAscii, CryptoBool, CryptoInt, and CryptoLong.

abstract void WriteObfuscated ( value)
protectedpure virtual

Write value to the obfuscated cache.

Parameters
valueValue.
int RandomValue ( int  min = int.MinValue,
int  max = int.MaxValue 
)
protected

Get a random value in the specified range.

Parameters
minMin value.
maxMax value.
Returns
Value.
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 T ToValue ( string  text)
protectedvirtualinherited

Convert the decrypted text to the real value.

Parameters
textText.
Returns
Value.

Reimplemented in CryptoObject< T, U >.

virtual string ToText ( value)
protectedvirtualinherited

Convert the real value to the text to encrypt.

Parameters
valueValue.
Returns
Text.

Reimplemented in CryptoObject< 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

override T value
getset

The stored value.