开发者

Sharing xml and data between multiple projects [closed]

Closed. This question is opinion-based. It is not currently accepting answers.

Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.

Closed 4 years ago.

Improve this question

I have three projects(C# libraries) namely A,B,C.

All the 3 have 3-4 xml files(in general can be resources) associated with them.

Each of these projects have classes that access these files for settings and information. (loading xmls when ever they need)

The problems is sometimes there is a need that a class in project C may need to access resources(xml files,images etc) of project B and vice versa.

Also these files may or may not be a part of the project solution.These resource paths can come from app.config etc.

Its really becoming tedious to work out how to centralise开发者_如何学JAVA access to these resources so that all three projects can access them uniformly.

Currently all the projects load the files using app.config.

Also i'm trying to minimise the number of times a xml is loaded.(ideally once). But given the projects are different i have to load it again.

I thought of using a Singleton class as it would make more sense for making uniform access but haven't quiet figured out a way.

Anyone has come across similar situations?

Are there any design patterns or best practices for sharing resources across projects?


Create one library containing the class(es) that access your centralized XML settings, and reference that library from the other libraries.

You don't necessarily need a Singleton for this, but putting it in one place will allow you to focus your efforts on things to improve it later, possibly caching, etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