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


C# ModuleDefinition.GetType方法代码示例

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


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

示例1: GenericForwardBaseType

        public void GenericForwardBaseType(ModuleDefinition module)
        {
            var tamchild = module.GetType ("TamChild");

            Assert.IsNotNull (tamchild);
            Assert.IsNotNull (tamchild.BaseType);

            var generic_instance = tamchild.BaseType as GenericInstanceType;

            Assert.IsNotNull (generic_instance);

            Assert.AreEqual (1, generic_instance.GenericArguments.Count);
            Assert.AreEqual (module.GetType ("Tamtam"), generic_instance.GenericArguments [0]);
        }
开发者ID:peterwald,项目名称:cecil,代码行数:14,代码来源:TypeTests.cs

示例2: TypeLayout

		public void TypeLayout (ModuleDefinition module)
		{
			var foo = module.GetType ("Foo");
			Assert.IsNotNull (foo);
			Assert.IsTrue (foo.IsValueType);

			Assert.IsTrue (foo.HasLayoutInfo);
			Assert.AreEqual (16, foo.ClassSize);

			var babar = module.GetType ("Babar");
			Assert.IsNotNull (babar);
			Assert.IsFalse (babar.IsValueType);
			Assert.IsFalse (babar.HasLayoutInfo);
		}
开发者ID:jeroldhaas,项目名称:ContinuousTests,代码行数:14,代码来源:TypeTests.cs

示例3: ArrayFields

        public void ArrayFields(ModuleDefinition module)
        {
            var types = module.GetType ("Types");
            Assert.IsNotNull (types);

            var rank_two = types.GetField ("rank_two");

            var array = rank_two.FieldType as ArrayType;
            Assert.IsNotNull (array);

            Assert.AreEqual (2, array.Rank);
            Assert.IsFalse (array.Dimensions [0].IsSized);
            Assert.IsFalse (array.Dimensions [1].IsSized);

            var rank_two_low_bound_zero = types.GetField ("rank_two_low_bound_zero");

            array = rank_two_low_bound_zero.FieldType as ArrayType;
            Assert.IsNotNull (array);

            Assert.AreEqual (2, array.Rank);
            Assert.IsTrue (array.Dimensions [0].IsSized);
            Assert.AreEqual (0, array.Dimensions [0].LowerBound);
            Assert.AreEqual (null, array.Dimensions [0].UpperBound);
            Assert.IsTrue (array.Dimensions [1].IsSized);
            Assert.AreEqual (0, array.Dimensions [1].LowerBound);
            Assert.AreEqual (null, array.Dimensions [1].UpperBound);
        }
开发者ID:peterwald,项目名称:cecil,代码行数:27,代码来源:FieldTests.cs

示例4: InjectInto

 public override void InjectInto(ModuleDefinition gamedef, ModuleDefinition moddef)
 {
     // This injects a call to the mod's static AnimalDamaged method for the AnimalDamagedScriptEvent
     TypeDefinition modtype = moddef.GetType("UnturnedFrenetic.UnturnedFreneticMod");
     MethodReference eventmethod = gamedef.ImportReference(GetMethod(modtype, "AnimalDamaged", 4));
     TypeDefinition animaltype = gamedef.GetType("SDG.Unturned.Animal");
     MethodDefinition damagemethod = GetMethod(animaltype, "askDamage", 4);
     MethodBody damagebody = damagemethod.Body;
     InjectInstructions(damagebody, 0, new Instruction[]
     {
             // Load "this" onto the stack.
             Instruction.Create(OpCodes.Ldarg_0),
             // Load "amount" onto the stack.
             Instruction.Create(OpCodes.Ldarga_S, damagemethod.Parameters[0]),
             // Load "newRagdoll" onto the stack.
             Instruction.Create(OpCodes.Ldarga_S, damagemethod.Parameters[1]),
             // Load "xp" onto the stack
             Instruction.Create(OpCodes.Ldarga_S, damagemethod.Parameters[3]),
             // Call the AnimalDamaged method with the above parameters and return a bool.
             Instruction.Create(OpCodes.Call, eventmethod),
             // If the return is false, jump ahead to the original 0th instruction.
             Instruction.Create(OpCodes.Brfalse, damagebody.Instructions[0]),
             // Otherwise, return now.
             Instruction.Create(OpCodes.Ret)
     });
 }
