public override long GetLastModified(NVelocity.Runtime.Resource.Resource resource) { if (File.Exists(resource.Name)) { var file = new FileInfo(resource.Name); return(file.LastWriteTime.Ticks); } return(base.GetLastModified(resource)); }
public override bool IsSourceModified(NVelocity.Runtime.Resource.Resource resource) { if (File.Exists(resource.Name)) { var file = new FileInfo(resource.Name); return(!file.Exists || (file.LastWriteTime.Ticks != resource.LastModified)); } return(base.IsSourceModified(resource)); }
public override bool IsSourceModified(Resource resource) { var template = resource as CustomTemplate; if (template != null) { return(template.IsModified); } return(false); }
public override bool IsSourceModified(Resource resource) { CustomTemplate template = resource as CustomTemplate; if (template != null) { return template.IsModified; } return false; }
public override long getLastModified(Resource resource) { String path = (String)templatePaths[resource.Name]; FileInfo file = new FileInfo(path + "\\" + resource.Name); if (file.Exists) { return(file.LastWriteTime.Ticks); } else { return(0); } }
private String SetUpEncoding(InternalContextAdapter context) { Resource current = context.CurrentResource; String encoding = null; if (current != null) { encoding = current.Encoding; } else { encoding = (String)rsvc.getProperty(RuntimeConstants_Fields.INPUT_ENCODING); } return(encoding); }
/// <summary> /// How to keep track of all the modified times /// across the paths. /// </summary> public override bool isSourceModified(Resource resource) { String path = (String)templatePaths[resource.Name]; FileInfo file = new FileInfo(path + "\\" + resource.Name); if (file.Exists) { if (file.LastWriteTime.Ticks != resource.LastModified) { return(true); } else { return(false); } } // If the file is now unreadable, or it has // just plain disappeared then we'll just say // that it's modified :-) When the loader attempts // to load the stream it will fail and the error // will be reported then. return(true); }
public override long getLastModified(Resource resource) { String path = (String) templatePaths[resource.Name]; FileInfo file = new FileInfo(path + "\\" + resource.Name); if (file.Exists) { return file.LastWriteTime.Ticks; } else { return 0; } }
/// <summary> /// How to keep track of all the modified times /// across the paths. /// </summary> public override bool isSourceModified(Resource resource) { String path = (String) templatePaths[resource.Name]; FileInfo file = new FileInfo(path + "\\" + resource.Name); if (file.Exists) { if (file.LastWriteTime.Ticks != resource.LastModified) { return true; } else { return false; } } // If the file is now unreadable, or it has // just plain disappeared then we'll just say // that it's modified :-) When the loader attempts // to load the stream it will fail and the error // will be reported then. return true; }
/// <summary> Given a template, check to see if the source of InputStream /// has been modified. /// </summary> public abstract bool isSourceModified(Resource resource);
/// <summary> Get the last modified time of the InputStream source /// that was used to create the template. We need the template /// here because we have to extract the name of the template /// in order to locate the InputStream source. /// </summary> public abstract long getLastModified(Resource resource);
public override long GetLastModified(Resource resource) { return resource.LastModified; }
public override long GetLastModified(Resource resource) { return(resource.LastModified); }
/// <summary> Return name of this directive. /// </summary> /// <summary> Return type of this directive. /// </summary> /// <summary> iterates through the argument list and renders every /// argument that is appropriate. Any non appropriate /// arguments are logged, but render() continues. /// </summary> public override bool render(InternalContextAdapter context, System.IO.TextWriter writer, Node node) { /* * did we get an argument? */ if (node.jjtGetChild(0) == null) { rsvc.error("#parse() error : null argument"); return(false); } /* * does it have a value? If you have a null reference, then no. */ System.Object value_Renamed = node.jjtGetChild(0).value_Renamed(context); if (value_Renamed == null) { rsvc.error("#parse() error : null argument"); return(false); } /* * get the path */ //UPGRADE_TODO: The equivalent in .NET for method 'java.Object.toString' may return a different value. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1043"' System.String arg = value_Renamed.ToString(); /* * see if we have exceeded the configured depth. * If it isn't configured, put a stop at 20 just in case. */ System.Object[] templateStack = context.TemplateNameStack; if (templateStack.Length >= rsvc.getInt(NVelocity.Runtime.RuntimeConstants_Fields.PARSE_DIRECTIVE_MAXDEPTH, 20)) { System.Text.StringBuilder path = new System.Text.StringBuilder(); for (int i = 0; i < templateStack.Length; ++i) { path.Append(" > " + templateStack[i]); } rsvc.error("Max recursion depth reached (" + templateStack.Length + ")" + " File stack:" + path); return(false); } Resource current = context.CurrentResource; /* * get the resource, and assume that we use the encoding of the current template * the 'current resource' can be null if we are processing a stream.... */ System.String encoding = null; if (current != null) { encoding = current.Encoding; } else { encoding = (System.String)rsvc.getProperty(NVelocity.Runtime.RuntimeConstants_Fields.INPUT_ENCODING); } /* * now use the Runtime resource loader to get the template */ Template t = null; try { t = rsvc.getTemplate(arg, encoding); } catch (ResourceNotFoundException rnfe) { /* * the arg wasn't found. Note it and throw */ rsvc.error("#parse(): cannot find template '" + arg + "', called from template " + context.CurrentTemplateName + " at (" + Line + ", " + Column + ")"); throw rnfe; } catch (ParseErrorException pee) { /* * the arg was found, but didn't parse - syntax error * note it and throw */ rsvc.error("#parse(): syntax error in #parse()-ed template '" + arg + "', called from template " + context.CurrentTemplateName + " at (" + Line + ", " + Column + ")"); throw pee; } catch (System.Exception e) { rsvc.error("#parse() : arg = " + arg + ". Exception : " + e); return(false); } /* * and render it */ try { context.PushCurrentTemplateName(arg); ((SimpleNode)t.Data).render(context, writer); } catch (System.Exception e) { /* * if it's a MIE, it came from the render.... throw it... */ if (e is MethodInvocationException) { throw (MethodInvocationException)e; } rsvc.error("Exception rendering #parse( " + arg + " ) : " + e); return(false); } finally { context.PopCurrentTemplateName(); } return(true); }
public override long GetLastModified(NVelocity.Runtime.Resource.Resource resource) { return(1); }
public override bool IsSourceModified(NVelocity.Runtime.Resource.Resource resource) { return(false); }
/// <summary> does the actual rendering of the included file /// * /// </summary> /// <param name="node">AST argument of type StringLiteral or Reference /// </param> /// <param name="context">valid context so we can render References /// </param> /// <param name="writer">output Writer /// </param> /// <returns>boolean success or failure. failures are logged /// /// </returns> private bool renderOutput(INode node, InternalContextAdapter context, System.IO.TextWriter writer) { System.String arg = ""; if (node == null) { rsvc.error("#include() error : null argument"); return(false); } /* * does it have a value? If you have a null reference, then no. */ System.Object value_Renamed = node.value_Renamed(context); if (value_Renamed == null) { rsvc.error("#include() error : null argument"); return(false); } /* * get the path */ //UPGRADE_TODO: The equivalent in .NET for method 'java.Object.toString' may return a different value. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1043"' arg = value_Renamed.ToString(); Resource resource = null; Resource current = context.CurrentResource; try { /* * get the resource, and assume that we use the encoding of the current template * the 'current resource' can be null if we are processing a stream.... */ System.String encoding = null; if (current != null) { encoding = current.Encoding; } else { encoding = (System.String)rsvc.getProperty(NVelocity.Runtime.RuntimeConstants_Fields.INPUT_ENCODING); } resource = rsvc.getContent(arg, encoding); } catch (ResourceNotFoundException rnfe) { /* * the arg wasn't found. Note it and throw */ rsvc.error("#include(): cannot find resource '" + arg + "', called from template " + context.CurrentTemplateName + " at (" + Line + ", " + Column + ")"); throw rnfe; } catch (System.Exception e) { rsvc.error("#include(): arg = '" + arg + "', called from template " + context.CurrentTemplateName + " at (" + Line + ", " + Column + ") : " + e); } if (resource == null) { return(false); } writer.Write((System.String)resource.Data); return(true); }