本文整理汇总了C#中CsElement.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# CsElement.GetType方法的具体用法?C# CsElement.GetType怎么用?C# CsElement.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CsElement
的用法示例。
在下文中一共展示了CsElement.GetType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RecordElement
/// <summary>
/// Records information about the given element, under the given node.
/// </summary>
/// <param name="element">
/// The element to record.
/// </param>
/// <param name="parentNode">
/// The Xml node to record this element beneath.
/// </param>
/// <returns>
/// Returns the new Xml node describing this element.
/// </returns>
private static XmlNode RecordElement(CsElement element, XmlNode parentNode)
{
Param.AssertNotNull(element, "element");
Param.AssertNotNull(parentNode, "parentNode");
// Create a new node for this element and add it to the parent.
XmlNode elementNode = parentNode.OwnerDocument.CreateElement("Element");
parentNode.AppendChild(elementNode);
// Add the name and type of the element.
XmlAttribute name = parentNode.OwnerDocument.CreateAttribute("Name");
name.Value = element.Declaration.Name;
elementNode.Attributes.Append(name);
XmlAttribute type = parentNode.OwnerDocument.CreateAttribute("Type");
type.Value = element.GetType().Name;
elementNode.Attributes.Append(type);
return elementNode;
}
示例2: GetDeclaration
private string GetDeclaration(CsElement codeElement)
{
if (codeElement.GetType().Name == "Method")
{
var methodDeclaration = (Method)codeElement;
var parameters = string.Join(",", methodDeclaration.Parameters.Select(x => x.Type.Text));
var returnType = methodDeclaration.ReturnType != null ? " : " + methodDeclaration.ReturnType.Text : string.Empty;
var declaration = methodDeclaration.Declaration.Name + "(" + parameters + ")" + returnType;
return declaration.Replace(",", ", ");
}
if (codeElement.GetType().Name == "Constructor")
{
var constructorDeclaration = (Constructor)codeElement;
var parameters = string.Join(",", constructorDeclaration.Parameters.Select(x => x.Type.Text));
var declaration = constructorDeclaration.Declaration.Name + "(" + parameters + ")";
return declaration.Replace(",", ", ");
}
if (codeElement.GetType().Name == "Accessor")
{
var accessor = (Accessor)codeElement;
var property = (Property)codeElement.Parent;
var parameters = string.Join(", ", accessor.Parameters.Select(x => x.Type.Text));
var returnType = accessor.ReturnType != null ? " : " + accessor.ReturnType.Text : string.Empty;
var declaration = property.Declaration.Name + "." + accessor.Declaration.Name + "(" + parameters + ")" + returnType;
return declaration.Replace(",", ", ");
}
return codeElement.Declaration.Name.Replace(",", ", ");
}
示例3: GetNameSpace
private string GetNameSpace(CsElement codeElement)
{
while (codeElement.GetType().Name != "Namespace" && codeElement.GetType().Name != "DocumentRoot")
{
codeElement = (CsElement)codeElement.Parent;
}
return codeElement.FullNamespaceName.Replace("Root.", string.Empty);
}
示例4: GetClassName
private string GetClassName(CsElement codeElement)
{
if (codeElement.GetType().Name == "DocumentRoot" ||
codeElement.GetType().Name == "Namespace" ||
codeElement.GetType().Name == "AssemblyOrModuleAttribute")
{
return string.Empty;
}
if (codeElement.GetType().Name == "UsingDirective")
{
return "UsingDirective";
}
if (codeElement.GetType().Name == "Class" || codeElement.GetType().Name == "Interface" || codeElement.GetType().Name == "Enum")
{
return codeElement.Declaration.Name;
}
return GetClassName((CsElement)codeElement.Parent);
}