/// <summary> /// A shortcut to node.NonNull(nameof(node)).AttrByName(attrName); If the first named attribute does not exist then the second is tried /// </summary> public static IConfigAttrNode Of(this IConfigSectionNode node, string attrName1, string attrName2) { var attr = node.NonNull(nameof(node)).AttrByName(attrName1); if (attr.Exists) { return(attr); } return(node.AttrByName(attrName2)); }
/// <summary> Makes entity with descriptive error </summary> protected virtual T Make <T>(IConfigSectionNode parent, string section) where T : IConfigurable { try { return(FactoryUtils.MakeAndConfigure <T>(parent.NonNull(nameof(parent))[section.NonBlank(nameof(section))])); } catch (ConfigException error) { throw new ScriptingException("Expression `{0}` declaration error while trying to make `{1}` around: ... {2} ...".Args(GetType().Name, section, parent.ToLaconicString(CodeAnalysis.Laconfig.LaconfigWritingOptions.Compact)), error); } }
public VarDef(IConfigSectionNode node) : this(node.NonNull(text : "VarDef.ctor(node==null)").AttrByName(Configuration.CONFIG_NAME_ATTR).Value) { ConfigAttribute.Apply(this, node); }
public VarDef(IConfigSectionNode node) : this(node.NonNull(text: "VarDef.ctor(node==null)").AttrByName(Configuration.CONFIG_NAME_ATTR).Value) { ConfigAttribute.Apply(this, node); }
public LangInfo(IConfigSectionNode cfg) : this( Atom.Encode(cfg.NonNull(nameof(cfg)).AttrByName(nameof(ISO)).Value.NonBlank(nameof(ISO))),//throws on bad atom cfg.NonNull(nameof(cfg)).AttrByName(nameof(Name)).Value) { }
/// <summary> /// Returns enumerable of LangInfo structures made of "lang-info" config sections /// </summary> public static IEnumerable <LangInfo> MakeManyFromConfig(IConfigSectionNode cfg) => cfg.NonNull(nameof(cfg)) .Children .Where(c => c.IsSameName(CONFIG_LANG_INFO_SECTION)) .Select(c => new LangInfo(c)) .ToArray();
public LangInfo(IConfigSectionNode cfg) : this( cfg.NonNull(nameof(cfg)).AttrByName(nameof(ISO)).Value, cfg.NonNull(nameof(cfg)).AttrByName(nameof(Name)).Value) { }
public AccessLevel(User user, Permission permission, IConfigSectionNode data) { m_User = user.NonNull(nameof(user)); m_Permission = permission.NonNull(nameof(permission)); m_Data = data.NonNull(nameof(data)); }
/// <summary> /// A shortcut to node.NonNull(nameof(node)).AttrByName(attrName); You can retrieve section by name using indexer /// </summary> public static IConfigAttrNode Of(this IConfigSectionNode node, string attrName) => node.NonNull(nameof(node)).AttrByName(attrName);
public void Configure(IConfigSectionNode node) { node.NonNull(nameof(node)); ConfigAttribute.Apply(this, node); m_ResolvedNode = node.Configuration.Application.GetMetabase().ResolveNetworkService(Host, Network, Service, Binding); }