本文整理汇总了C#中TypeDeclaration.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# TypeDeclaration.ToString方法的具体用法?C# TypeDeclaration.ToString怎么用?C# TypeDeclaration.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeDeclaration
的用法示例。
在下文中一共展示了TypeDeclaration.ToString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: handle
private void handle(TypeDeclaration type, DirectoryInfo projectFolder)
{
if (type.ClassType != ClassType.Enum)
return;
Dictionary<String, String> textDict = new Dictionary<string, string>();
foreach (AttributeSection attribute in type.Attributes)
{
String attributeText = attribute.ToString();
Match attributeNameMatch = getAttrubuteNameRegex.Match(attribute.ToString());
Group attributeNameGroup = attributeNameMatch.Groups["name"];
if (!attributeNameGroup.Success || attributeNameGroup.Value != "TextResource")
continue;
foreach (Match match in regex.Matches(type.ToString()))
{
Group keyGroup = match.Groups["key"];
Group valueGroup = match.Groups["value"];
if (!keyGroup.Success || !valueGroup.Success)
continue;
String key = keyGroup.Value.Trim();
String value = valueGroup.Value.Trim();
textDict.Add(key, value);
}
}
if (textDict.Count == 0)
return;
TypeDeclaration currentType = type;
String typeFullName = null;
while (true)
{
if (typeFullName == null)
typeFullName = type.Name;
else
typeFullName = String.Format("{0}+{1}", currentType.Name, typeFullName);
if (currentType.Parent is TypeDeclaration)
{
currentType = (TypeDeclaration)currentType.Parent;
continue;
}
else if (currentType.Parent is NamespaceDeclaration)
{
NamespaceDeclaration namesp = (NamespaceDeclaration)currentType.Parent;
typeFullName = String.Format("{0}.{1}", namesp.FullName, typeFullName);
break;
}
else
throw new ApplicationException("Type's parent unknown!");
}
handle(typeFullName, textDict, projectFolder);
}
示例2: renderInterface
InterfaceRenderInformation renderInterface(TypeDeclaration interfaceDecl)
{
var ret = new InterfaceRenderInformation();
ret.isRoutableViewModel = interfaceDecl.BaseTypes
.OfType<SimpleType>()
.Any(x => x.Identifier == "IRoutableViewModel") ? ret : null;
ret.definition = "public " + chompedString(interfaceDecl.ToString().Replace("[Once]", ""));
ret.interfaceName = chompedString(interfaceDecl.Name);
ret.implClassName = ret.interfaceName.Substring(1); // Skip the 'I'
ret.properties = interfaceDecl.Children
.Where(x => x is PropertyDeclaration || x is MethodDeclaration)
.Select(renderPropertyDeclaration)
.ToArray();
ret.onceProperties = ret.properties
.Where(x => x.onceProp != null)
.Select(x => x.onceProp)
.ToArray();
return ret;
}
示例3: Set
public static TypeCode Set(TypeDeclaration typedecl, CSharpAstResolver resolver)
{
var ns = typedecl.Parent as NamespaceDeclaration;
var nsName = ns == null ? "" : ns.FullName;
var name = typedecl.Name;
var usings =
resolver.RootNode.Descendants.
OfType<UsingDeclaration> ().
Select (x => x.ToString ().Trim ()).
ToList ();
var code = typedecl.ToString ();
var deps = new List<String> ();
foreach (var d in typedecl.Descendants.OfType<SimpleType> ()) {
deps.Add (d.Identifier);
}
return Set (name, usings, code, deps, nsName);
}
示例4: WriteTypeDeclaration
private static void WriteTypeDeclaration(TypeDeclaration value, TextWriter writer)
{
writer.Write(value.ToString());
}