本文整理汇总了C#中ITemplate.ImplementsServerInterface方法的典型用法代码示例。如果您正苦于以下问题:C# ITemplate.ImplementsServerInterface方法的具体用法?C# ITemplate.ImplementsServerInterface怎么用?C# ITemplate.ImplementsServerInterface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITemplate
的用法示例。
在下文中一共展示了ITemplate.ImplementsServerInterface方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryProcess
public bool TryProcess(IDocumentProcessor docProcessor, XmlNode node, bool isRoot, ITemplate template, IRenderFunction currentRenderFunction) {
if (node.NodeType != XmlNodeType.ProcessingInstruction || node.Name != "view")
return false;
if (!isRoot)
throw ParserUtils.TemplateErrorException(string.Format("The view directive can only appear outside of the template.", node.Name));
string[] serverTypeArr = Utils.RegexExec(node.Value, "modelType=\"([^\"]*)\"", "");
string[] clientTypeArr = Utils.RegexExec(node.Value, "clientModelType=\"([^\"]*)\"", "");
if (serverTypeArr == null && clientTypeArr != null)
throw ParserUtils.TemplateErrorException("You cannot specify a client type for the model if you don't specify a server type");
if (template.HasMember("Model") || template.HasMember("model") || template.HasMember("Saltarelle.Mvc.IView.Model"))
throw ParserUtils.TemplateErrorException("The template already defines at least one of the members essential to use the view directive. Have you specified <?view?> more than once?");
string serverType = (serverTypeArr != null ? serverTypeArr[1] : "object"), clientType = (clientTypeArr != null ? clientTypeArr[1] : null);
string viewInterface = "Saltarelle.Mvc.IView<" + serverType + ">";
if (template.ImplementsServerInterface(viewInterface))
throw ParserUtils.TemplateErrorException("The template already implements the interface " + viewInterface + ".");
template.AddServerInterface(viewInterface);
template.AddMember(new FieldMember("model", serverType, clientType));
template.AddMember(new PropertyMember("Model", serverType, null, AccessModifier._Public, "model", serverType, null, true, true, "ModelChanged", false));
template.AddMember(new PropertyMember("Saltarelle.Mvc.IView.Model", "object", null, AccessModifier._None, "model", serverType, null, true, true, "ModelChanged", false));
return true;
}
示例2: 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;
}