本文整理汇总了C#中IRule.saveToDisk方法的典型用法代码示例。如果您正苦于以下问题:C# IRule.saveToDisk方法的具体用法?C# IRule.saveToDisk怎么用?C# IRule.saveToDisk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRule
的用法示例。
在下文中一共展示了IRule.saveToDisk方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: saveRule
public void saveRule(IRule save)
{
save.saveToDisk(_rulesPath);
lock (_ruleLock)
{
if (_ruleList == null)
_ruleList = new List<IRule>(1);
_ruleList.Add(save);
}
}
示例2: changeRuleName
public void changeRuleName(IRule save, string newName)
{
string newRulePath = _rulesPath + newName + RULE_EXT;
if (File.Exists(newRulePath))
throw new IOException(newName + " already exists!");
// if the rule was saved to disk we delete the old file name and recreate it else we just rename the object in memory
string oldName = save.name;
string oldRulePath = _rulesPath + oldName + RULE_EXT;
save.name = newName;
try
{
if (File.Exists(oldRulePath))
{
File.Delete(oldRulePath);
save.saveToDisk(newRulePath);
}
} // if for some reason this fails we roll back to the previous state
catch (Exception)
{
save.name = oldName;
if (File.Exists(newRulePath))
{
File.Delete(newRulePath);
if (!File.Exists(oldRulePath))
save.saveToDisk(oldRulePath);
}
throw;
}
}