开发者ID:FreneticXYZ,项目名称:UnturnedFrenetic,代码行数:26,代码来源:AnimalDamagedEventInjectable.cs

示例5: DirectNestedType

		public void DirectNestedType (ModuleDefinition module)
		{
			var bingo = module.GetType ("Bingo");
			var get_fuel = bingo.GetMethod ("GetFuel");

			Assert.AreEqual ("Bingo/Fuel", get_fuel.ReturnType.FullName);
		}
开发者ID:0xb1dd1e,项目名称:cecil,代码行数:7,代码来源:NestedTypesTests.cs

示例6: ConstantCoalescing

        public void ConstantCoalescing(ModuleDefinition module)
        {
            var fields = module.GetType ("Fields");

            var field = fields.GetField ("int32_int16");
            Assert.AreEqual ("System.Int32", field.FieldType.FullName);
            Assert.IsTrue (field.HasConstant);
            Assert.IsInstanceOfType (typeof (short), field.Constant);
            Assert.AreEqual ((short) 1, field.Constant);

            field = fields.GetField ("int16_int32");
            Assert.AreEqual ("System.Int16", field.FieldType.FullName);
            Assert.IsTrue (field.HasConstant);
            Assert.IsInstanceOfType (typeof (int), field.Constant);
            Assert.AreEqual (1, field.Constant);

            field = fields.GetField ("char_int16");
            Assert.AreEqual ("System.Char", field.FieldType.FullName);
            Assert.IsTrue (field.HasConstant);
            Assert.IsInstanceOfType (typeof (short), field.Constant);
            Assert.AreEqual ((short) 1, field.Constant);

            field = fields.GetField ("int16_char");
            Assert.AreEqual ("System.Int16", field.FieldType.FullName);
            Assert.IsTrue (field.HasConstant);
            Assert.IsInstanceOfType (typeof (char), field.Constant);
            Assert.AreEqual ('s', field.Constant);
        }
开发者ID:jm3105,项目名称:cecil,代码行数:28,代码来源:FieldTests.cs

示例7: FieldLayout

		public void FieldLayout (ModuleDefinition module)
		{
			var foo = module.GetType ("Foo");
			Assert.IsNotNull (foo);

			Assert.IsTrue (foo.HasFields);

			var fields = foo.Fields;

			var field = fields [0];

			Assert.AreEqual ("Bar", field.Name);
			Assert.IsTrue (field.HasLayoutInfo);
			Assert.AreEqual (0, field.Offset);

			field = fields [1];

			Assert.AreEqual ("Baz", field.Name);
			Assert.IsTrue (field.HasLayoutInfo);
			Assert.AreEqual (2, field.Offset);

			field = fields [2];

			Assert.AreEqual ("Gazonk", field.Name);
			Assert.IsTrue (field.HasLayoutInfo);
			Assert.AreEqual (4, field.Offset);
		}
开发者ID:95ulisse,项目名称:ILEdit,代码行数:27,代码来源:FieldTests.cs

示例8: OtherMethod

		public void OtherMethod (ModuleDefinition module)
		{
			var type = module.GetType ("Others");

			Assert.IsTrue (type.HasEvents);

			var events = type.Events;

			Assert.AreEqual (1, events.Count);

			var @event = events [0];

			Assert.IsNotNull (@event);
			Assert.AreEqual ("Handler", @event.Name);
			Assert.IsNotNull (@event.EventType);
			Assert.AreEqual ("System.EventHandler", @event.EventType.FullName);

			Assert.IsTrue (@event.HasOtherMethods);

			Assert.AreEqual (2, @event.OtherMethods.Count);

			var other = @event.OtherMethods [0];
			Assert.AreEqual ("dang_Handler", other.Name);

			other = @event.OtherMethods [1];
			Assert.AreEqual ("fang_Handler", other.Name);
		}
开发者ID:0xb1dd1e,项目名称:cecil,代码行数:27,代码来源:EventTests.cs

