Ejemplo n.º 1
0
        /// <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
                    + "'");
        }
Ejemplo n.º 2
0
 public void TestEscapedStar()
 {
     NodeRef nr = new NodeRef("/*/*/*");
     Assert.AreEqual("/*/*/*", nr.ToString(),
         "String comparison");
     Assert.IsTrue(nr.Includes(new NodeRef("/*/*/*/abb")),
         "nr.Includes");
 }
Ejemplo n.º 3
0
 public void TestEscapedNone()
 {
     NodeRef nr = new NodeRef("/a/b/c");
     Assert.AreEqual("/a/b/c", nr.ToString(),
         "String comparison");
 }
Ejemplo n.º 4
0
 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);
 }
Ejemplo n.º 5
0
 /// <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);
 }
Ejemplo n.º 6
0
 /// <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); }
 }
Ejemplo n.º 7
0
        /// <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());
        }