RoboZhando/Redis/Serialize/RedisConvert.cs
/// <summary>
/// Deserializes a dictionary into a object
/// </summary>
/// <param name="buffer">The data that was received by the redis</param>
/// <param name="type">The type of target object</param>
/// <param name="reference">The target object</param>
/// <param name="subkey">The subkey (optional)</param>
/// <returns></returns>
Deserializes a dictionary into a object
Deserializes a dictionary into a object
private static bool Deserialize(Dictionary<string, string> buffer, Type type, ref object reference, string subkey = "")
        {
            Debug.Assert(type != null);
            Debug.Assert(reference != null);
            Debug.Assert(buffer != null);
            bool hasElements = false;
			RedisOptionAttribute options = type.GetCustomAttribute<RedisOptionAttribute>();
            if (options == null) options = new RedisOptionAttribute();
			foreach (var property in type.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance))
				if (DeserializeMember(buffer, type, new SerializeMember(property), ref reference, subkey, options))
					hasElements = true;
			foreach (var field in type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance))
				if (DeserializeMember(buffer, type, new SerializeMember(field), ref reference, subkey, options))
					hasElements = true;
			return hasElements;
		}
private static bool Deserialize ( Dictionary < string , string > buffer , Type type , ref object reference , string subkey = " " ) { Debug . Assert ( type != null ) ; Debug . Assert ( reference != null ) ; Debug . Assert ( buffer != null ) ; bool hasElements = false ; RedisOptionAttribute options = type . GetCustomAttribute < RedisOptionAttribute > ( ) ; if ( options == null ) options = new RedisOptionAttribute ( ) ; foreach ( var property in type . GetProperties ( BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Instance ) ) if ( DeserializeMember ( buffer , type , new SerializeMember ( property ) , ref reference , subkey , options ) ) hasElements = true ; foreach ( var field in type . GetFields ( BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Instance ) ) if ( DeserializeMember ( buffer , type , new SerializeMember ( field ) , ref reference , subkey , options ) ) hasElements = true ; return hasElements ; }
Deserializes a dictionary into a object
Deserializes a dictionary into a object
//Prepare the type and initial options //See if we should override the options //Create a new instance of the type //Return the element state
None
buffer
Dictionary<string, string>
The data that was received by the redis
The data that was received by the redis
type
Type
The type of target object
The type of target object
object
ref
<not_specific>
subkey
string
The subkey (optional)
The subkey ( optional )
reference
<not_specific>
The target object
The target object