本文整理汇总了C#中IConfig.Set方法的典型用法代码示例。如果您正苦于以下问题:C# IConfig.Set方法的具体用法?C# IConfig.Set怎么用?C# IConfig.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IConfig
的用法示例。
在下文中一共展示了IConfig.Set方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Save
public EReturn Save(IConfig config)
{
if (config != null)
{
config.Set("Text", Text);
config.Set("Autor", Autor);
return EReturn.NoError;
}
else return EReturn.Error;
}
示例2: RemoveConfigKeys
/// <summary>
/// Removes all XML keys that were removed as config keys.
/// </summary>
private void RemoveConfigKeys(IConfig config)
{
XmlNode section = GetChildElement (config.Name);
// Remove old keys
string[] configKeys = config.GetKeys ();
foreach (string configKey in configKeys)
{
if (GetKey (section, configKey) == null) {
// Key doesn't exist, remove
config.Remove (configKey);
}
}
// Add or set all new keys
foreach (XmlNode node in section.ChildNodes)
{
if (node.NodeType == XmlNodeType.Element
&& node.Name == "add") {
config.Set (node.Attributes["key"].Value,
node.Attributes["value"].Value);
}
}
}
示例3: RemoveConfigKeys
/// <summary>
/// Removes all INI keys that were removed as config keys.
/// </summary>
private void RemoveConfigKeys (IConfig config)
{
IniSection section = iniDocument.Sections[config.Name];
// Remove old keys
string[] configKeys = config.GetKeys ();
foreach (string configKey in configKeys)
{
if (!section.Contains (configKey)) {
// Key doesn't exist, remove
config.Remove (configKey);
}
}
// Add or set all new keys
string[] keys = section.GetKeys ();
for (int i = 0; i < keys.Length; i++)
{
string key = keys[i];
config.Set (key, section.GetItem (i).Value);
}
}
示例4: Expand
/// <summary>
/// Expands key values from the given IConfig.
/// </summary>
private string Expand (IConfig config, string key, bool setValue)
{
string result = config.Get (key);
if (result == null) {
throw new ArgumentException (String.Format ("[{0}] not found in [{1}]",
key, config.Name));
}
while (true)
{
int startIndex = result.IndexOf ("${", 0);
if (startIndex == -1) {
break;
}
int endIndex = result.IndexOf ("}", startIndex + 2);
if (endIndex == -1) {
break;
}
string search = result.Substring (startIndex + 2,
endIndex - (startIndex + 2));
if (search == key) {
// Prevent infinite recursion
throw new ArgumentException
("Key cannot have a expand value of itself: " + key);
}
string replace = ExpandValue (config, search);
result = result.Replace("${" + search + "}", replace);
}
if (setValue) {
config.Set(key, result);
}
return result;
}
示例5: RemoveConfigKeys
/// <summary>
/// Removes all XML keys that were removed as config keys.
/// </summary>
private void RemoveConfigKeys(IConfig config)
{
XmlNode section = GetSectionByName (config.Name);
// Remove old keys
string[] configKeys = config.GetKeys ();
foreach (string configKey in configKeys)
{
if (GetKeyByName (section, configKey) == null) {
// Key doesn't exist, remove
config.Remove (configKey);
}
}
// Add or set all new keys
foreach (XmlNode node in section.ChildNodes)
{
// Loop through all key nodes and add to config
if (node.NodeType == XmlNodeType.Element
&& node.Name == "Key") {
config.Set (node.Attributes["Name"].Value,
node.Attributes["Value"].Value);
}
}
}
示例6: WriteDapToConfig
public static void WriteDapToConfig(DAuthorProperties dap, IConfig config)
{
config.Set(FILL_OPT, DColor.FormatToString(dap.Fill));
config.Set(STROKE_OPT, DColor.FormatToString(dap.Stroke));
config.Set(STROKEWIDTH_OPT, dap.StrokeWidth);
config.Set(STROKESTYLE_OPT, dap.StrokeStyle.ToString());
config.Set(ALPHA_OPT, dap.Alpha);
config.Set(STARTMARKER_OPT, dap.StartMarker);
config.Set(ENDMARKER_OPT, dap.EndMarker);
config.Set(FONTNAME_OPT, dap.FontName);
config.Set(BOLD_OPT, dap.Bold);
config.Set(ITALICS_OPT, dap.Italics);
config.Set(UNDERLINE_OPT, dap.Underline);
config.Set(STRIKETHROUGH_OPT, dap.Strikethrough);
}
示例7: Save
public virtual EReturn Save(IConfig config)
{
//IConfig config = source.AddConfig("Karta");
if (config != null)
{
config.Set("ID", Id);
config.Set("Jmeno", Jmeno);
config.Set("Popis", Popis);
config.Set("Sfera", (int)Sfera);
config.Set("Typ", (int)Typ);
string s = "";
foreach (MyString ss in Druh)
if (s == "") s = ss.String;
else s = s + "," + ss.String;
config.Set("Druh", s);
s = "";
foreach (MyString ss in Reakce)
if (s == "") s = ss.String;
else s = s + "," + ss.String;
config.Set("Reakce", s);
config.Set("Text", Text);
config.Set("Autor", Autor);
config.Set("Kvalita", Kvalita);
return EReturn.NoError;
}
else return EReturn.Error;
}
示例8: Replace
/// <summary>
/// Recursively replaces text.
/// </summary>
private void Replace(IConfig config, string key)
{
string text = config.Get (key);
if (text == null) {
throw new Exception (String.Format ("[{0}] not found in [{1}]",
key, config.Name));
}
int startIndex = text.IndexOf ("${", 0);
if (startIndex != -1) {
int endIndex = text.IndexOf ("}");
if (endIndex != -1) {
string search = text.Substring (startIndex + 2,
endIndex - (startIndex + 2));
string replace = ReplaceValue (config, search);
// Assemble the result string
StringBuilder builder = new StringBuilder ();
for (int i = 0; i < startIndex; i++)
{
builder.Append (text[i]);
}
builder.Append (replace);
for (int i = endIndex + 1; i < text.Length; i++)
{
builder.Append (text[i]);
}
config.Set (key, builder.ToString ());
Replace (config, key); // recurse
}
}
}