本文整理汇总了C#中ApplicationClass.GetHierarchy方法的典型用法代码示例。如果您正苦于以下问题:C# ApplicationClass.GetHierarchy方法的具体用法?C# ApplicationClass.GetHierarchy怎么用?C# ApplicationClass.GetHierarchy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ApplicationClass
的用法示例。
在下文中一共展示了ApplicationClass.GetHierarchy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessRecord
protected override void ProcessRecord( )
{
if (ShouldProcess( _fullName ))
{
ApplicationClass _app = new ApplicationClass( );
string objectId;
_app.OpenHierarchy(_fullName, null, out objectId, CreateFileType.cftNone);
string hierarchyXml;
_app.GetHierarchy(objectId, HierarchyScope.hsSelf, out hierarchyXml);
XmlDocument hierarchyDoc = new XmlDocument( );
hierarchyDoc.LoadXml(hierarchyXml);
string notebookName = hierarchyDoc.DocumentElement.Attributes["name"].Value;
WriteObject("OneNote:\\" + notebookName);
}
}
示例2: getOneNoteNode
/// <summary>
/// Gets the OneNote XML node that is associated with a "Path" of names that go:
/// \Notebook\Section\Page
/// </summary>
/// <param name="path">The path to a OneNote organizational element.</param>
/// <returns>An XML Node representing the element if it's found, or null otherwise.</returns>
private XmlNode getOneNoteNode(string path)
{
//
// First, get the current hierarchy down to the page level.
//
string xml;
ApplicationClass _app = new ApplicationClass( );
_app.GetHierarchy(
"",
HierarchyScope.hsPages,
out xml);
XmlDocument hierarchy = new XmlDocument( );
hierarchy.LoadXml(xml);
if (PathIsDrive(path))
{
return hierarchy.DocumentElement;
}
//
// Next, split the path.
//
string[] pathComponents = splitPath(path);
//
// Now, walk down the hierarchy looking at element names.
//
XmlNode currentElement = hierarchy.DocumentElement;
foreach (string component in pathComponents)
{
currentElement = getChildNodeByName(currentElement, component);
if (currentElement == null)
{
return null;
}
}
return currentElement;
}