本文整理汇总了C#中Application.GetBinaryPageContent方法的典型用法代码示例。如果您正苦于以下问题:C# Application.GetBinaryPageContent方法的具体用法?C# Application.GetBinaryPageContent怎么用?C# Application.GetBinaryPageContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Application
的用法示例。
在下文中一共展示了Application.GetBinaryPageContent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
// skipping error checking, just demonstrating using these APIs
var app = new Application();
// get the hierarchy
string xmlHierarchy;
app.GetHierarchy(null, HierarchyScope.hsPages, out xmlHierarchy);
Console.WriteLine("Hierarchy:\n" + xmlHierarchy);
// now find the current page, print out its ID
var xdoc = XDocument.Parse(xmlHierarchy);
var ns = xdoc.Root.Name.Namespace;
var pageId = app.Windows.CurrentWindow.CurrentPageId;
Console.WriteLine("Current Page ID: " + pageId);
// get the page content, print it out
string xmlPage;
app.GetPageContent(pageId, out xmlPage);
Console.WriteLine("Page XML:\n" + xmlPage);
// sample - this is how to update content - normally you would modify the xml.
app.UpdatePageContent(xmlPage);
// bonus - if there are any images, get the binary content of the first one
var xPage = XDocument.Parse(xmlPage);
var xImage = xPage.Descendants(ns + "Image").FirstOrDefault();
if (xImage != null)
{
var xImageCallbackID = xImage.Elements(ns + "CallbackID").First();
var imageId = xImageCallbackID.Attribute("callbackID").Value;
string base64Out;
app.GetBinaryPageContent(pageId, imageId, out base64Out);
Console.WriteLine("Image found, base64 data is:\n" + base64Out);
}
}