/// <summary> /// Injects the introduced field. /// </summary> /// <param name="advice">The advice.</param> /// <param name="adviceMemberInfo">The member information.</param> /// <param name="advisedType">Type of the advised.</param> /// <exception cref="System.InvalidOperationException">Internal error, can not find matching introduced field</exception> private static void InjectIntroducedField(IAdvice advice, MemberInfo adviceMemberInfo, Type advisedType) { adviceMemberInfo.SetValue(advice, Activator.CreateInstance(adviceMemberInfo.GetMemberType(), advice, adviceMemberInfo)); }
public void Set(MemberInfo member, Object instance, Byte[] buffer, ref Int32 currentPosition) { var length = buffer.ReadInt32(currentPosition); currentPosition += sizeof (Int32); member.SetValue(instance, _encoding.GetString(buffer, currentPosition, length - 1)); currentPosition += length; }
void DecryptMember(object target, MemberInfo property) { var encryptedValue = property.GetValue(target); if (encryptedValue == null) { return; } var wireEncryptedString = encryptedValue as WireEncryptedString; if (wireEncryptedString != null) { Decrypt(wireEncryptedString); } else { property.SetValue(target, DecryptUserSpecifiedProperty(encryptedValue)); } Log.Debug(property.Name + " decrypted successfully"); }
void EncryptMember(object target, MemberInfo member) { var valueToEncrypt = member.GetValue(target); if (valueToEncrypt == null) { return; } var wireEncryptedString = valueToEncrypt as WireEncryptedString; if (wireEncryptedString != null) { var encryptedString = wireEncryptedString; EncryptWireEncryptedString(encryptedString); //we clear the properties to avoid having the extra data serialized encryptedString.EncryptedBase64Value = null; encryptedString.Base64Iv = null; } else { member.SetValue(target, EncryptUserSpecifiedProperty(valueToEncrypt)); } Log.Debug(member.Name + " encrypted successfully"); }
void EncryptMember(object target, MemberInfo member) { var valueToEncrypt = member.GetValue(target); if (valueToEncrypt == null) return; if (EncryptionService == null) throw new InvalidOperationException( String.Format("Cannot encrypt field {0} because no encryption service was configured.", member.Name)); if (valueToEncrypt is WireEncryptedString) { var encryptedString = (WireEncryptedString)valueToEncrypt; EncryptWireEncryptedString(encryptedString); if (!ConfigureEncryption.EnsureCompatibilityWithNSB2) { //we clear the properties to avoid having the extra data serialized encryptedString.EncryptedBase64Value = null; encryptedString.Base64Iv = null; } } else { member.SetValue(target, EncryptUserSpecifiedProperty(valueToEncrypt)); } Log.Debug(member.Name + " encrypted successfully"); }
void DecryptMember(object target, MemberInfo property) { var encryptedValue = property.GetValue(target); if (encryptedValue == null) return; if (EncryptionService == null) throw new InvalidOperationException( String.Format("Cannot decrypt field {0} because no encryption service was configured.", property.Name)); if (encryptedValue is WireEncryptedString) { Decrypt((WireEncryptedString)encryptedValue); } else { property.SetValue(target, DecryptUserSpecifiedProperty(encryptedValue)); } Log.Debug(property.Name + " decrypted successfully"); }
void EncryptMember(object target, MemberInfo member) { var valueToEncrypt = member.GetValue(target); if (valueToEncrypt == null) { return; } if (EncryptionService == null) { throw new Exception(String.Format("Cannot encrypt field {0} because no encryption service was configured.",member.Name)); } var wireEncryptedString = valueToEncrypt as WireEncryptedString; if (wireEncryptedString != null) { var encryptedString = wireEncryptedString; EncryptWireEncryptedString(encryptedString); //we clear the properties to avoid having the extra data serialized encryptedString.EncryptedBase64Value = null; encryptedString.Base64Iv = null; } else { member.SetValue(target, EncryptUserSpecifiedProperty(valueToEncrypt)); } Log.Debug(member.Name + " encrypted successfully"); }
private ISection CreateEnumCollectionSection(MemberInfo member, string caption, object view, List<Binding> bindings) { Type memberType = GetTypeForMember(member); object context = view; var dataContext = view as IDataContext; if (dataContext != null) { context = dataContext.DataContext; } SetDefaultConverter(view, member, "DataContext", new EnumCollectionConverter(), null, bindings); member = GetMemberFromDataContext(member, ref context); var csection = new Section() { IsMultiselect = true, Opaque = false }; var collection = member.GetValue(view); if (collection == null) { var collectionType = typeof(EnumCollection<>); var enumType = memberType.GetGenericArguments().FirstOrDefault(); Type[] generic = { enumType }; collection = Activator.CreateInstance(collectionType.MakeGenericType(generic)); member.SetValue(view, collection); } var index = 0; var items = (EnumCollection)collection; foreach (var item in items.Items) { var checkboxElement = new CheckboxElement(item.Description) { Item = item, Index = index, DataContext = item.IsChecked, Group = item.GroupName }; csection.Add(checkboxElement); index++; } csection.DataContext = memberType; csection.ViewBinding.DataContextCode = DataContextCode.EnumCollection; return csection; }
public void Set(MemberInfo member, Object instance, Byte[] buffer, ref Int32 currentPosition) { member.SetValue(instance, buffer.ReadInt32(currentPosition)); currentPosition += sizeof (Int32); }
public void Set(MemberInfo member, Object instance, Byte[] buffer, ref Int32 currentPosition) { member.SetValue(instance, BitConverter.ToDouble(buffer, currentPosition)); currentPosition += sizeof (Double); }
public void Set(MemberInfo member, Object instance, Byte[] buffer, ref Int32 currentPosition) { member.SetValue(instance, buffer[currentPosition] == 0x01); currentPosition++; }