本文整理汇总了C#中Type类的典型用法代码示例。如果您正苦于以下问题:C# Type类的具体用法?C# Type怎么用?C# Type使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Type类属于命名空间,在下文中一共展示了Type类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: CanUpdateReadOnlyProperty
private static bool CanUpdateReadOnlyProperty(Type propertyType)
{
// Value types have copy-by-value semantics, which prevents us from updating
// properties that are marked readonly.
if (propertyType.IsValueType)
{
return false;
}
// Arrays are strange beasts since their contents are mutable but their sizes aren't.
// Therefore we shouldn't even try to update these. Further reading:
// http://blogs.msdn.com/ericlippert/archive/2008/09/22/arrays-considered-somewhat-harmful.aspx
if (propertyType.IsArray)
{
return false;
}
// Special-case known immutable reference types
if (propertyType == typeof(string))
{
return false;
}
return true;
}
开发者ID:marojeri,项目名称:aspnetwebstack,代码行数:25,代码来源:MutableObjectModelBinder.cs
示例17: CanConvertTo
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
if (destinationType == typeof(InstanceDescriptor))
return true;
return base.CanConvertTo(context, destinationType);
}
开发者ID:NelsonSantos,项目名称:fyiReporting-Android,代码行数:7,代码来源:ColorConverter.cs
示例18: ProcessDescriptionForMsmqIntegration
static Type[] ProcessDescriptionForMsmqIntegration(ServiceEndpoint endpoint, Type[] existingSerializationTypes)
{
List<Type> targetSerializationTypes;
if (existingSerializationTypes == null)
{
targetSerializationTypes = new List<Type>();
}
else
{
targetSerializationTypes = new List<Type>(existingSerializationTypes);
}
foreach (OperationDescription operationDesc in endpoint.Contract.Operations)
{
foreach (Type type in operationDesc.KnownTypes)
{
// add contract known types to targetSerializationTypes
if (!targetSerializationTypes.Contains(type))
{
targetSerializationTypes.Add(type);
}
}
// Default document style doesn't work for Integration Transport
// because messages that SFx layer deals with are not wrapped
// We need to change style for each operation
foreach (MessageDescription messageDescription in operationDesc.Messages)
{
messageDescription.Body.WrapperName = messageDescription.Body.WrapperNamespace = null;
}
}
return targetSerializationTypes.ToArray();
}
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:32,代码来源:DispatcherBuilder.cs
示例19: GeneratePageResult
private static object GeneratePageResult(HelpPageSampleGenerator sampleGenerator, Type type)
{
if (type.IsGenericType)
{
Type openGenericType = type.GetGenericTypeDefinition();
if (openGenericType == typeof(PageResult<>))
{
// Get the T in PageResult<T>
Type[] typeParameters = type.GetGenericArguments();
Debug.Assert(typeParameters.Length == 1);
// Create an enumeration to pass as the first parameter to the PageResult<T> constuctor
Type itemsType = typeof(List<>).MakeGenericType(typeParameters);
object items = sampleGenerator.GetSampleObject(itemsType);
// Fill in the other information needed to invoke the PageResult<T> constuctor
Type[] parameterTypes = new Type[] { itemsType, typeof(Uri), typeof(long?), };
object[] parameters = new object[] { items, null, (long)ObjectGenerator.DefaultCollectionSize, };
// Call PageResult(IEnumerable<T> items, Uri nextPageLink, long? count) constructor
ConstructorInfo constructor = type.GetConstructor(parameterTypes);
return constructor.Invoke(parameters);
}
}
return null;
}
开发者ID:egaia,项目名称:ASP.NET-Tournament.Manager,代码行数:27,代码来源:HelpPageConfig.cs
示例20: WriteObject
/// <inheritdoc />
public override void WriteObject(object graph, Type type, ODataMessageWriter messageWriter,
ODataSerializerContext writeContext)
{
if (messageWriter == null)
{
throw Error.ArgumentNull("messageWriter");
}
if (writeContext == null)
{
throw Error.ArgumentNull("writeContext");
}
IEdmNavigationSource navigationSource = writeContext.NavigationSource;
if (navigationSource == null)
{
throw new SerializationException(SRResources.NavigationSourceMissingDuringSerialization);
}
var path = writeContext.Path;
if (path == null)
{
throw new SerializationException(SRResources.ODataPathMissing);
}
ODataWriter writer = messageWriter.CreateODataEntryWriter(navigationSource, path.EdmType as IEdmEntityType);
WriteObjectInline(graph, navigationSource.EntityType().ToEdmTypeReference(isNullable: false), writer, writeContext);
}
开发者ID:BarclayII,项目名称:WebApi,代码行数:29,代码来源:ODataEntityTypeSerializer.cs
注:本文中的Type类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论