当前位置: 首页>>代码示例>>C#>>正文


C# MemberInfo.SetValue方法代码示例

本文整理汇总了C#中System.Reflection.MemberInfo.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# MemberInfo.SetValue方法的具体用法?C# MemberInfo.SetValue怎么用?C# MemberInfo.SetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Reflection.MemberInfo的用法示例。


在下文中一共展示了MemberInfo.SetValue方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InjectIntroducedField

 /// <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));
 }
开发者ID:csuffyy,项目名称:MrAdvice,代码行数:11,代码来源:Invocation.Introduction.cs

示例2: Set

 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;
 }
开发者ID:naighes,项目名称:ReactiveMongo,代码行数:7,代码来源:Setters.cs

示例3: DecryptMember

        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");
        }
开发者ID:ninocrudele,项目名称:NServiceBus,代码行数:21,代码来源:EncryptionMutator.cs

示例4: EncryptMember

        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");
        }
开发者ID:ninocrudele,项目名称:NServiceBus,代码行数:26,代码来源:EncryptionMutator.cs

示例5: EncryptMember

        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");
        }
开发者ID:remogloor,项目名称:NServiceBus,代码行数:31,代码来源:EncryptionMessageMutator.cs

示例6: DecryptMember

        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");
        }
开发者ID:remogloor,项目名称:NServiceBus,代码行数:22,代码来源:EncryptionMessageMutator.cs

示例7: EncryptMember

        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");
        }
开发者ID:89sos98,项目名称:NServiceBus,代码行数:31,代码来源:EncryptionMessageMutator.cs

示例8: CreateEnumCollectionSection

		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;
		}
开发者ID:CartBlanche,项目名称:MonoMobile.MVVM,代码行数:50,代码来源:ViewParser.cs


注:本文中的System.Reflection.MemberInfo.SetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。