本文整理汇总了C#中ITypeDefinition.IsInterface方法的典型用法代码示例。如果您正苦于以下问题:C# ITypeDefinition.IsInterface方法的具体用法?C# ITypeDefinition.IsInterface怎么用?C# ITypeDefinition.IsInterface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITypeDefinition
的用法示例。
在下文中一共展示了ITypeDefinition.IsInterface方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Visit
public TsType Visit(ITypeDefinition ce)
{
var name = SkJs.GetEntityJsName(ce);
var ce2 = new TsType
{
Name = name, Kind=(ce.IsInterface() || ce.IsDelegate()) ? TsTypeKind.Interface : TsTypeKind.Class,
TypeParameters = ce.TypeParameters.Select(Visit).ToList()
};
if (name.Contains("."))
{
var pair = name.SplitAt(name.LastIndexOf("."), true);
ce2.Name = pair[1];
ce2.ModuleName = pair[0];
ce2.IsModuleExport = true;
}
if (ce.IsDelegate())
{
var func = Visit(ce.GetDelegateInvokeMethod());
//func.IsCallSignature = true;
func.Name = null;
ce2.Members.Add(func);
}
else
{
var members = TypeConverter.ClrConverter.GetMembersToExport(ce);
var members2 = members.Select(Visit).Where(t => t != null).ToList();
ce2.Members.AddRange(members2);
if (ce2.Kind == TsTypeKind.Class)
{
ce2.Members.OfType<TsFunction>().Where(t => !t.IsConstructor || !t.Type.IsNullOrVoid()).ForEach(t => t.Body = "return null;");
ce2.Members.OfType<TsFunction>().Where(t => t.IsConstructor).ForEach(t => t.Body = "");
}
}
return ce2;
}
示例2: ExportClassStructInterface
private JsNode ExportClassStructInterface(ITypeDefinition ce)
{
var jsType = new JsClrType();
jsType.Kind = GetJsTypeKind(ce);
jsType.fullname = GetJsTypeName(ce);
var baseClass = GetBaseClassIfValid(ce, true);
if (baseClass != null)
{
var baseClassName = GetJsTypeName(baseClass);
if (baseClassName != jsType.fullname) //avoid object:object inheritance recursion
jsType.baseTypeName = baseClassName;
}
var globalCode = new List<JsUnit>();
if (!ce.IsInterface() || Sk.NewInterfaceImplementation)
{
var members = GetMembersToExport(ce);
var inlineFields = Sk.InlineFields(ce);
var cctor = ce.GetConstructors(false, true).FirstOrDefault();
if (cctor == null && !inlineFields && ce.GetFields().Where(t => t.IsStatic).FirstOrDefault() != null)
{
cctor = CreateStaticCtor(ce);
if (ShouldExportConstructor(cctor))
members.Insert(0, cctor);
}
var mappings = members.Select(t => new EntityToJsNode { JsNode = Visit(t), Entity = t }).ToList();
//Remove GlobalCode=True members from mappings
for (var i = mappings.Count - 1; i >= 0; i--)
{
if (mappings[i].JsNode is JsUnit)
{ //Maybe more clean: Another way could be to check the IEntity for GlobalCode=True
globalCode.Add((JsUnit)mappings[i].JsNode);
mappings.RemoveAt(i);
}
}
ImportToType(jsType, mappings);
}
ExportImplementedInterfaces(ce, jsType);
jsType.assemblyName = AssemblyName;
var atts = ExportCustomAttributes(ce);
if (atts.IsNotNullOrEmpty())
{
if (jsType.customAttributes == null)
jsType.customAttributes = new JsArray<JsClrAttribute>();
jsType.customAttributes.AddRange(atts);
}
var unit = OnAfterExportType(ce, jsType);
globalCode.ForEach(t => unit.Statements.AddRange(t.Statements));
return unit;
}
示例3: GetJsTypeKind
JsClrTypeKind GetJsTypeKind(ITypeDefinition ce)
{
if (ce.IsEnum())
return JsClrTypeKind.Enum;
else if (ce.IsInterface())
return JsClrTypeKind.Interface;
else if (ce.Kind == TypeKind.Struct)
return JsClrTypeKind.Struct;
return JsClrTypeKind.Class;
}