本文整理汇总了C#中INamedTypeSymbol.IsPrimitive方法的典型用法代码示例。如果您正苦于以下问题:C# INamedTypeSymbol.IsPrimitive方法的具体用法?C# INamedTypeSymbol.IsPrimitive怎么用?C# INamedTypeSymbol.IsPrimitive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类INamedTypeSymbol
的用法示例。
在下文中一共展示了INamedTypeSymbol.IsPrimitive方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StoreClassCreateType
public JsExpressionStatement StoreClassCreateType(INamedTypeSymbol type)
{
var explicitName = type.GetAttributeValue<string>(Context.Instance.JsAttributeType, "Name");
var fullTypeName = type.GetFullName();
var baseType = type.BaseType != null ? Type(type.BaseType, true) : Js.Null();
var body = new JsBlockStatement();
body.Assign(Js.This().Member(SpecialNames.TypeField),
CreateObject(Context.Instance.TypeConstructor, Js.Primitive(type.Name), CreateAttributes(type)));
TypeFlags typeFlags = 0;
if (type.ContainingType == null)
{
switch (type.DeclaredAccessibility)
{
case Accessibility.Public:
typeFlags |= TypeFlags.Public;
break;
case Accessibility.Internal:
typeFlags |= TypeFlags.Internal;
break;
default:
throw new Exception();
}
}
else
{
switch (type.DeclaredAccessibility)
{
case Accessibility.Public:
typeFlags |= TypeFlags.Public;
break;
case Accessibility.Internal:
typeFlags |= TypeFlags.Internal;
break;
case Accessibility.Private:
typeFlags |= TypeFlags.Private;
break;
case Accessibility.Protected:
typeFlags |= TypeFlags.Protected;
break;
case Accessibility.ProtectedOrInternal:
typeFlags |= TypeFlags.Private | TypeFlags.Internal;
break;
default:
throw new Exception();
}
}
if (type.TypeKind == TypeKind.Interface)
{
typeFlags |= TypeFlags.Interface;
}
else if (type.TypeKind == TypeKind.Class)
{
typeFlags |= TypeFlags.Class;
}
else if (type.TypeKind == TypeKind.Enum)
{
typeFlags |= TypeFlags.Enum;
}
if (type.IsAbstract)
{
typeFlags |= TypeFlags.Abstract;
}
else if (type.IsSealed)
{
typeFlags |= TypeFlags.Sealed;
}
if (type.IsValueType)
{
typeFlags |= TypeFlags.ValueType;
}
if (type.IsPrimitive())
{
typeFlags |= TypeFlags.Primitive;
}
if (type.IsGenericType || type.IsAnonymousTypeWithTypeParameters())
{
typeFlags |= TypeFlags.GenericType;
}
if (type.TypeParameters.Any())
{
typeFlags |= TypeFlags.GenericTypeDefenition;
}
if (type.TypeKind == TypeKind.TypeParameter)
{
typeFlags |= TypeFlags.GenericParameter;
}
var arguments = new List<JsExpression>
{
Js.Primitive(explicitName ?? fullTypeName), // Param1: fullTypeName
Js.Primitive((int)typeFlags),
Type(type, true),
baseType,
CreateInterfaceReferences(type),
MakeArray(Js.Array(type.TypeParameters.Select(x => Js.Reference(x.Name)).Concat(type.GetAnonymousTypeParameters().Select(x => Js.Reference(x.Item2))).ToArray()), Context.Instance.TypeArray)
};
if (!Context.Instance.Compilation.Assembly.IsReflectionMinimized())
{
//.........这里部分代码省略.........