本文整理汇总了C#中ITemplate.AddClientInterface方法的典型用法代码示例。如果您正苦于以下问题:C# ITemplate.AddClientInterface方法的具体用法?C# ITemplate.AddClientInterface怎么用?C# ITemplate.AddClientInterface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITemplate
的用法示例。
在下文中一共展示了ITemplate.AddClientInterface方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryProcess
public bool TryProcess(IDocumentProcessor docProcessor, XmlNode node, bool isRoot, ITemplate template, IRenderFunction currentRenderFunction) {
if (node.NodeType != XmlNodeType.ProcessingInstruction || (node.Name != "inherits" && node.Name != "implements"))
return false;
if (!isRoot)
throw ParserUtils.TemplateErrorException(string.Format("The {0} directive can only appear outside of the template.", node.Name));
string[] sideArr = Utils.RegexExec(node.Value, "side=\"([^\"]*)\"", "");
string[] typeArr = Utils.RegexExec(node.Value, "type=\"([^\"]*)\"", "");
if (typeArr == null)
throw ParserUtils.TemplateErrorException(node.Name + " elements must have the type specified.");
if (sideArr == null)
throw ParserUtils.TemplateErrorException(node.Name + " elements must have the side specified.");
string side = sideArr[1].Trim(), type = typeArr[1].Trim();
bool serverSide, clientSide;
switch (side) {
case "client":
serverSide = false;
clientSide = true;
break;
case "server":
serverSide = true;
clientSide = false;
break;
case "both":
serverSide = true;
clientSide = true;
break;
default:
throw ParserUtils.TemplateErrorException("The side attribute of the " + node.Name + " element must be 'client', 'server', or 'both'.");
}
if (node.Name == "implements") {
if (serverSide) {
if (template.ImplementsServerInterface(type))
throw ParserUtils.TemplateErrorException("The interface " + type + " is implemented more than once on the server side.");
template.AddServerInterface(type);
}
if (clientSide) {
if (template.ImplementsClientInterface(type))
throw ParserUtils.TemplateErrorException("The interface " + type + " is implemented more than once on the client side.");
template.AddClientInterface(type);
}
}
else {
if (serverSide) {
if (template.ServerInherits != null)
throw ParserUtils.TemplateErrorException("Cannot inherit from more than one class on the server side.");
template.ServerInherits = type;
}
if (clientSide) {
if (template.ClientInherits != null)
throw ParserUtils.TemplateErrorException("Cannot inherit from more than one class on the client side.");
template.ClientInherits = type;
}
}
return true;
}