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


C# TypeWrapper类代码示例

本文整理汇总了C#中TypeWrapper的典型用法代码示例。如果您正苦于以下问题:C# TypeWrapper类的具体用法?C# TypeWrapper怎么用?C# TypeWrapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: AddAutomagicSerialization

		internal static ConstructorInfo AddAutomagicSerialization(TypeWrapper wrapper)
		{
			ConstructorInfo serializationCtor = null;
			if (wrapper.GetClassLoader().NoAutomagicSerialization)
			{
				// do nothing
			}
			else if ((wrapper.Modifiers & IKVM.Attributes.Modifiers.Enum) != 0)
			{
				MarkSerializable(wrapper);
			}
			else if (wrapper.IsSubTypeOf(serializable) && IsSafeForAutomagicSerialization(wrapper))
			{
				if (wrapper.IsSubTypeOf(externalizable))
				{
					MethodWrapper ctor = wrapper.GetMethodWrapper("<init>", "()V", false);
					if (ctor != null && ctor.IsPublic)
					{
						MarkSerializable(wrapper);
						ctor.Link();
						serializationCtor = AddConstructor(wrapper.TypeAsBuilder, ctor, null, true);
						if (!wrapper.BaseTypeWrapper.IsSubTypeOf(serializable))
						{
							AddGetObjectData(wrapper);
						}
						if (wrapper.BaseTypeWrapper.GetMethodWrapper("readResolve", "()Ljava.lang.Object;", true) != null)
						{
							RemoveReadResolve(wrapper);
						}
					}
				}
				else if (wrapper.BaseTypeWrapper.IsSubTypeOf(serializable))
				{
					ConstructorInfo baseCtor = wrapper.GetBaseSerializationConstructor();
					if (baseCtor != null && (baseCtor.IsFamily || baseCtor.IsFamilyOrAssembly))
					{
						MarkSerializable(wrapper);
						serializationCtor = AddConstructor(wrapper.TypeAsBuilder, null, baseCtor, false);
						AddReadResolve(wrapper);
					}
				}
				else
				{
					MethodWrapper baseCtor = wrapper.BaseTypeWrapper.GetMethodWrapper("<init>", "()V", false);
					if (baseCtor != null && baseCtor.IsAccessibleFrom(wrapper.BaseTypeWrapper, wrapper, wrapper))
					{
						MarkSerializable(wrapper);
						AddGetObjectData(wrapper);
#if STATIC_COMPILER
						// because the base type can be a __WorkaroundBaseClass__, we may need to replace the constructor
						baseCtor = ((AotTypeWrapper)wrapper).ReplaceMethodWrapper(baseCtor);
#endif
						baseCtor.Link();
						serializationCtor = AddConstructor(wrapper.TypeAsBuilder, baseCtor, null, true);
						AddReadResolve(wrapper);
					}
				}
			}
			return serializationCtor;
		}
开发者ID:ikvm,项目名称:IKVM.NET-cvs-clone,代码行数:60,代码来源:Serialization.cs

示例2: Meta

 internal Meta(ScriptEngine engine, ModelInstance instance)
     : base(engine, engine.Object.InstancePrototype)
 {
     this.PopulateFunctions();
     this.instance = instance;
     this.typeWrapper = new TypeWrapper(engine, instance.Type);
 }
开发者ID:vc3,项目名称:ExoWeb,代码行数:7,代码来源:Meta.cs

