Building a large app where we want to be able to ship updated icons like
patches/assign different "skins", etc.
So, I'm looking at storing sets of related icons in assemblies that will be
loaded dynamically.
Some questions:
What's the "best practices" way to load an assembly where its only purpose
is to provide resources?
In my simplistic view, I would just do something like this:
{
Assembly theAssembly = Assembly.LoadFile(theFileName);
Image theImage =
Image.FromStream(theAssembly.GetManifestResourceSt ream(resourceID));
}
Now, I'm not looking for the "quick fix" here, this needs to be durable and
enterprise-grade. Is there somewhere else that I should be looking?
I thought about the resource manager, but it seems to be all about
internationalization, and that's not really what I'm trying to solve here. 4 1758
J.Marsch <jm*****@newsgroup.nospam> wrote: Building a large app where we want to be able to ship updated icons like patches/assign different "skins", etc.
So, I'm looking at storing sets of related icons in assemblies that will be loaded dynamically.
Some questions:
What's the "best practices" way to load an assembly where its only purpose is to provide resources?
In my simplistic view, I would just do something like this: { Assembly theAssembly = Assembly.LoadFile(theFileName); Image theImage = Image.FromStream(theAssembly.GetManifestResourceSt ream(resourceID)); }
Now, I'm not looking for the "quick fix" here, this needs to be durable and enterprise-grade. Is there somewhere else that I should be looking?
I thought about the resource manager, but it seems to be all about internationalization, and that's not really what I'm trying to solve here.
One way to make things simpler might be to include a single type in the
resource assembly - that way you can make sure the assembly is loaded
(and get a reference to the Assembly object) just by using
typeof(TypeInResourceAssembly) (etc).
Now, if you've already got a type within the assembly, you could make
that some kind of ImageManager type which is able to load the resources
requested and return images directly.
Does that help at all?
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Actually, yes that does help. I still think that I am going to have to load
the assembly dynamically, but it might be handy to have a manager sitting in
there to help with pulling out the resources -- I'll have to noodle on that
a bit.
Oh, and here's why I _think_ I need to do dynamic loads (I'm not dead-set on
that idea yet):
These icons might change as a result of a user preference. For example:
today maybe the set of icons in the assembly supports the "blue" XP look.
Maybe next week, we ship a download that supports the "silver" XP theme, and
maybe next year we toss one out that is more appropriate to Longhorn.
Even that is a simplification. There is a specific type of partition (think
of it as a business entity) in this system, and the user can associate
different color schemes with different entities. As they move from entity
to entity, the application will change in obvious ways (different large
icons and headings), and subtly (different accent colors and tree icons,
etc).
So these resource assemblies are sort of like extensions, or plug-ins but
they do not offer code, just alternate resources. In some ways, that is
kind of like internationalization; it's just that the selection of the
resource set is not tied to culture.
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om... J.Marsch <jm*****@newsgroup.nospam> wrote: Building a large app where we want to be able to ship updated icons like patches/assign different "skins", etc.
So, I'm looking at storing sets of related icons in assemblies that will be loaded dynamically.
Some questions:
What's the "best practices" way to load an assembly where its only purpose is to provide resources?
In my simplistic view, I would just do something like this: { Assembly theAssembly = Assembly.LoadFile(theFileName); Image theImage = Image.FromStream(theAssembly.GetManifestResourceSt ream(resourceID)); }
Now, I'm not looking for the "quick fix" here, this needs to be durable and enterprise-grade. Is there somewhere else that I should be looking?
I thought about the resource manager, but it seems to be all about internationalization, and that's not really what I'm trying to solve here.
One way to make things simpler might be to include a single type in the resource assembly - that way you can make sure the assembly is loaded (and get a reference to the Assembly object) just by using typeof(TypeInResourceAssembly) (etc).
Now, if you've already got a type within the assembly, you could make that some kind of ImageManager type which is able to load the resources requested and return images directly.
Does that help at all?
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
J.Marsch <jm*****@newsgroup.nospam> wrote: Actually, yes that does help. I still think that I am going to have to load the assembly dynamically, but it might be handy to have a manager sitting in there to help with pulling out the resources -- I'll have to noodle on that a bit.
Oh, and here's why I _think_ I need to do dynamic loads (I'm not dead-set on that idea yet):
These icons might change as a result of a user preference. For example: today maybe the set of icons in the assembly supports the "blue" XP look. Maybe next week, we ship a download that supports the "silver" XP theme, and maybe next year we toss one out that is more appropriate to Longhorn.
Even that is a simplification. There is a specific type of partition (think of it as a business entity) in this system, and the user can associate different color schemes with different entities. As they move from entity to entity, the application will change in obvious ways (different large icons and headings), and subtly (different accent colors and tree icons, etc).
So these resource assemblies are sort of like extensions, or plug-ins but they do not offer code, just alternate resources. In some ways, that is kind of like internationalization; it's just that the selection of the resource set is not tied to culture.
Right. That seems pretty reasonable, yes. You may want to think about
organising your resources in the same way as for cultures, with a
hierarchy (which in your case may be arbitrarily deep). So, for
instance, you might have:
MyResources
MyResources-Windows
MyResources-Windows-XP
MyResources-Windows-XP-Silver
MyResources-Windows-XP-Blue
MyResources-Windows-Longhorn
MyResources-Linux
MyResources-Linux-Gnome
MyResources-Linux-KDE
with each deferring requests for any unfound resources to its "parent".
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Yes, that makes sense. Thank you for the commentary, Jon.
-- Jeremy
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om... J.Marsch <jm*****@newsgroup.nospam> wrote: Actually, yes that does help. I still think that I am going to have to load the assembly dynamically, but it might be handy to have a manager sitting in there to help with pulling out the resources -- I'll have to noodle on that a bit.
Oh, and here's why I _think_ I need to do dynamic loads (I'm not dead-set on that idea yet):
These icons might change as a result of a user preference. For example: today maybe the set of icons in the assembly supports the "blue" XP look. Maybe next week, we ship a download that supports the "silver" XP theme, and maybe next year we toss one out that is more appropriate to Longhorn.
Even that is a simplification. There is a specific type of partition (think of it as a business entity) in this system, and the user can associate different color schemes with different entities. As they move from entity to entity, the application will change in obvious ways (different large icons and headings), and subtly (different accent colors and tree icons, etc).
So these resource assemblies are sort of like extensions, or plug-ins but they do not offer code, just alternate resources. In some ways, that is kind of like internationalization; it's just that the selection of the resource set is not tied to culture.
Right. That seems pretty reasonable, yes. You may want to think about organising your resources in the same way as for cultures, with a hierarchy (which in your case may be arbitrarily deep). So, for instance, you might have:
MyResources MyResources-Windows MyResources-Windows-XP MyResources-Windows-XP-Silver MyResources-Windows-XP-Blue MyResources-Windows-Longhorn MyResources-Linux MyResources-Linux-Gnome MyResources-Linux-KDE
with each deferring requests for any unfound resources to its "parent".
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Adrian MacNair |
last post by:
Hi,
I created an image gallery which displays 63 images in a slideshow. The
problem is that the show was slow because each image loaded one at a time
during the show. No problem right? I just...
|
by: D. Yates |
last post by:
Hi,
I am looking for an example of how to extract bitmap images from an embedded
resource file (a file with *.res extension, which can be viewed inside of
the ide and can hold bitmaps, icons,...
|
by: Novice |
last post by:
I'm afraid I will incur the wraith of Mr. Powell on this one - but I did read
his #1 FAQ and some others and I still can't figure this out.
I created this little c# app. and I have a PictureBox...
|
by: Joshua Kendall |
last post by:
I have a splash screen that is set to a timer. When the
timer reaches it's Interval of 1000, I want it to load
the next form in my project. My brother knows VB6 from
school but can't figure out...
|
by: Joshua Kendall |
last post by:
I need to know the code to load another form. In vb6 it's
simply "load" what is it in dotnet?
Anyway here's my code:
Public Class Splash
Inherits System.Windows.Forms.Form
#Region "...
|
by: Ivan Sammut |
last post by:
Hi,
Anyone can give me an example on how to load a bitmap from resource.
Thanks
Ivan
|
by: Chris Tomlinson |
last post by:
Hi, is there any way to specify the sequence in which images load on a web
page?
More specifically, here is what we need to achieve:
Image1 starts loading first and the browser does not...
|
by: MsNews |
last post by:
Hi,
I'm creating a free Icon library in C# with source code include, it already
support .ico/.dll../exe and I'd like to support .ICL format too, I need to
load a file .ICL (Icon Library) that...
|
by: speedcoder |
last post by:
hi all,
i'm stumped. my applet used to load images over the network. (it was actually designed by someone else.) yes, the applet used to load each image file independently over the network and...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |