/// <summary> /// Constructs an asset from the given assembly. If the resource /// does not exist, this throws an AssetException. /// </summary> public AssemblyAsset(AssemblyAssetProvider provider, NodeRef path) { // Save the fields this.provider = provider; this.path = path.ToString(); if (provider.StripLeadingSlash) this.path = this.path.Substring(1); // Make sure it exists bool found = false; foreach (string name in provider.Assembly.GetManifestResourceNames()) { if (name == this.path) { found = true; break; } } if (!found) throw new AssetException("Cannot find resource '" + path + "' from assembly '" + provider.Assembly.FullName + "'"); }
public void TestEscapedStar() { NodeRef nr = new NodeRef("/*/*/*"); Assert.AreEqual("/*/*/*", nr.ToString(), "String comparison"); Assert.IsTrue(nr.Includes(new NodeRef("/*/*/*/abb")), "nr.Includes"); }
public void TestEscapedNone() { NodeRef nr = new NodeRef("/a/b/c"); Assert.AreEqual("/a/b/c", nr.ToString(), "String comparison"); }
public void ParsePluses() { NodeRef nr = new NodeRef("/Test/Test +1/Test +2"); Assert.AreEqual("/Test/Test +1/Test +2", nr.ToString()); Assert.AreEqual("Test +2", nr.Name); }
/// <summary> /// Returns true if this path includes the given path. This means /// that given path is under or part of this node's path. /// </summary> public bool Includes(NodeRef path) { // We have a real easy way of finding this return Regex.IsMatch(path.ToString(), "^" + regexable); }
/// <summary> /// Returns the attribute tree node for the given path. If it does /// not exist, a null is returned. /// </summary> public AttributeTree this[NodeRef nref] { get { return this[nref, false]; } set { BaseSet(nref.ToString(), value); } }
/// <summary> /// Called when a new child is created (but not cloned). /// </summary> public virtual void OnCreatedAsChild(NodeRef nref, AttributeTree parent) { Path = new NodeRef(parent.Path.ToString() + nref.ToString()); }