示例3: Emit

 internal static bool Emit(DynamicTypeWrapper.FinishContext context, TypeWrapper wrapper, CodeEmitter ilgen, ClassFile classFile, int i, ClassFile.Method.Instruction[] code, InstructionFlags[] flags)
 {
     if (i >= 3
         && (flags[i - 0] & InstructionFlags.BranchTarget) == 0
         && (flags[i - 1] & InstructionFlags.BranchTarget) == 0
         && (flags[i - 2] & InstructionFlags.BranchTarget) == 0
         && (flags[i - 3] & InstructionFlags.BranchTarget) == 0
         && code[i - 1].NormalizedOpCode == NormalizedByteCode.__ldc
         && code[i - 2].NormalizedOpCode == NormalizedByteCode.__ldc
         && code[i - 3].NormalizedOpCode == NormalizedByteCode.__ldc)
     {
         // we now have a structural match, now we need to make sure that the argument values are what we expect
         TypeWrapper tclass = classFile.GetConstantPoolClassType(code[i - 3].Arg1);
         TypeWrapper vclass = classFile.GetConstantPoolClassType(code[i - 2].Arg1);
         string fieldName = classFile.GetConstantPoolConstantString(code[i - 1].Arg1);
         if (tclass == wrapper && !vclass.IsUnloadable && !vclass.IsPrimitive && !vclass.IsNonPrimitiveValueType)
         {
             FieldWrapper field = wrapper.GetFieldWrapper(fieldName, vclass.SigName);
             if (field != null && !field.IsStatic && field.IsVolatile && field.DeclaringType == wrapper && field.FieldTypeWrapper == vclass)
             {
                 // everything matches up, now call the actual emitter
                 DoEmit(context, wrapper, ilgen, field);
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:samskivert,项目名称:ikvm-monotouch,代码行数:28,代码来源:atomic.cs

示例4: GetFixtures

        private IList<Test> GetFixtures(Assembly assembly, IList names)
        {
            var fixtures = new List<Test>();
            var testTypes = GetCandidateFixtureTypes(assembly, names);
            int testcases = 0;
            foreach (Type testType in testTypes)
            {
                var typeInfo = new TypeWrapper(testType);

                try
                {
                    if (_unitySuiteBuilder.CanBuildFrom(typeInfo))
                    {
                        Test fixture = _unitySuiteBuilder.BuildFrom(typeInfo);
                        fixtures.Add(fixture);
                        testcases += fixture.TestCaseCount;
                    }
                }
                catch (Exception ex)
                {
                    Debug.LogException(ex);
                }
            }


            return fixtures;
        }
开发者ID:aws,项目名称:aws-sdk-net,代码行数:27,代码来源:UnityTestAssemblyBuilder.cs

示例5: IsEnabled

        internal static bool IsEnabled(TypeWrapper tw)
        {
            string className = tw.Name;

            // match class name
            for (OptionNode n = classes; n != null; n = n.next)
            {
                if (n.name == className)
                {
                    return n.enabled;
                }
            }

            // match package name
            if (packages != null)
            {
                int len = className.Length;
                while (len > 0 && className[--len] != '.') ;

                do
                {
                    for (OptionNode n = packages; n != null; n = n.next)
                    {
                        if (String.Compare(n.name, 0, className, 0, len, false, CultureInfo.InvariantCulture) == 0 && len == n.name.Length)
                        {
                            return n.enabled;
                        }
                    }
                    while (len > 0 && className[--len] != '.') ;
                } while (len > 0);
            }

            return tw.GetClassLoader() == ClassLoaderWrapper.GetBootstrapClassLoader() ? sysAsserts : userAsserts;
        }
开发者ID:somexotherxguy,项目名称:ikvm,代码行数:34,代码来源:Assertions.cs

示例6: WriteTypeName

        public void WriteTypeName(TypeWrapper type)
        {
            if (this._builder.Length > 0)
                this._builder.Append(" ");

            string typeName = type.GetDisplayName(false);
            if (typeName == "Void")
                typeName = "void";

            WriteValue(typeName);
        }
开发者ID:rajdotnet,项目名称:aws-sdk-net,代码行数:11,代码来源:SyntaxWriter.cs

示例7: HasJavaMethods

		private static bool HasJavaMethods(TypeWrapper tw)
		{
			foreach (MethodWrapper mw in tw.GetMethods())
			{
				if (!mw.IsHideFromReflection && mw.Name != StringConstants.CLINIT)
				{
					return true;
				}
			}
			return false;
		}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:11,代码来源:SerialVersionUID.cs

示例8: HasJavaMethods

		private static bool HasJavaMethods(TypeWrapper tw)
		{
			foreach (MethodWrapper mw in tw.GetMethods())
			{
				if (!mw.IsHideFromReflection && !mw.IsClassInitializer)
				{
					return true;
				}
			}
			return false;
		}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:11,代码来源:SerialVersionUID.cs

示例9: GenerateSyntax

        public string GenerateSyntax(TypeWrapper type)
        {
            var syntax = new SyntaxWriter(this._version);

            if (type.IsPublic)
                syntax.WriteToken("public");

            if (type.IsEnum)
            {
                syntax.WriteToken("enum");
                syntax.WriteTypeName(type);
            }
            else
            {
                if (type.IsSealed)
                    syntax.WriteToken("sealed");
                if (type.IsAbstract)
                    syntax.WriteToken("abstract");
                if (type.IsStatic)
                    syntax.WriteToken("static");

                if (type.IsClass)
                    syntax.WriteToken("class");
                else if (type.IsInterface)
                    syntax.WriteToken("interface");
                else if (type.IsValueType)
                    syntax.WriteToken("struct");

                syntax.WriteTypeName(type);

                var baseType = type.BaseType;
                if (baseType != null)
                {
                    syntax.WriteRaw(" :");
                    syntax.WriteTypeName(baseType);
                }

                var interfaces = type.GetInterfaces();
                if (interfaces.Count > 0)
                {
                    syntax.WriteNewLineWithTab();

                    syntax.BeginCommaDelimitedList();
                    foreach (var face in interfaces.OrderBy(x => x.Name))
                    {
                        syntax.WriteTypeName(face);
                    }
                    syntax.EndCommaDelimitedList();
                }
            }

            return syntax.CurrentSyntax;
        }
开发者ID:rajdotnet,项目名称:aws-sdk-net,代码行数:53,代码来源:CSharpSyntaxGenerator.cs

示例10: WriteModifiers

		private static void WriteModifiers(BigEndianStream bes, TypeWrapper tw)
		{
			Modifiers mods = tw.ReflectiveModifiers & (Modifiers.Public | Modifiers.Final | Modifiers.Interface | Modifiers.Abstract);
			if ((mods & Modifiers.Interface) != 0)
			{
				mods &= ~Modifiers.Abstract;
				if (HasJavaMethods(tw))
				{
					mods |= Modifiers.Abstract;
				}
			}
			bes.WriteUInt32((uint)mods);
		}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:13,代码来源:SerialVersionUID.cs

示例11: Test_ToStringShouldReturnTypeToString

 public void Test_ToStringShouldReturnTypeToString()
 {
     //---------------Set up test pack-------------------
     var type = MockRepository.GenerateMock<Type>();
     var expectedToString = GetRandomString();
     type.Stub(type1 => type1.ToString()).Return(expectedToString);
     TypeWrapper wrapper = new TypeWrapper(type);
     //---------------Assert Precondition----------------
     Assert.AreEqual(expectedToString, type.ToString());
     //---------------Execute Test ----------------------
     var toString = wrapper.ToString();
     //---------------Test Result -----------------------
     Assert.AreEqual(expectedToString, toString);
 }
开发者ID:Chillisoft,项目名称:habanero.smooth,代码行数:14,代码来源:TestTypeWrapper.cs

示例12: Compute

		internal static long Compute(TypeWrapper tw)
		{
			MemoryStream mem = new MemoryStream();
			BigEndianStream bes = new BigEndianStream(mem);
			WriteClassName(bes, tw);
			WriteModifiers(bes, tw);
			WriteInterfaces(bes, tw);
			WriteFields(bes, tw);
			WriteStaticInitializer(bes, tw);
			WriteConstructors(bes, tw);
			WriteMethods(bes, tw);
			byte[] buf = sha1.ComputeHash(mem.ToArray());
			long hash = 0;
			for (int i = 7; i >= 0; i--)
			{
				hash <<= 8;
				hash |= buf[i];
			}
			return hash;
		}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:20,代码来源:SerialVersionUID.cs

示例13: Create

		internal static void Create(CompilerClassLoader loader, string proxy)
		{
			string[] interfaces = proxy.Split(',');
			TypeWrapper[] wrappers = new TypeWrapper[interfaces.Length];
			for (int i = 0; i < interfaces.Length; i++)
			{
				try
				{
					wrappers[i] = loader.LoadClassByDottedNameFast(interfaces[i]);
				}
				catch (RetargetableJavaException)
				{
				}
				if (wrappers[i] == null)
				{
					StaticCompiler.IssueMessage(Message.UnableToCreateProxy, proxy, "unable to load interface " + interfaces[i]);
					return;
				}
			}
			Create(loader, proxy, wrappers);
		}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:21,代码来源:Proxy.cs

示例14: CreateGenerator

 public static IAsymmetricCipherKeyPairGenerator CreateGenerator(SecureRandom random, TypeWrapper kpGen,
                                                                 int keystrength)
 {
     var keypairGen = kpGen.Instance<IAsymmetricCipherKeyPairGenerator>();
     //var random = SecureRandomUtils.GetInstance(Model.RandomGenerator, Model.RandomGeneratorArgument);
     if (keypairGen is DsaKeyPairGenerator)
     {
         DsaParametersGenerator pGen = new DsaParametersGenerator();
         pGen.Init(keystrength, 80, random); //TODO:
         DsaParameters parameters = pGen.GenerateParameters();
         DsaKeyGenerationParameters genParam = new DsaKeyGenerationParameters(random, parameters);
         keypairGen.Init(genParam);
         return keypairGen;
     }
     if (keypairGen is ECKeyPairGenerator)
     {
         keypairGen.Init(new KeyGenerationParameters(random, keystrength));
         return keypairGen;
     }
     keypairGen.Init(new KeyGenerationParameters(random, keystrength));
     return keypairGen;
 }
开发者ID:naveedmurtuza,项目名称:crypto-tools,代码行数:22,代码来源:KeyPairUtils.cs

示例15: DoEmit

	private static void DoEmit(DynamicTypeWrapper.FinishContext context, TypeWrapper wrapper, CodeEmitter ilgen, FieldWrapper field)
	{
		ConstructorBuilder cb;
		bool exists;
		lock (map)
		{
			exists = map.TryGetValue(field, out cb);
		}
		if (!exists)
		{
			// note that we don't need to lock here, because we're running as part of FinishCore, which is already protected by a lock
			TypeWrapper arfuTypeWrapper = ClassLoaderWrapper.LoadClassCritical("ikvm.internal.IntrinsicAtomicReferenceFieldUpdater");
			TypeBuilder tb = wrapper.TypeAsBuilder.DefineNestedType("__<ARFU>_" + field.Name + field.Signature.Replace('.', '/'), TypeAttributes.NestedPrivate | TypeAttributes.Sealed, arfuTypeWrapper.TypeAsBaseType);
			EmitCompareAndSet("compareAndSet", tb, field.GetField());
			EmitGet(tb, field.GetField());
			EmitSet("set", tb, field.GetField());

			cb = tb.DefineConstructor(MethodAttributes.Assembly, CallingConventions.Standard, Type.EmptyTypes);
			lock (map)
			{
				map.Add(field, cb);
			}
			CodeEmitter ctorilgen = CodeEmitter.Create(cb);
			ctorilgen.Emit(OpCodes.Ldarg_0);
			MethodWrapper basector = arfuTypeWrapper.GetMethodWrapper("<init>", "()V", false);
			basector.Link();
			basector.EmitCall(ctorilgen);
			ctorilgen.Emit(OpCodes.Ret);
			context.RegisterPostFinishProc(delegate
			{
				arfuTypeWrapper.Finish();
				tb.CreateType();
			});
		}
		ilgen.LazyEmitPop();
		ilgen.LazyEmitPop();
		ilgen.LazyEmitPop();
		ilgen.Emit(OpCodes.Newobj, cb);
	}
开发者ID:ikvm,项目名称:IKVM.NET-cvs-clone,代码行数:39,代码来源:atomic.cs


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