Plugin Developer Discussion

Discussion for FogBugz Plugin developers

Embeded resources instead of files for static content

I would greatly prefer putting my static content in embedded resources. This seems like a much more natural approach for static content within plugins. Alternatively, I could live with an IPlugInstallStaticFiles interface with a method InstallGetStaticContent that was called during plugin installation/upgrade, and returned an array of CStaticFile objects. Then it would create/replace all the files returned, and delete any files not in the array.

class CStaticFile
{
    public string FileName;
    public byte[] Data;
}

Then I could do something like this:

public CStaticFile[] InstallGetStaticContent()
{
    var ns = GetType().Namespace;
    var assembly = GetType().Assembly;
    return (from name in assembly.GetManifestResourceNames()
            let stream = assembly.GetManifestResourceStream(Name)
            let reader = new BinaryReader(stream)
            select new CStaticFile()
                  {
                      FileName = name.Substring(ns.Length + 1),
                      Data = reader.ReadBytes((int) stream.Length)
                  }
          ).ToArray();
}
Stefan Rusek Send private email
Sunday, May 3, 2009
 
 
Another approach which might require even less changes to FB, would be to allow the static content methods to return special resource urls, like so:

return new[] { "resource://KanbanBoard/static/js/loadmenu.js" };

This I think might be my preferred solution, since it would probably involve the least coding for me and for you.
Stefan Rusek Send private email
Sunday, May 3, 2009
 
 
The url string in my previous post probably should have been:

"resource://KanbanBoard.static.js.loadmenu.js"
Stefan Rusek Send private email
Sunday, May 3, 2009
 
 
Good suggestions.  I've opened a case.
David Fullerton Send private email
Monday, May 4, 2009
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz