本文整理汇总了C#中System.Windows.Forms.HtmlElement.AppendChild方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlElement.AppendChild方法的具体用法?C# HtmlElement.AppendChild怎么用?C# HtmlElement.AppendChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.HtmlElement
的用法示例。
在下文中一共展示了HtmlElement.AppendChild方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StartConfigurationLoad
/// <summary>
/// Begin loading the configuration.
/// </summary>
private void StartConfigurationLoad()
{
DisplayProgressMessage("Loading configuration, please wait...", 0);
myStopwatch.Reset();
myStopwatch.Start();
var loader = new DefaultConfigurationFileLoader(this);
myBodyEl = validationResults.Document.Body;
myBodyEl.InnerHtml = string.Empty;
this.configurationHierarchy.Initialise(myFileName);
// Initialise the display
DisplayConfig();
ClearProcessed();
try
{
// Attempt to load the configuration
loader.Load(new FileInfo(myFileName));
}
catch (ConfigurationException error)
{
// There is an error with the configuration
myBodyEl.AppendChild(
GenerateElement("div",
new HtmlAttribute("class", "error"),
GenerateElement("div", "Unable to load configuration:")));
var errors = GenerateElement("ul");
myBodyEl.AppendChild(errors);
// Generate the error details
Exception errorDetails = error;
while (errorDetails != null)
{
errors.AppendChild(
GenerateElement("li", errorDetails.Message));
errorDetails = errorDetails.InnerException;
}
// Log the base error
LogMessage(error.Message);
isConfigValid = false;
}
catch (PreprocessorException error)
{
// There was an error with pre-processing
var message = "Preprocessing failed loading the XML: " + error.Message;
myBodyEl.AppendChild(
GenerateElement("div",
new HtmlAttribute("class", "error"),
GenerateElement("div", message)));
LogMessage(message);
isConfigValid = false;
}
catch (Exception error)
{
// Catch-all exception block
StringBuilder message = new StringBuilder();
message.Append("An unexpected error has occurred while loading the configuration!" +
Environment.NewLine +
"Please report this error to the CCNet user group (http://groups.google.com/group/ccnet-user). This will help us to improve this application.");
Exception currentError = error;
while (currentError != null)
{
message.AppendFormat("{0}{1} [{2}]", Environment.NewLine, currentError.Message, currentError.GetType().Name);
message.AppendFormat("{0}{1}", Environment.NewLine, currentError.StackTrace);
currentError = currentError.InnerException;
if (currentError != null)
{
message.AppendFormat("{0}{1} Inner Exception {1}", Environment.NewLine, new string('=', 10));
}
}
MessageBox.Show(this, message.ToString(), "Unexpected error", MessageBoxButtons.OK, MessageBoxIcon.Error);
isConfigValid = false;
}
}
示例2: ValidateElement
private object ValidateElement(HtmlElement tableEl, XmlNode node, int row, Configuration configuration)
{
HtmlAttribute rowClass = new HtmlAttribute("class", (row % 2) == 1 ? "even" : "odd");
object loadedItem = null;
try
{
loadedItem = myConfigReader.Read(node);
this.configurationHierarchy.Add(loadedItem);
if (loadedItem is IProject)
{
IProject project = loadedItem as IProject;
configuration.AddProject(project);
tableEl.AppendChild(
GenerateElement("tr",
rowClass,
GenerateElement("td", project.Name),
GenerateElement("td", "Project"),
GenerateElement("td", "Yes")));
LogMessage(string.Format("Loaded project '{0}'", project.Name));
}
else if (loadedItem is IQueueConfiguration)
{
IQueueConfiguration queueConfig = loadedItem as IQueueConfiguration;
configuration.QueueConfigurations.Add(queueConfig);
tableEl.AppendChild(
GenerateElement("tr",
rowClass,
GenerateElement("td", queueConfig.Name),
GenerateElement("td", "Queue"),
GenerateElement("td", "Yes")));
LogMessage(string.Format("Loaded queue '{0}'", queueConfig.Name));
}
else if (loadedItem is ISecurityManager)
{
ISecurityManager securityManager = loadedItem as ISecurityManager;
configuration.SecurityManager = securityManager as ISecurityManager;
LogMessage("Loaded security manager");
}
else
{
tableEl.AppendChild(
GenerateElement("tr",
rowClass,
GenerateElement("td", (node as XmlElement).GetAttribute("name")),
GenerateElement("td", node.Name),
GenerateElement("td", "No")));
var message = "Unknown configuration type: " + loadedItem.GetType().Name;
tableEl.AppendChild(
GenerateElement("tr",
rowClass,
GenerateElement("td",
new HtmlAttribute("colspan", "3"),
GenerateElement("div",
new HtmlAttribute("class", "error"),
message))));
LogMessage(message);
isConfigValid = false;
}
}
catch (Exception error)
{
string errorMsg = error.Message;
int index = errorMsg.IndexOf("Xml Source");
if (index >= 0) errorMsg = errorMsg.Substring(0, index - 1);
tableEl.AppendChild(
GenerateElement("tr",
rowClass,
GenerateElement("td", (node as XmlElement).GetAttribute("name")),
GenerateElement("td", node.Name),
GenerateElement("td", "No")));
tableEl.AppendChild(
GenerateElement("tr",
rowClass,
GenerateElement("td",
new HtmlAttribute("colspan", "3"),
GenerateElement("div",
new HtmlAttribute("class", "error"),
errorMsg))));
isConfigValid = false;
LogMessage(error.Message);
}
return loadedItem;
}
示例3: attachScript
private void attachScript(HtmlElement parentElement, String scriptText)
{
HtmlElement newScript = browser.Document.CreateElement("script");
mshtml.IHTMLScriptElement script = (mshtml.IHTMLScriptElement)newScript.DomElement;
script.text = scriptText;
parentElement.AppendChild(newScript);
}