/// <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 TestAssemblyMissingSlash() { AssemblyAssetProvider aap = new AssemblyAssetProvider(GetType().Assembly); IAsset asset = aap.GetAsset(new NodeRef("/gary/bob"), false); Assert.IsNull(asset); }
public void TestAssemblySimple2() { AssemblyAssetProvider aap = new AssemblyAssetProvider(GetType().Assembly); IAsset asset = aap.GetAsset(new NodeRef("/foo/bar"), false); Assert.IsNotNull(asset); }
public void TestAssemblyStrippedSlash() { AssemblyAssetProvider aap = new AssemblyAssetProvider(GetType().Assembly); aap.StripLeadingSlash = false; IAsset asset = aap.GetAsset(new NodeRef("/gary/bob"), false); Assert.IsNotNull(asset); }
public void TestAssemblyMissingException() { AssemblyAssetProvider aap = new AssemblyAssetProvider(GetType().Assembly); aap.GetAsset(new NodeRef("/gary/bob"), true); }