本文整理汇总了C#中IClass.EnumerateImplementedInterfaces方法的典型用法代码示例。如果您正苦于以下问题:C# IClass.EnumerateImplementedInterfaces方法的具体用法?C# IClass.EnumerateImplementedInterfaces怎么用?C# IClass.EnumerateImplementedInterfaces使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IClass
的用法示例。
在下文中一共展示了IClass.EnumerateImplementedInterfaces方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildClassHeaderSourceCode
/// <summary>Build the class header source code. This encompass :
/// - The class package definition.
/// - The import definitions
/// - The class definition including the type it extends and the interfaces it
/// implements.</summary>
/// <param name="definition">Class definition.</param>
/// <param name="importedTypes"></param>
/// <returns>A <see cref="StringBuilder"/> holding the source code.</returns>
private StringBuilder BuildClassHeaderSourceCode(IClass definition,
List<IJavaType> importedTypes)
{
StringBuilder resultBuilder = new StringBuilder();
string thisClassJavaNamespace = definition.NamespaceJavaName;
// string thisClassCanonicName = JavaHelpers.GetCanonicTypeName(definition.Name, out thisClassNamespace);
string thisClassCanonicName = definition.Name;
// Resolve implemented interfaces namespaces.
List<string> simpleInterfaceNames = new List<string>();
string simpleBaseClassName = definition.SuperClass.Name;
foreach (string fullInterfaceName in definition.EnumerateImplementedInterfaces()) {
string simpleInterfaceName = fullInterfaceName;
simpleInterfaceNames.Add(simpleInterfaceName);
}
if (!string.IsNullOrEmpty(thisClassJavaNamespace)) {
resultBuilder.AppendFormat("package {0};\n", thisClassJavaNamespace);
}
resultBuilder.Append("\n");
foreach (IJavaType importedType in importedTypes) {
// Types from the same namespace than the reversed class are automatically
// imported. No needs to emit an import directive.
if (object.ReferenceEquals(importedType.NamespaceJavaName, thisClassJavaNamespace)) { continue; }
resultBuilder.AppendFormat(string.Format("import {0};\n", importedType.FullyQualifiedJavaName));
}
resultBuilder.AppendLine();
resultBuilder.Append(Helpers.GetModifiersSourceCode(definition.Access));
if (definition.IsEnumeration) { resultBuilder.Append("enum "); }
else if (definition.IsInterface) { resultBuilder.Append("interface "); }
else { resultBuilder.Append("class "); }
resultBuilder.AppendFormat(" {0} ", thisClassCanonicName);
if (!definition.IsInterface) { resultBuilder.AppendFormat("extends {0}", simpleBaseClassName); }
foreach (string interfaceName in simpleInterfaceNames) {
resultBuilder.AppendFormat(", {0}", interfaceName);
}
resultBuilder.AppendLine();
resultBuilder.AppendLine("{");
return resultBuilder;
}