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


C# FieldReference.ToString方法代码示例

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


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

示例1: WeaveDependencyProperty

        private void WeaveDependencyProperty(MethodBody staticCtorBody, FieldReference field, PropertyDefinition property)
        {
            var assembly = property.DeclaringType.Module.Assembly;
            var propertyType = assembly.ImportType(Type.GetType(property.PropertyType.FullName));
            var getTypeFromHandle = assembly.ImportMethod(typeof(Type).GetMethod("GetTypeFromHandle"));
            var register = assembly.ImportMethod(typeof(DependencyProperty).GetMethod("Register", new[] { typeof(string), typeof(Type), typeof(Type) }));

            // ignore previously weaved DPs
            if (staticCtorBody.Instructions.Any(i => i.Operand != null && i.Operand.ToString() == field.ToString()))
            {
                return;
            }

            var ret = staticCtorBody.Instructions.Last();
            if (ret.OpCode != OpCodes.Ret)
                throw new InvalidOperationException("The last instruction should be OpCode.Ret");

            HasChanges = true;

            var proc = staticCtorBody.GetILProcessor();
            proc.InsertBefore(ret, proc.Create(OpCodes.Ldstr, property.Name));
            proc.InsertBefore(ret, proc.Create(OpCodes.Ldtoken, propertyType));
            proc.InsertBefore(ret, proc.Create(OpCodes.Call, getTypeFromHandle));
            proc.InsertBefore(ret, proc.Create(OpCodes.Ldtoken, property.DeclaringType));
            proc.InsertBefore(ret, proc.Create(OpCodes.Call, getTypeFromHandle));
            proc.InsertBefore(ret, proc.Create(OpCodes.Call, register));
            proc.InsertBefore(ret, proc.Create(OpCodes.Stsfld, field));
        }
开发者ID:bling,项目名称:dependencypropertyweaver,代码行数:28,代码来源:DependencyPropertyWeaver.cs

示例2: method_6

		internal BfField method_6(FieldReference fieldReference_0)
		{
			BfAssembly bfAssembly;
			BfField result;
			if (fieldReference_0.DeclaringType.Scope is AssemblyNameReference)
			{
				bfAssembly = this.dictionary_0[((AssemblyNameReference)fieldReference_0.DeclaringType.Scope).FullName];
			}
			else
			{
				if (!(fieldReference_0.DeclaringType.Scope is ModuleDefinition))
				{
					Logger.LogWarning("GetBfField1", "Couldn't find assembly for field: " + fieldReference_0.ToString());
					result = null;
					return result;
				}
				bfAssembly = this.dictionary_0[((ModuleDefinition)fieldReference_0.DeclaringType.Scope).Assembly.Name.FullName];
			}
			string key = BfCache.smethod_2(fieldReference_0.DeclaringType);
			BfType bfType;
			bfAssembly.method_4().TryGetValue(key, out bfType);
			if (bfType == null)
			{
				Logger.LogWarning("GetBfField2", "Couldn't find type for field: " + fieldReference_0.ToString());
				result = null;
			}
			else
			{
				foreach (BfField bfField in ((IEnumerable<BfField>)bfType.Fields))
				{
					BfField bfField;
					if (fieldReference_0.Name == bfField.Name)
					{
						result = bfField;
						return result;
					}
				}
				foreach (FieldDefinition fieldDefinition in bfType.method_2().Fields)
				{
					if (fieldDefinition.Name == fieldReference_0.Name)
					{
						BfField bfField = new BfField(this, fieldDefinition, bfType);
						this.fieldCollection_0.method_1(bfField);
						bfType.Fields.method_1(bfField);
						result = bfField;
						return result;
					}
				}
				Logger.LogWarning("GetBfField3", "Couldn't find field " + fieldReference_0.ToString() + " in type: " + bfType.FullName);
				result = null;
			}
			return result;
		}
开发者ID:akordowski,项目名称:Source-Code-Nitriq,代码行数:53,代码来源:BfCache.cs

示例3: ImportFieldReference

        public FieldReference ImportFieldReference(FieldReference field, ImportContext context)
        {
            if (field.DeclaringType.Module == m_module)
                return field;

            ImportCache ();

            FieldReference f = (FieldReference) m_memberRefCache [field.ToString ()];
            if (f != null)
                return f;

            f = new FieldReference (
                field.Name,
                ImportTypeReference (field.DeclaringType, context),
                ImportTypeReference (field.FieldType, context));

            m_module.MemberReferences.Add (f);
            m_memberRefCache [field.ToString ()] = f;
            return f;
        }
开发者ID:KenMacD,项目名称:deconfuser,代码行数:20,代码来源:ReflectionHelper.cs


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