Пример #1
0
        /// <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));
        }
Пример #2
0
 /// <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);
     }
 }
Пример #3
0
 public VarDef(IConfigSectionNode node)
     : this(node.NonNull(text : "VarDef.ctor(node==null)").AttrByName(Configuration.CONFIG_NAME_ATTR).Value)
 {
     ConfigAttribute.Apply(this, node);
 }
Пример #4
0
 public VarDef(IConfigSectionNode node)
     : this(node.NonNull(text: "VarDef.ctor(node==null)").AttrByName(Configuration.CONFIG_NAME_ATTR).Value)
 {
     ConfigAttribute.Apply(this, node);
 }
Пример #5
0
 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)
 {
 }
Пример #6
0
 /// <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();
Пример #7
0
 public LangInfo(IConfigSectionNode cfg) : this(
         cfg.NonNull(nameof(cfg)).AttrByName(nameof(ISO)).Value,
         cfg.NonNull(nameof(cfg)).AttrByName(nameof(Name)).Value)
 {
 }
Пример #8
0
 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));
 }
Пример #9
0
 /// <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);
Пример #10
0
 public void Configure(IConfigSectionNode node)
 {
     node.NonNull(nameof(node));
     ConfigAttribute.Apply(this, node);
     m_ResolvedNode = node.Configuration.Application.GetMetabase().ResolveNetworkService(Host, Network, Service, Binding);
 }