473,466 Members | 1,389 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Shipping configuration parameters along a library

I am currently implementing a scientific library in C#. The algorithms
include some system dependent tuning parameters (lets say memory vs. speed
parameters for example). Since, those parameters are quite numerous, it
would be cumbersome for the client of the library to be forced to provide
explicit values for all those parameters. Also, default parameters should be
provided by the library itself. But I would rather not "hard code" such
parameters. I think, a good solution would be somehow to ship a (XML)
configuration file along the library. This way, the default performance of
the library could still be tuned after compilation.

To do this, there are a lot of dirty home-made solutions. But I think, this
issue should have some classical solutions (using System.Resource or
System.Configuration ???). Does someone have a convenient solution for this
problem ?

Thank you for the help,
Joannes Vermorel
Nov 15 '05 #1
2 1438
Place your configuration settings into their own class, and you can use
XMLSerializer (described in Visual Studio Help) to read and write an object
of the class to an XML file.

Give your class a constructor that initialises the default settings. That
way, you can easily use these if the XML file doesn't exist.

Here's a simple example of the class to be serialised. (In production code,
you'd probably want to use properties instead of public variables.)

[Serializable]
public class MySettings
{
public bool bFavourSpeedOverSize;
public bool bOptimiseForSomeProcessor;

public MySettings()
{
this.SetDefaults();
}

public void SetDefaults()
{
bFavourSpeedOverSize = true;
bOptimiseForSomeProcessor = false;
}
}

P.

--
www.CL4.org
Nov 15 '05 #2
Place your configuration settings into their own class, and you can use
XMLSerializer (described in Visual Studio Help) to read and write an object
of the class to an XML file.

Give your class a constructor that initialises the default settings. That
way, you can easily use these if the XML file doesn't exist.

Here's a simple example of the class to be serialised. (In production code,
you'd probably want to use properties instead of public variables.)

[Serializable]
public class MySettings
{
public bool bFavourSpeedOverSize;
public bool bOptimiseForSomeProcessor;

public MySettings()
{
this.SetDefaults();
}

public void SetDefaults()
{
bFavourSpeedOverSize = true;
bOptimiseForSomeProcessor = false;
}
}

P.

--
www.CL4.org
Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: InProcess | last post by:
We have successfully implemented Log Shipping between two MS SQL Server 2000 servers (bothe SP3). The problem we are having is two fold: 1) The tran log on the primary server is not being truncated...
3
by: GB | last post by:
Are all database configuration parameters included in the database backup or not ? If I restore the database from the backup are these restored also ? What is the best way to backup and restore...
2
by: Fred | last post by:
Hi. Sorry, but I don't know where else to ask. I wrote a access shipping database and we currently use the web interface for DHL to print shipping labels. That means we have to manualy transpose...
0
by: Joannes Vermorel | last post by:
I am currently implementing a scientific library in C#. The algorithms include some system dependent tuning parameters (lets say memory vs. speed parameters for example). Since, those parameters...
2
by: Patrick | last post by:
I am using the Microsoft enterprise Library (June 2005) with .NET Framework 1.1 on a Windows 2003 IIS6 web server. with an ASP.NET 1.1 application, I have a dataConfiguration.config as listed at...
18
by: John Friedland | last post by:
My problem: I need to call (from C code) an arbitrary C library function, but I don't know until runtime what the function name is, how many parameters are required, and what the parameters are. I...
4
by: Michael Lang | last post by:
I was basically wanting to know how to use the System.Configuration namespace to be able to load an arbitrary number of unknown attributes on an element in a custom section in the .config into a...
7
by: Peter Bradley | last post by:
OK. A bit behind the times, I know; but we're just moving over to .NET 2.0. How on earth do you manage configuration settings in a class library in .NET 2.0? In version 1.1, we used a handy class...
7
by: =?Utf-8?B?U3RlcGhhbmVWYXJpbg==?= | last post by:
Hi all, For some reasons, we've had to move away from the configuration files and are now storing all the configuration parameters for our applications in a SQL table. We have developped a...
1
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...
0
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...
0
Oralloy
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,...
0
jinu1996
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.