/// <summary> /// Attempts to get a part-name for traversal, expanding interpolated part-names if appropriate. /// </summary> /// <returns><c>true</c>, if a part name was resolved, <c>false</c> otherwise.</returns> /// <param name="part">A TALES path part.</param> /// <param name="context">The rendering context.</param> /// <param name="model">The TALES model.</param> /// <param name="result">Exposes the result of this operation.</param> private bool TryGetPartName(PathPart part, IRenderingContext context, ITalesModel model, out string result) { result = part.Value; bool output = true; if(part.IsInterpolated) { object interpolatedValue; if(model.TryGetRootObject(result, context, out interpolatedValue) && interpolatedValue != null) { output = true; result = interpolatedValue.ToString(); } else { output = false; result = null; } } return output; }
/// <summary> /// Attempts to get a root object, from which to begin traversal of the path. /// </summary> /// <returns><c>true</c>, if the root object was retrieved, <c>false</c> otherwise.</returns> /// <param name="walker">A TALES path walker.</param> /// <param name="context">The rendering context.</param> /// <param name="model">The TALES model.</param> /// <param name="result">Exposes the result of this operation.</param> protected virtual bool TryGetTraversalRoot(PathWalker walker, IRenderingContext context, ITalesModel model, out object result) { bool output; if(walker.NextPart() && model.TryGetRootObject(walker.CurrentPart.Value, context, out result)) { output = true; } else { output = false; result = null; } return output; }