public void SetValue(string property, object value) { // Si propiedad es Hash, coloca valor hash if (property == FieldHash) { Reflex.SetPropertyValue(this, property, FieldsHashCode); return; } if (Reflex.PropertyHasAttribute(this, property, typeof(EncryptAttribute))) { if (EncryptIters != 0) { Encriptador.Iters = EncryptIters; } if (!string.IsNullOrEmpty(EncryptPass)) { Encriptador.Pass = EncryptPass; } if (!string.IsNullOrEmpty(EncryptSalt)) { Encriptador.Salt = EncryptSalt; } // obtiene valor desencriptado de acuerdo al tipo de propiedad switch (Reflex.GetPropertyTypeName(this, property)) { case "Double": string doubleDecrypt = Encriptador.Decrypt(value.ToString()); value = double.Parse(doubleDecrypt); break; case "Int32": string intDecrypt = Encriptador.Decrypt(value.ToString()); value = int.Parse(intDecrypt); break; case "Byte[]": byte[] bytesLength = new byte[4]; Array.Copy(((byte[])value), bytesLength, bytesLength.Length); int lengthEncrypted = Convierte.BytesToInt(bytesLength); byte[] bytesEncrypted = new byte[lengthEncrypted]; Array.Copy((byte[])value, 4, bytesEncrypted, 0, bytesEncrypted.Length); byte[] bytesNoEncrypted = null; if (((byte[])value).Length > 4 + lengthEncrypted) { int lengthNoEncrypted = ((byte[])value).Length - (4 + lengthEncrypted); bytesNoEncrypted = new byte[lengthNoEncrypted]; Array.Copy((byte[])value, 4 + lengthEncrypted, bytesNoEncrypted, 0, bytesNoEncrypted.Length); } byte[] bytesDecrypted = Encriptador.DecryptBytes(bytesEncrypted); value = bytesNoEncrypted == null ? bytesDecrypted : bytesDecrypted.Concat(bytesNoEncrypted).ToArray(); break; default: value = Encriptador.Decrypt(value.ToString()); break; } } Reflex.SetPropertyValue(this, property, value); }