本文整理汇总了C#中Properties.Store方法的典型用法代码示例。如果您正苦于以下问题:C# Properties.Store方法的具体用法?C# Properties.Store怎么用?C# Properties.Store使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Properties
的用法示例。
在下文中一共展示了Properties.Store方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveFrom
public void SaveFrom(IConfiguration config, ConfigurationLevel level, Stream outputStream)
{
try {
var keys = config.GetKeys(level);
var properties = new Properties();
foreach (var configKey in keys) {
var configValue = config.GetValue(configKey);
object value;
if (configValue == null || configValue.Value == null) {
value = configKey.DefaultValue;
} else {
value = configValue.Value;
}
var stringValue = Convert.ToString(value, CultureInfo.InvariantCulture);
properties.SetProperty(configKey.Name, stringValue);
}
properties.Store(outputStream, String.Empty);
} catch (DatabaseConfigurationException) {
throw;
} catch (Exception ex) {
throw new DatabaseConfigurationException("Could not save the configurations to the given stream.", ex);
}
}
示例2: OnManagersClear
protected override void OnManagersClear()
{
// Write the manager server address to the properties file,
Properties p = new Properties();
p.SetProperty("manager_server_address", "");
// Contains the root properties,
string propFile = Path.Combine(path, "00.properties");
FileStream fout = new FileStream(propFile, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None);
p.Store(fout, null);
fout.Close();
}
示例3: OnManagersSet
protected override void OnManagersSet(IServiceAddress[] addresses)
{
StringBuilder b = new StringBuilder();
for (int i = 0; i < addresses.Length; ++i) {
b.Append(addresses[i].ToString());
if (i < addresses.Length - 1) {
b.Append(",");
}
}
// Write the manager server address to the properties file,
Properties p = new Properties();
p.SetProperty("manager_server_address", b.ToString());
// Contains the root properties,
string propFile = Path.Combine(path, "00.properties");
FileStream fout = new FileStream(propFile, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None);
p.Store(fout, null);
fout.Close();
base.OnManagersSet(addresses);
}
示例4: OnUnbindingWithManager
protected override void OnUnbindingWithManager(IServiceAddress managerAddress)
{
// Contains the root properties,
string propFile = Path.Combine(basePath, "00.properties");
using (FileStream fileStream = new FileStream(propFile, FileMode.OpenOrCreate, FileAccess.ReadWrite)) {
// Write the manager server address to the properties file,
Properties p = new Properties();
if (fileStream.Length > 0)
p.Load(fileStream);
p.Remove("manager_address");
fileStream.SetLength(0);
p.Store(fileStream, null);
fileStream.Close();
}
}