本文整理汇总了C#中Mono.Cecil.FieldDefinition类的典型用法代码示例。如果您正苦于以下问题:C# FieldDefinition类的具体用法?C# FieldDefinition怎么用?C# FieldDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FieldDefinition类属于Mono.Cecil命名空间,在下文中一共展示了FieldDefinition类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Field
public Field(FieldDefinition fieldDefinition, Class declaringClass, Type type, int structIndex)
{
FieldDefinition = fieldDefinition;
DeclaringClass = declaringClass;
Type = type;
StructIndex = structIndex;
}
开发者ID:frje,项目名称:SharpLang,代码行数:7,代码来源:Field.cs
示例2: GetWeaver
public override IWeaver GetWeaver(MethodDefinition method, FieldDefinition mixin)
{
if (method.CustomAttributes.Any (a => a.AttributeType.FullName == Constants.AsyncStateMachineAttribute))
return GetAsyncMethodWeaver (method, mixin);
return new FakeWeaver ();
throw new NotImplementedException ();
}
开发者ID:JeanSebTr,项目名称:Comedian,代码行数:7,代码来源:ActorEngine.cs
示例3: AnalyzedFieldNode
public AnalyzedFieldNode(FieldDefinition analyzedField)
{
if (analyzedField == null)
throw new ArgumentNullException("analyzedField");
this.analyzedField = analyzedField;
this.LazyLoading = true;
}
开发者ID:arturek,项目名称:ILSpy,代码行数:7,代码来源:AnalyzedFieldNode.cs
示例4: Field
public Field(FieldDefinition fieldDefinition, Type declaringType, Type type, int structIndex)
{
FieldDefinition = fieldDefinition;
DeclaringType = declaringType;
Type = type;
StructIndex = structIndex;
}
开发者ID:RainsSoft,项目名称:SharpLang,代码行数:7,代码来源:Field.cs
示例5: WeaveInterceptionCall
private void WeaveInterceptionCall(
MethodDefinition methodToExtend,
MethodDefinition decoratedMethodParameter,
MethodDefinition implementationMethodParameter,
FieldDefinition interceptorManager)
{
methodToExtend.Body.InitLocals = true;
ILProcessor processor = methodToExtend.Body.GetILProcessor();
processor.Emit(OpCodes.Nop);
var decoratedMethodVar = methodToExtend.AddVariableDefinition("__fody$originalMethod", this.methodBaseTypeRef);
var implementationMethodVar = methodToExtend.AddVariableDefinition("__fody$implementationMethod", this.methodBaseTypeRef);
var parametersVar = methodToExtend.AddVariableDefinition("__fody$parameters", this.objectArrayTypeRef);
this.SaveMethodBaseToVariable(processor, decoratedMethodParameter, decoratedMethodVar);
if (implementationMethodParameter != null)
{
this.SaveMethodBaseToVariable(processor, implementationMethodParameter, implementationMethodVar);
}
processor.SaveParametersToNewObjectArray(parametersVar, methodToExtend.Parameters.ToArray());
this.CallInterceptMethod(interceptorManager, processor, decoratedMethodVar, implementationMethodVar, parametersVar);
HandleInterceptReturnValue(methodToExtend, processor);
// write method end
processor.Emit(OpCodes.Ret);
methodToExtend.Body.OptimizeMacros();
}
开发者ID:BrunoJuchli,项目名称:StaticProxy.Fody,代码行数:30,代码来源:MethodWeaver.cs
示例6: StateControllerRemover
public StateControllerRemover(MethodSpecificContext methodContext, FieldDefinition stateField = null)
{
this.methodContext = methodContext;
this.theCFG = methodContext.ControlFlowGraph;
this.stateField = stateField;
this.stateToStartBlock = new InstructionBlock[this.theCFG.Blocks.Length];
}
开发者ID:Feng2012,项目名称:JustDecompileEngine,代码行数:7,代码来源:StateControllerRemover.cs
示例7: InjectLoadHook
static void InjectLoadHook()
{
// only hooking to V2 shouldn't be bad: V1 worlds won't have mod data in them, because 1.3 (and prism) only write as V2
var loadWorld = typeDef_WorldFile.GetMethod("loadWorld");
var lwb = loadWorld.Body;
var lwbproc = lwb.GetILProcessor();
MethodDefinition invokeLoadWorld;
var loadWorldDel = context.CreateDelegate("Terraria.PrismInjections", "WorldFile_OnLoadWorldDel", typeSys.Void, out invokeLoadWorld, typeSys.Boolean);
var onLoadWorld = new FieldDefinition("P_OnLoadWorld", FieldAttributes.Public | FieldAttributes.Static, loadWorldDel);
typeDef_WorldFile.Fields.Add(onLoadWorld);
OpCode[] toFind =
{
OpCodes.Br_S,
OpCodes.Ldloc_S,
OpCodes.Call, // wtf?
OpCodes.Stloc_S
};
Instruction[] toInject =
{
Instruction.Create(OpCodes.Ldsfld, onLoadWorld),
Instruction.Create(OpCodes.Ldarg_0),
Instruction.Create(OpCodes.Callvirt, invokeLoadWorld)
};
var instr = lwb.FindInstrSeqStart(toFind).Next.Next.Next.Next;
for (int i = 0; i < toInject.Length; i++)
lwbproc.InsertBefore(instr, toInject[i]);
}
开发者ID:Reuged,项目名称:Prism,代码行数:34,代码来源:WorldFilePatcher.cs
示例8: FieldVisitor
//public FieldVisitor(ClassInfo classInfo, string name, string descriptor, string signature, object value,
// bool isFinal, bool isStatic, bool isPrivate)
//{
// Type type = ClrType.FromDescriptor(descriptor);
// classInfo.AddField(new FieldInfo(classInfo, name, type, isFinal, isStatic, isPrivate));
//}
public FieldVisitor(ClassInfo classInfo, FieldDefinition fieldDefinition)
{
//classInfo.AddField();
//Type type = ClrType.FromName(fieldDefinition.FieldType.FullName);
Type type = ClrType.FromDescriptor(fieldDefinition.FieldType.FullName);
classInfo.AddField(new FieldInfo(classInfo, fieldDefinition.Name, type, false, fieldDefinition.IsStatic, fieldDefinition.IsPrivate));
}
开发者ID:dbremner,项目名称:dotnet-testability-explorer,代码行数:15,代码来源:FieldVisitor.cs
示例9: YieldFieldsInformation
public YieldFieldsInformation(FieldDefinition stateHolderField, FieldDefinition currentItemField,
VariableReference returnFlagVariable)
{
this.stateHolderField = stateHolderField;
this.currentItemField = currentItemField;
this.returnFlagVariable = returnFlagVariable;
}
开发者ID:Feng2012,项目名称:JustDecompileEngine,代码行数:7,代码来源:YieldFieldsInformation.cs
示例10: ProcessField
protected override void ProcessField(FieldDefinition fieldDef)
{
if (fieldDef.IsPublic || fieldDef.IsFamily || fieldDef.IsFamilyOrAssembly) {
_members.Add(fieldDef);
}
base.ProcessField(fieldDef);
}
开发者ID:LoveDuckie,项目名称:Piranha,代码行数:7,代码来源:ListApiProcessor.cs
示例11: AsyncMethodWeaver
public AsyncMethodWeaver(IEngine engine, MethodDefinition method, FieldDefinition actorMixin, FieldDefinition stateMachineMixin)
{
_engine = engine;
_method = method;
_actorMixin = actorMixin;
_stateMachineMixin = stateMachineMixin;
}
开发者ID:JeanSebTr,项目名称:Comedian,代码行数:7,代码来源:AsyncMethodWeaver.cs
示例12: Visit
protected override void Visit(FieldDefinition fieldDefinition, Unity.Cecil.Visitor.Context context)
{
if (!GenericsUtilities.CheckForMaximumRecursion(this._genericContext.Type))
{
base.Visit(fieldDefinition, context);
}
}
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:7,代码来源:GenericContextAwareDeclarationOnlyVisitor.cs
示例13: AddPropertyGetter
public static MethodDefinition AddPropertyGetter(
PropertyDefinition property
, MethodAttributes methodAttributes = MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.NewSlot | MethodAttributes.Virtual
, FieldDefinition backingField = null)
{
if (backingField == null)
{
// TODO: Try and find existing friendly named backingFields first.
backingField = AddPropertyBackingField(property);
}
var methodName = "get_" + property.Name;
var getter = new MethodDefinition(methodName, methodAttributes, property.PropertyType)
{
IsGetter = true,
Body = {InitLocals = true},
};
getter.Body.Variables.Add(new VariableDefinition(property.PropertyType));
var returnStart = Instruction.Create(OpCodes.Ldloc_0);
getter.Body.Instructions.Append(
Instruction.Create(OpCodes.Ldarg_0),
Instruction.Create(OpCodes.Ldfld, backingField),
Instruction.Create(OpCodes.Stloc_0),
Instruction.Create(OpCodes.Br_S, returnStart),
returnStart,
Instruction.Create(OpCodes.Ret)
);
property.GetMethod = getter;
property.DeclaringType.Methods.Add(getter);
return getter;
}
开发者ID:brainoffline,项目名称:Commander.Fody,代码行数:34,代码来源:CommandPropertyInjector.cs
示例14: CreateNewField
/// <summary>
/// Creates a new field in the target assembly, for the specified type.
/// </summary>
/// <param name="targetDeclaringType">The target declaring type.</param>
/// <param name="yourField">Your field.</param>
/// <param name="attr">The action attribute.</param>
/// <exception cref="PatchDeclerationException">Thrown if this member collides with another member, and the error cannot be resolved.</exception>
/// <returns></returns>
private NewMemberStatus CreateNewField(TypeDefinition targetDeclaringType, FieldDefinition yourField,
NewMemberAttribute attr)
{
if (attr.IsImplicit) {
Log_implicitly_creating_member("field", yourField);
} else {
Log_creating_member("field", yourField);
}
var maybeDuplicate = targetDeclaringType.GetField(yourField.Name);
if (maybeDuplicate != null) {
Log_duplicate_member("field", yourField, maybeDuplicate);
if ((DebugOptions & DebugFlags.CreationOverwrites) != 0) {
Log_overwriting();
return NewMemberStatus.Continue;
}
if (attr.IsImplicit) {
return NewMemberStatus.InvalidItem;
}
throw Errors.Duplicate_member("type", yourField.FullName, maybeDuplicate.FullName);
}
var targetField =
new FieldDefinition(yourField.Name, yourField.Resolve().Attributes, FixTypeReference(yourField.FieldType)) {
InitialValue = yourField.InitialValue, //probably for string consts
Constant = yourField.Constant
};
targetDeclaringType.Fields.Add(targetField);
return NewMemberStatus.Continue;
}
开发者ID:gitter-badger,项目名称:Patchwork,代码行数:36,代码来源:CreateNew.cs
示例15: Add
public void Add(FieldDefinition value)
{
if (!Contains (value))
Attach (value);
List.Add (value);
}
开发者ID:KenMacD,项目名称:deconfuser,代码行数:7,代码来源:FieldDefinitionCollection.cs
示例16: GetTargetCecilDefintion
internal FieldDefinition GetTargetCecilDefintion(ModuleDefinition module)
{
if (_targetCecilDef == null)
_targetCecilDef = DeclInjectee.GetTargetCecilType(module).FindMatchingField(TargetField, true);
return _targetCecilDef;
}
开发者ID:MarkusSintonen,项目名称:MNetInjector,代码行数:7,代码来源:FieldInjectees.cs
示例17: GetInjecteeCecilDefintion
internal FieldDefinition GetInjecteeCecilDefintion(ModuleDefinition module)
{
if (_injecteeCecilDef == null)
_injecteeCecilDef = DeclInjectee.GetInjecteeCecilType(module).FindMatchingField(InjecteeField, true);
return _injecteeCecilDef;
}
开发者ID:MarkusSintonen,项目名称:MNetInjector,代码行数:7,代码来源:FieldInjecteeBase.cs
示例18: InjectBuffEffectsCall
static void InjectBuffEffectsCall()
{
var updateNpc = typeDef_NPC.GetMethod("RealUpdateNPC");
MethodDefinition invokeEffects;
var onBuffEffects = context.CreateDelegate("Terraria.PrismInjections", "NPC_BuffEffectsDel", typeSys.Void, out invokeEffects, typeDef_NPC);
var buffEffects = new FieldDefinition("P_OnBuffEffects", FieldAttributes.Public | FieldAttributes.Static, onBuffEffects);
typeDef_NPC.Fields.Add(buffEffects);
OpCode[] toRem =
{
OpCodes.Ldarg_0,
OpCodes.Ldfld,
OpCodes.Brfalse
};
var unb = updateNpc.Body;
var unproc = unb.GetILProcessor();
Instruction instr;
int start = 0;
while (true)
{
instr = unb.FindInstrSeqStart(toRem, start);
if (instr.Next.Operand == typeDef_NPC.GetField("soulDrain"))
break;
else
start = unb.Instructions.IndexOf(instr) + 1;
}
unproc.InsertBefore(instr, Instruction.Create(OpCodes.Ldsfld, buffEffects));
unproc.EmitWrapperCall(invokeEffects, instr);
}
开发者ID:Reuged,项目名称:Prism,代码行数:35,代码来源:NpcPatcher.cs
示例19: InjectField
public static FieldDefinition InjectField(this TypeDefinition targetType, FieldDefinition sourceField, ReferenceResolver resolver)
{
if (sourceField == null)
throw new ArgumentNullException("sourceField");
if (resolver == null)
throw new ArgumentNullException("resolver");
FieldDefinition newField = null;
if (Helper.TryGetField(targetType.Fields, sourceField, ref newField))
return newField;
TypeReference fieldType = resolver.ReferenceType(sourceField.FieldType, targetType);
newField = new FieldDefinition(sourceField.Name, sourceField.Attributes, fieldType)
{
InitialValue = sourceField.InitialValue,
DeclaringType = targetType,
};
targetType.Fields.Add(newField);
MetadataBuilderHelper.CopyCustomAttributes(sourceField, newField, resolver);
if (newField.HasDefault)
newField.Constant = sourceField.Constant;
return newField;
}
开发者ID:Cadla,项目名称:OBFSCTR,代码行数:27,代码来源:TypeDefinitionExtensions.cs
示例20: InjectSaveHook
static void InjectSaveHook()
{
var saveWorld = typeDef_WorldFile.GetMethod("saveWorld", MethodFlags.Public | MethodFlags.Static, typeSys.Boolean, typeSys.Boolean);
var swb = saveWorld.Body;
var swbproc = swb.GetILProcessor();
MethodDefinition invokeSaveWorld;
var saveWorldDel = context.CreateDelegate("Terraria.PrismInjections", "WorldFile_OnSaveWorldDel", typeSys.Void, out invokeSaveWorld, typeSys.Boolean);
var onSaveWorld = new FieldDefinition("P_OnSaveWorld", FieldAttributes.Public | FieldAttributes.Static, saveWorldDel);
typeDef_WorldFile.Fields.Add(onSaveWorld);
OpCode[] toFind =
{
OpCodes.Ldloc_S,
OpCodes.Call,
OpCodes.Leave_S
};
Instruction[] toInject =
{
Instruction.Create(OpCodes.Ldsfld, onSaveWorld),
Instruction.Create(OpCodes.Ldarg_0),
Instruction.Create(OpCodes.Callvirt, invokeSaveWorld)
};
var instr = swb.FindInstrSeqStart(toFind).Next.Next;
for (int i = 0; i < toInject.Length; i++)
swbproc.InsertBefore(instr, toInject[i]);
}
开发者ID:Reuged,项目名称:Prism,代码行数:32,代码来源:WorldFilePatcher.cs
注:本文中的Mono.Cecil.FieldDefinition类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论