示例9: ReturnGenericInstance

		public void ReturnGenericInstance (ModuleDefinition module)
		{
			var bar = module.GetType ("Bar`1");

			var self = bar.GetMethod ("Self");
			Assert.IsNotNull (self);

			var bar_t = self.ReturnType;

			Assert.IsTrue (bar_t.IsGenericInstance);

			var bar_t_instance = (GenericInstanceType) bar_t;

			Assert.AreEqual (bar.GenericParameters [0], bar_t_instance.GenericArguments [0]);

			var self_str = bar.GetMethod ("SelfString");
			Assert.IsNotNull (self_str);

			var bar_str = self_str.ReturnType;
			Assert.IsTrue (bar_str.IsGenericInstance);

			var bar_str_instance = (GenericInstanceType) bar_str;

			Assert.AreEqual ("System.String", bar_str_instance.GenericArguments [0].FullName);
		}
开发者ID:0xb1dd1e,项目名称:cecil,代码行数:25,代码来源:MethodTests.cs

示例10: AssemblyUpdater

 public AssemblyUpdater(string assemblyFile)
 {
     _assemblyFile = assemblyFile;
     _module = ModuleDefinition.ReadModule(assemblyFile);
     _type = _module.GetType("TheIndex", "EntryPoint");
     _resolveUpdater = new AssemblyResolveUpdater(_module);
 }
开发者ID:flq,项目名称:Tmp.ExecIndex,代码行数:7,代码来源:AssemblyUpdater.cs

示例11: ArrayMarshaler

		public void ArrayMarshaler (ModuleDefinition module)
		{
			var bar = module.GetType ("Bar");
			var pan = bar.GetMethod ("PanPan");

			var parameter = pan.Parameters [1];

			Assert.IsTrue (parameter.HasMarshalInfo);

			var info = (ArrayMarshalInfo) parameter.MarshalInfo;

			Assert.AreEqual (NativeType.I8, info.ElementType);
			Assert.AreEqual (66, info.Size);
			Assert.AreEqual (2, info.SizeParameterIndex);

			parameter = pan.Parameters [3];

			Assert.IsTrue (parameter.HasMarshalInfo);

			info = (ArrayMarshalInfo) parameter.MarshalInfo;

			Assert.AreEqual (NativeType.I2, info.ElementType);
			Assert.AreEqual (-1, info.Size);
			Assert.AreEqual (-1, info.SizeParameterIndex);
		}
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:25,代码来源:ParameterTests.cs

示例12: InjectInto

 public override void InjectInto(ModuleDefinition gamedef, ModuleDefinition moddef)
 {
     // Expose some things in AnimalManager for easier use.
     TypeDefinition type = gamedef.GetType("SDG.Unturned.AnimalManager");
     MakePublic(GetMethod(type, "addAnimal", 4));
     MakePublic(GetField(type, "manager"));
 }
开发者ID:FreneticXYZ,项目名称:UnturnedFrenetic,代码行数:7,代码来源:ExposeAnimalManagerMethodsInjectable.cs

示例13: AssemblyResolveUpdater

 public AssemblyResolveUpdater(ModuleDefinition module)
 {
     _module = module;
     var type = _module.GetType("TheIndex", "Resolver");
     _initMethod = type.Methods.Single(m => m.Name == "DictionaryInitialization");
     _addResolveMethod = type.Methods.Single(m => m.Name == "Add");
     _proc = _initMethod.Body.GetILProcessor();
 }
开发者ID:flq,项目名称:Tmp.ExecIndex,代码行数:8,代码来源:AssemblyResolveUpdater.cs

示例14: FilterMaxStack

        public void FilterMaxStack(ModuleDefinition module)
        {
            var type = module.GetType ("Foo");
            var method = type.GetMethod ("TestFilter");

            Assert.IsNotNull (method);
            Assert.AreEqual (2, method.Body.MaxStackSize);
        }
开发者ID:pombredanne,项目名称:cecil,代码行数:8,代码来源:MethodBodyTests.cs

示例15: BoxedDefaultArgumentValue

        public void BoxedDefaultArgumentValue(ModuleDefinition module)
        {
            var foo = module.GetType ("Foo");
            var bar = foo.GetMethod ("Bar");
            var baz = bar.Parameters [0];

            Assert.IsTrue (baz.HasConstant);
            Assert.AreEqual (-1, baz.Constant);
        }
开发者ID:peterwald,项目名称:cecil,代码行数:9,代码来源:ParameterTests.cs


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