Modular Program using Config files [closed] - c#

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 8 years ago.
Improve this question
I'm being tasked with making a modular program that uses external, easy to edit files to dictate if certain elements are shown, what classes are used, etc.
Using C# and Visual Studio 2008, what type of file should I use? I was suggested .ini, but there is also talk of using .xml for it?
Which file would be best, and is there a built-in C# method of working with those files?

There's a heap of different ways for achieving different things. You could for example use an appSetting in an app.config file to turn features on and off. If you wanted to change classes or services that are used, then you could use DI/IoC with something like Castle Windsor and configure that in code and or xml.
If you can be more specific with what you want to achieve, and some examples in code, you can probably get some better answers.

you can use custom sections in your config files.
Config files are xml, well known files in .net context.
See example here: http://msdn.microsoft.com/en-us/library/vstudio/2tw134k3(v=vs.100).aspx

Related

How to compile one project's code from another project [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 months ago.
Improve this question
I'm working on a project that contains 2 C# solution projects, the first solution includes a design that is supposed to be an EXE Builder and the second solution project is the one I want to be built using the first solution.
I want to build the second project's EXE file using the first solution while editing some values (Resources or strings whatever is better) in the Second solution that will be compiled.
I'm not sure how to do that there are no tutorials for this, the essential thing is that I want to make an EXE Builder while at the same time editing some settings in it without having to rely on other external files.
The concept is quite similar to Remote Access Tools Builder, but what I'm building is an obfuscator & encryptor

What is the proper way to pass config/parameters to class library? [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 5 years ago.
Improve this question
I'm creating a class library that is meant to be used by a lot of different clients. I want it to be configureable, for example I want to be able to specify the path for temporary files of the library in the client.
I'm wondering what is the 'correct' way to do that? Is there a way to read(inherit) client's appconfig from class library? Should it be passed by dependency injection? The easiest solution would be to pass it by parameter, but then my library would have to pass it around or store in a static variable, but it's not a very clean solution...
Is there a way to read(inherit) client's appconfig from class library?
If you use the normal method of reading Configuration from .config or appsettings in your library, it will automatically take the .config or appsettings file for the application it is used in.
Please be advised that this will make it less transparent to use the library, since it needs specific configuration items to work (properly). I would make sure it has default values for all settings you might want to put in configuration.

Project naming conventions: [Company].[ProjectName] vs [Company_ProjectName] [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 6 years ago.
Improve this question
Is it good practice to name preface project names within a solution like so?
CompanyName.P01
CompanyName.P02
CompanyName.P03
Or is it safer to use a convention like this?
CompanyName_P01
CompanyName_P02
CompanyName_P03
To me, the [.] separator looks nicer, and provides intellisense, but is there any caveat to using it?
Most of the solutions I came across follow the following convention:
CompanyName.SolutionName.LayerName
So basically in a company named COMP and a Project Named StackOverflow, you would end up with a project that looks like this:
COMP.StackOverflow.Business
COMP.StackOverflow.Data
COMP.StackOverflow.Web
COMP.StackOverflow.Core
This allows you to easily manage the generated assembly, so if you need to create a common library to be used in your company. You would name it:
COMP.SomeFrameworkName;
That would easily seperate your company's (or Team's) Dlls from external Dlls and Nuget Packages.

Working with Windows Registry from .NET [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 8 years ago.
Improve this question
my .net app needs to store some persistent data and since it is possible that it runs in an environment where it cant write to disk, i would like to use the registry for it.
are there any conventions about the path where an application is writing to?
are there any tools or libraries that make reading and writing the registry from .net more convenient? i need to mostly write simple datatypes and datastructures like lists.
any other best practices or tips & tricks that should be know when working with the registry?
Writing to the registry is a little frowned on nowadays, however if you must:
Put settings for the current user in: HKEY_CURRENT_USER\Software\Your Company\Your App
Put settings for all users in: HKEY_LOCAL_MACHINE\Software\Your Company\Your App
Use the Registry class in the .NET framework to read and write registry keys and values:
http://msdn.microsoft.com/en-us/library/microsoft.win32.registry(v=vs.110).aspx

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 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.

Categories

Resources