本文整理汇总了C#中IConfig.RootOf方法的典型用法代码示例。如果您正苦于以下问题:C# IConfig.RootOf方法的具体用法?C# IConfig.RootOf怎么用?C# IConfig.RootOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IConfig
的用法示例。
在下文中一共展示了IConfig.RootOf方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
/// <summary>
/// Finds the commands specified in the config file and invokes them with the specified attributes.
/// </summary>
/// <param name="command"></param>
/// <param name="config"></param>
/// <param name="password">The password to decrypt encrypted config commands</param>
protected void Execute(ICommand command, IConfig config, String password = null) {
if (config != null && config.Root != null) {
foreach (var loadedConfigCommand in config.RootOf(this.GetType()).Children<JObject>().Select(item => item.ToObject<ConfigCommand>(JsonSerialization.Minimal)).Where(item => item != null)) {
// only attempt a decrypt if we've been given a password. If we don't have a password, we won't bother
// and the command will have a null Command and be skipped anyway.
if (password != null) {
loadedConfigCommand.Decrypt(password);
}
var loadedCommand = loadedConfigCommand.Command;
if (loadedCommand != null && loadedCommand.Name != null) {
command.ParseCommandType(loadedCommand.Name);
command.Parameters = loadedCommand.Parameters;
command.Scope = loadedCommand.Scope;
this.Tunnel(command);
}
}
}
}