本文整理汇总了C#中RenderState.Warning方法的典型用法代码示例。如果您正苦于以下问题:C# RenderState.Warning方法的具体用法?C# RenderState.Warning怎么用?C# RenderState.Warning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderState
的用法示例。
在下文中一共展示了RenderState.Warning方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: processImportTemplateElement
//.........这里部分代码省略.........
// Read the cms-template-area's id attribute:
if (!tst.Reader.MoveToAttribute("id"))
{
tst.Error("cms-template-area needs an 'id' attribute");
tst.Reader.MoveToElement();
tst.SkipElementAndChildren("cms-template-area");
return false;
}
// Assign the template's area id:
string tmplAreaId = tst.Reader.Value;
// Move to the first area if we have to:
if (isFirstArea)
{
if (!st.Reader.IsEmptyElement)
{
fillerAreaId = moveToNextAreaElement(st);
}
isFirstArea = false;
}
// Do the ids match?
if ((fillerAreaId != null) && (tmplAreaId == fillerAreaId))
{
// Skip the cms-template-area in the template:
tst.Reader.MoveToElement();
tst.SkipElementAndChildren("cms-template-area");
// Move the filler reader to the element node:
st.Reader.MoveToElement();
// Copy the elements:
await stWriter.CopyElementChildren("area");
// Move to the next area element, if available:
fillerAreaId = moveToNextAreaElement(st);
}
else
{
// Insert the default content from the template:
tst.Reader.MoveToElement();
// Recurse into children, allowing processing of embedded cms-template-areas:
await tst.CopyElementChildren("cms-template-area", null, processTemplateAreaElements);
}
// We handled this:
return false;
});
// Now continue on stream-copying child elements until we find a cms-template-area:
var err = await sst.CopyElementChildren("cms-template", null, processTemplateAreaElements)
.ConfigureAwait(continueOnCapturedContext: false);
if (err.HasErrors) return err.Errors;
// We missed some <area />s in the cms-import-template:
while (!((st.Reader.NodeType == XmlNodeType.EndElement) && (st.Reader.LocalName == "cms-import-template")) &&
!((st.Reader.NodeType == XmlNodeType.Element) && st.Reader.IsEmptyElement && (st.Reader.LocalName == "cms-import-template")))
{
// Move to the next <area /> start element:
fillerAreaId = moveToNextAreaElement(st);
if (fillerAreaId != null)
{
st.Warning("area '{0}' unused by the template", fillerAreaId);
st.SkipElementAndChildren("area");
}
}
return false;
});
// Process the imported cms-template and inject the <area /> elements from the current <cms-import-template /> element:
RenderState importedTemplate = new RenderState(
st.Engine,
tmplBlob,
earlyExit: (Func<RenderState, bool>)(sst =>
{
return false;
}),
processElements: processElements,
previous: st
);
// Render the template:
var esbResult = await importedTemplate.Render().ConfigureAwait(continueOnCapturedContext: false);
if (esbResult.HasErrors)
{
foreach (var err in esbResult.Errors)
st.Error(err.Message);
return esbResult.Errors;
}
StringBuilder sbResult = esbResult.Value;
string blob = sbResult.ToString();
// Write the template to our current writer:
st.Writer.Append(blob);
return Errorable.NoErrors;
}