u can use configuration file to store user settings.
also create custom ConfigManager which handles the configuration file and provides settings to either projects.
the idea is to have all the settings related code in one class (dll) and reference it from either projects.
u can create custom sections as well and provide objects which reflects the data in those custom sections
assume the following config file:
configuration>
<configSections>
<section name="InternalConfiguratio
CustomConfigSection, version=1.0.0.0, Culture=neutral, PublicKeyToken=8bcec9130f8
</configSections>
<InternalConfiguration>
<Data>
<Source name="1.txt">
<Dest name="2.txt">
</Data>
</InternalConfiguration>
<appSettings>
<add key ="DiskSpace" value="1.0" /><!--GB-->
</appSettings>
</configuration>
the InternalConfiguration is your custom section wraper class which looks like this:
public class InternalConfiguration:Conf
{
[ConfigurationProperty("Da
public DataElement Data
{
get { return (DataElement)base["Data"];
}
}
public class DataElement:ConfigurationE
{
public DataElementEntry Data
{
get { return (DataElementEntry )base["Source"]; }
}
public DataElementEntry Data
{
get { return (DataElementEntry )base["Dest"]; }
}
}
public class DataElementEntry :ConfigurationElement
{
[ConfigurationProperty("na
public string Name
{
get { return (string)base["name"]; }
}
}
the configuration manager sould look something like this:
public class ConfigManager
{
Configuration _config = null;
//ctor - loads your own configuraion file
public ConfigManager(string configFile)
{
_config = ConfigurationManager.OpenM
}
//ctor - loads the project app.config
public ConfigManager()
{
_config = ConfigurationManager.OpenM
}
public AppSettingsSection AppSettings
{
get { return _config.AppSettings; }
}
public ConnectionStringsSection AppSettings
{
get { return _config.ConnectionStrings;
}
public ConfigurationSection GetCustomSection(string section)
{
return _config.GetSection(section
}
}
Main Topics
Browse All Topics





by: ivostoykovPosted on 2009-10-29 at 00:46:14ID: 25691313
Look here it might be useful...
HTH
Ivo Stoykov