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


C# Type类代码示例

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


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

示例1: ToCode

 internal static InternalPrimitiveTypeE ToCode(Type type) =>
         type == null ? ToPrimitiveTypeEnum(TypeCode.Empty) :
         type.GetTypeInfo().IsPrimitive ? ToPrimitiveTypeEnum(type.GetTypeCode()) :
         ReferenceEquals(type, s_typeofDateTime) ? InternalPrimitiveTypeE.DateTime :
         ReferenceEquals(type, s_typeofTimeSpan) ? InternalPrimitiveTypeE.TimeSpan :
         ReferenceEquals(type, s_typeofDecimal) ? InternalPrimitiveTypeE.Decimal :
         InternalPrimitiveTypeE.Invalid;
开发者ID:Corillian,项目名称:corefx,代码行数:7,代码来源:Converter.cs

示例2: GetSmartPartInfo

    /// <summary>
    /// Gets the smart part info.
    /// </summary>
    /// <param name="smartPartInfoType">Type of the smart part info.</param>
    /// <returns></returns>
    public override ISmartPartInfo GetSmartPartInfo(Type smartPartInfoType)
    {
        ToolsSmartPartInfo tinfo = new ToolsSmartPartInfo();
        if (BindingSource != null)
        {
            if (BindingSource.Current != null)
            {
                tinfo.Title = _stage.Id != null
                                  ? (_mode == "Complete"
                                         ? GetLocalResourceObject("DialogTitleComplete").ToString()
                                         : GetLocalResourceObject("DialogTitleEdit").ToString())
                                  : GetLocalResourceObject("DialogTitleAdd").ToString();
            }
        }

        foreach (Control c in Form_LTools.Controls)
        {
            tinfo.LeftTools.Add(c);
        }
        foreach (Control c in Form_CTools.Controls)
        {
            tinfo.CenterTools.Add(c);
        }
        foreach (Control c in Form_RTools.Controls)
        {
            tinfo.RightTools.Add(c);
        }
        return tinfo;
    }
开发者ID:ssommerfeldt,项目名称:TAC_EAB,代码行数:34,代码来源:AddEditStage.ascx.cs

示例3: VarEnumSelector

        internal VarEnumSelector(Type[] explicitArgTypes) {
            _variantBuilders = new VariantBuilder[explicitArgTypes.Length];

            for (int i = 0; i < explicitArgTypes.Length; i++) {
                _variantBuilders[i] = GetVariantBuilder(explicitArgTypes[i]);
            }
        }
开发者ID:tnachen,项目名称:ironruby,代码行数:7,代码来源:VarEnumSelector.cs

示例4: ConvertTo

            public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) {
                if (destinationType == typeof(string)) {
                    return "EmbeddedMailObject";
                }

                return base.ConvertTo(context, culture, value, destinationType);
            }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:7,代码来源:EmbeddedMailObject.cs

示例5: CoordinatorScratchpad

 internal CoordinatorScratchpad(Type elementType)
 {
     _elementType = elementType;
     _nestedCoordinatorScratchpads = new List<CoordinatorScratchpad>();
     _expressionWithErrorHandlingMap = new Dictionary<Expression, Expression>();
     _inlineDelegates = new HashSet<LambdaExpression>();
 }
开发者ID:christiandpena,项目名称:entityframework,代码行数:7,代码来源:coordinatorscratchpad.cs

示例6: TryGetType

 /// <summary>
 ///     Given a clrType attempt to return the corresponding target type from
 ///     the worksapce
 /// </summary>
 /// <param name="clrType"> The clr type to resolve </param>
 /// <param name="outTypeUsage"> an out param for the typeUsage to be resolved to </param>
 /// <returns> true if a TypeUsage can be found for the target type </returns>
 internal bool TryGetType(Type clrType, out TypeUsage outTypeUsage)
 {
     return TryGetTypeByName(
         clrType.FullNameWithNesting(),
         false /*ignoreCase*/,
         out outTypeUsage);
 }
开发者ID:christiandpena,项目名称:entityframework,代码行数:14,代码来源:ClrPerspective.cs

示例7: CodeTypeReference

		public CodeTypeReference (Type baseType)
		{
#if NET_2_0
			if (baseType == null) {
				throw new ArgumentNullException ("baseType");
			}

			if (baseType.IsGenericParameter) {
				this.baseType = baseType.Name;
				this.referenceOptions = CodeTypeReferenceOptions.GenericTypeParameter;
			}
			else if (baseType.IsGenericTypeDefinition)
				this.baseType = baseType.FullName;
			else if (baseType.IsGenericType) {
				this.baseType = baseType.GetGenericTypeDefinition ().FullName;
				foreach (Type arg in baseType.GetGenericArguments ()) {
					if (arg.IsGenericParameter)
						TypeArguments.Add (new CodeTypeReference (new CodeTypeParameter (arg.Name)));
					else
						TypeArguments.Add (new CodeTypeReference (arg));
				}
			}
			else
#endif
			if (baseType.IsArray) {
				this.arrayRank = baseType.GetArrayRank ();
				this.arrayElementType = new CodeTypeReference (baseType.GetElementType ());
				this.baseType = arrayElementType.BaseType;
			} else {
				Parse (baseType.FullName);
			}
			this.isInterface = baseType.IsInterface;
		}
开发者ID:runefs,项目名称:Marvin,代码行数:33,代码来源:CodeTypeReference.cs

