本文整理汇总了C#中INamedTypeSymbol.IsBuiltIn方法的典型用法代码示例。如果您正苦于以下问题:C# INamedTypeSymbol.IsBuiltIn方法的具体用法?C# INamedTypeSymbol.IsBuiltIn怎么用?C# INamedTypeSymbol.IsBuiltIn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类INamedTypeSymbol
的用法示例。
在下文中一共展示了INamedTypeSymbol.IsBuiltIn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateTypeFunction
public JsBlockStatement CreateTypeFunction(INamedTypeSymbol classType, out JsBlockStatement typeInitializer, out JsBlockStatement staticInitializer)
{
var isBuiltIn = classType.IsBuiltIn();
var extraBuiltInExports = classType.GetExtraBuiltInExports();
var explicitBaseType = classType.GetAttributeValue<ITypeSymbol>(Context.Instance.JsAttributeType, "BaseType");
var baseType =
explicitBaseType != null ? Type(explicitBaseType) :
Equals(classType, Context.Instance.ObjectType) ? Js.Reference("Object") :
classType.BaseType == null ? Type(Context.Instance.ObjectType) :
Js.Reference(classType.BaseType.GetTypeName());
// classType.BaseType.HasGenericParameters() ? Js.Reference(classType.BaseType.GetTypeName()) :
// Type(classType.BaseType);
var block = new JsBlockStatement();
JsExpression outerClassType = Js.Reference(classType.GetTypeName());
// Generate type initializer
typeInitializer = new JsBlockStatement();
// typeInitializer.Add(StoreInType(SpecialNames.GetAssembly, Js.Reference(classType.ContainingAssembly.GetAssemblyMethodName())));
// typeInitializer.Add(StoreInPrototype(SpecialNames.TypeField, Js.Reference(SpecialNames.TypeInitializerTypeFunction)));
// typeInitializer.Add(StoreInType(SpecialNames.BaseType, baseType));
if (classType.IsExported() && !classType.IsBuiltIn())
{
// typeInitializer.Add(StoreInPrototype(SpecialNames.TypeName, Js.Reference(SpecialNames.TypeInitializerTypeFunction).Member(SpecialNames.TypeName)));
}
else
{
typeInitializer.Add(StoreInPrototype(SpecialNames.TypeName, Js.Primitive(classType.GetFullName())));
typeInitializer.Add(StoreInType(SpecialNames.TypeName, GetFromPrototype(SpecialNames.TypeName)));
}
if (classType.IsBuiltIn())
typeInitializer.Add(StoreClassGetType());
typeInitializer.Add(StoreClassCreateType(classType));
var containingType = classType.ContainingType;
var typeInitializerFunction = Js.Function(new[] { Js.Parameter(SpecialNames.TypeInitializerTypeFunction), Js.Parameter(SpecialNames.TypeInitializerPrototype) }.Concat(classType.TypeParameters.Select(x => Js.Parameter(x.Name))).Concat(classType.GetAnonymousTypeParameters().Select(x => Js.Parameter(x.Item2))).ToArray()).Body(typeInitializer);
if (!isBuiltIn)
{
var displayName = classType.GetFullName();
var args = new[]
{
Js.Reference(SpecialNames.Assembly),
containingType == null ? (JsExpression)Js.Null() : Js.Reference(SpecialNames.TypeInitializerTypeFunction),
Js.Primitive(displayName),
Js.Primitive(classType.HasOrIsEnclosedInGenericParameters()),
Js.Array(
classType.TypeParameters.Select(x =>
(JsExpression)Js.Reference(SpecialNames.DefineTypeParameter).Invoke(
Js.Reference(SpecialNames.Assembly),
Js.Primitive(x.Name),
Type(x.BaseType ?? Context.Instance.ObjectType, true)
)
)
.Concat(classType.GetAnonymousTypeParameters().Select(x =>
Js.Reference(SpecialNames.DefineTypeParameter).Invoke(
Js.Reference(SpecialNames.Assembly),
Js.Primitive(x.Item2),
Type(x.Item1 ?? Context.Instance.ObjectType, true)
)
))
.ToArray()
),
baseType,
typeInitializerFunction
};
if (classType.ContainingType == null && !classType.IsAnonymousType)
{
block.Assign(Js.Reference(classType.ContainingNamespace.GetFullName()).Member(classType.GetShortTypeName()),
Js.Reference(SpecialNames.Define).Invoke(args));
}
else if (classType.ContainingType != null)
{
outerClassType = Js.Reference(SpecialNames.TypeInitializerTypeFunction).Member(classType.GetShortTypeName());
block.Assign(outerClassType, Js.Reference(SpecialNames.Define).Invoke(args));
}
else
{
block.Assign(Js.Reference(classType.GetTypeName()), Js.Reference(SpecialNames.Define).Invoke(args));
}
}
if (classType.IsBuiltIn())
block.Assign(outerClassType.Member(SpecialNames.TypeInitializer), Js.Reference(SpecialNames.DefineTypeFunction).Invoke(outerClassType, typeInitializerFunction));
Func<JsExpression, JsExpression> primaryTypeInitializerCall = expression => expression
.Member("call")
.Invoke(
new[]
{
containingType == null ? (JsExpression)Js.Null() : Js.Reference(SpecialNames.TypeInitializerTypeFunction),
outerClassType,
outerClassType.Member("prototype")
}
.Concat(
classType.TypeParameters.Select(x =>
Js.Reference(SpecialNames.DefineTypeParameter).Invoke(
Js.Reference(SpecialNames.Assembly),
Js.Primitive(x.Name),
Type(x.BaseType ?? Context.Instance.ObjectType, true)
//.........这里部分代码省略.........
示例2: InitializeConstructor
private JsBlockStatement InitializeConstructor(INamedTypeSymbol type, string constructorName, Tuple<string, IParameterSymbol>[] parameters)
{
var block = new JsBlockStatement();
block.Assign(GetFromPrototype(constructorName).Member(SpecialNames.TypeField), Js.Reference(SpecialNames.TypeInitializerTypeFunction));
var parameterNames = parameters.Select(x => x.Item1);
JsExpression[] arguments;
if (!type.IsBuiltIn())
{
block.Assign(GetFromPrototype(constructorName).Member(SpecialNames.New),
Js.Function().Body(Js.New(Js.Reference(SpecialNames.TypeInitializerTypeFunction), Js.This(), Js.Reference("arguments")).Return()));
}
else
{
arguments = parameters.Where(x => x.Item2 != null && x.Item2.IsBuiltIn()).Select(x => Js.Reference(x.Item1)).ToArray();
block.Assign(GetFromPrototype(constructorName).Member(SpecialNames.New),
Js.Function(parameterNames.Select(x => Js.Parameter(x)).ToArray())
.Body(Js.New(GetFromPrototype(constructorName).Member(SpecialNames.TypeField), Js.Array(arguments)).Return()));
}
return block;
}