示例8: ComMethodInformation

 internal ComMethodInformation(bool hasvarargs, bool hasoptional, ParameterInformation[] arguments, Type returnType, int dispId, COM.INVOKEKIND invokekind)
     : base(hasvarargs, hasoptional, arguments)
 {
     this.ReturnType = returnType;
     this.DispId = dispId;
     this.InvokeKind = invokekind;
 }
开发者ID:40a,项目名称:PowerShell,代码行数:7,代码来源:ComMethod.cs

示例9: GetNullableType

 internal static Type GetNullableType(Type type) {
     Debug.Assert(type != null, "type cannot be null");
     if (type.IsValueType && !IsNullableType(type)) {
         return typeof(Nullable<>).MakeGenericType(type);
     }
     return type;
 }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:7,代码来源:TypeUtils.cs

示例10: Element

		// snippet moved from FileIOPermission (nickd) to be reused in all derived classes
		internal static SecurityElement Element (Type type, int version) 
		{
			SecurityElement se = new SecurityElement ("IPermission");
			se.AddAttribute ("class", type.FullName + ", " + type.Assembly.ToString ().Replace ('\"', '\''));
			se.AddAttribute ("version", version.ToString ());
			return se;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:8,代码来源:PermissionHelper.cs

示例11: GetSerializableFields

        private static FieldInfo[] GetSerializableFields(Type type)
        {
            if (type.GetTypeInfo().IsInterface)
            {
                return Array.Empty<FieldInfo>();
            }

            if (!type.GetTypeInfo().IsSerializable)
            {
                throw new SerializationException(SR.Format(SR.Serialization_NonSerType, type.GetTypeInfo().FullName, type.GetTypeInfo().Assembly.FullName));
            }

            var results = new List<FieldInfo>();
            for (Type t = type; t != typeof(object); t = t.GetTypeInfo().BaseType)
            {
                foreach (FieldInfo field in t.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly))
                {
                    if ((field.Attributes & FieldAttributes.NotSerialized) != FieldAttributes.NotSerialized)
                    {
                        results.Add(field);
                    }
                }
            }
            return results.ToArray();
        }
开发者ID:geoffkizer,项目名称:corefx,代码行数:25,代码来源:FormatterServices.cs

示例12: Main

    static void Main(string[] args)
    {
        AssemblyName an = new AssemblyName();
        an.Name = "HelloWorld";
        AssemblyBuilder ab = Thread.GetDomain().DefineDynamicAssembly(an, AssemblyBuilderAccess.RunAndSave);
        ModuleBuilder module = ab.DefineDynamicModule("b.dll");
        TypeBuilder tb = module.DefineType("type", TypeAttributes.Public | TypeAttributes.Class);
        MethodBuilder mb = tb.DefineMethod("test",
					   MethodAttributes.HideBySig | MethodAttributes.Static |
					   MethodAttributes.Public, typeof(void), null);
        ILGenerator ig = mb.GetILGenerator();

	//
	// This is the actual test:
	//   Generate a method signature that contains modopts and modreqs
	//   and call that.  It has no name or anything, not sure how this
	//   is actually used, but we at least generate the stuff
	//
	SignatureHelper sh = SignatureHelper.GetMethodSigHelper (module, CallingConventions.HasThis, typeof(int));
	sh.AddArgument (typeof (bool));
	Type [] req = new Type [] { typeof (System.Runtime.CompilerServices.IsBoxed) };
	sh.AddArgument (typeof (string), req, null);
	Type [] opt = new Type [] { typeof (System.Runtime.CompilerServices.IsConst) };
	sh.AddArgument (typeof (byte), null, opt);
	sh.AddArgument (typeof (int), null, opt);
	sh.AddArgument (typeof (long), null, opt);
	ig.Emit (OpCodes.Call, sh);

        ig.Emit(OpCodes.Ret);

        tb.CreateType();

	ab.Save ("b.dll");
     }
开发者ID:Zman0169,项目名称:mono,代码行数:34,代码来源:sighelpermod.cs

示例13: IsValid

        private static bool IsValid(Type type, TypeInfo typeInfo)
        {
            if (!ReferenceEquals(null, type))
            {
                if (typeInfo.IsArray)
                {
                    type = type.GetElementType();
                }

                if (typeInfo.IsAnonymousType || type.IsAnonymousType())
                {
                    var properties = type.GetProperties().Select(x => x.Name).ToList();
                    var propertyNames = typeInfo.Properties.Select(x => x.Name).ToList();

                    var match =
                        type.IsAnonymousType() &&
                        typeInfo.IsAnonymousType &&
                        properties.Count == propertyNames.Count &&
                        propertyNames.All(x => properties.Contains(x));

                    if (!match)
                    {
                        return false;
                    }
                }

                return true;
            }

            return false;
        }
开发者ID:6bee,项目名称:aqua-core,代码行数:31,代码来源:TypeResolver.cs

示例14: CreateShelfService

 public CreateShelfService(string serviceName, ShelfType shelfType, Type bootstrapperType, AssemblyName[] assemblyNames)
 {
     ServiceName = serviceName;
     ShelfType = shelfType;
     BootstrapperType = bootstrapperType;
     AssemblyNames = assemblyNames;
 }
开发者ID:haf,项目名称:Topshelf,代码行数:7,代码来源:CreateShelfService.cs

示例15: CanConvertFrom

        public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
        {
            if (sourceType == typeof(string))
                return true;

            return base.CanConvertFrom(context, sourceType);
        }
开发者ID:NelsonSantos,项目名称:fyiReporting-Android,代码行数:7,代码来源:ColorConverter.cs


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