Source/NFX/Environment/ConfigNode.cs
/// <summary>
/// Replaces all include pragmas - sections with specified names ('_include' by default), with pointed to configuration file content
/// as obtained via the call to file system specified in every pragma.
/// If no FS specified then LocalFileSystem is used. If no file name specified when try to allocate config node provider.
/// Returns true if include pragmas were found.
/// Note: this method does not process new include pragmas that may have fetched during this call.
/// Caution: the file system used in the operation may rely on the App container that may need to be set-up for the call to succeed,
/// therefore calling this method before app has activated may fail, in such cases a temp app container may be set to get the config file
///  with processed includes, then the result may be passed to the primary app container ctor.
/// This call is not logically thread-safe, it must be called from the main thread in the app
/// </summary>
/// <param name="recurse">True to process inner nodes</param>
/// <param name="includePragma">Pragma section name, '_include' by default</param>
/// <returns>True if pragmas were found</returns>
/// <example>
///  nfx
///  {
///    sectionA{ a=2 b=3}
///    _include
///    {
///      name=secret // '_include' will be replaced by 'secret' with sub-nodes from referenced file
///      file="/etc/cluster/mysecret.laconf" //would come from local FS
///      required=false //if file is not found then nothing will be included instead of '_include' which will be just removed
///    }
///    _include
///    {
///      // '_include' will be replaced by whatever root section content in the referenced file
///      fs {type="NFX.Web.IO.FileSystem.SVNFileSystem, NFX.Web"}
///      session { server-url="https://myhost.com/mySvnRepo/trunk/configs" user-name="user1" user-password="******"}
///    }
///  }
/// </example>
Replaces all include pragmas - sections with specified names ('_include' by default), with pointed to configuration file content
as obtained via the call to file system specified in every pragma.
If no FS specified then LocalFileSystem is used. If no file name specified when try to allocate config node provider.
Returns true if include pragmas were found.
Note: this method does not process new include pragmas that may have fetched during this call.
Caution: the file system used in the operation may rely on the App container that may need to be set-up for the call to succeed,
therefore calling this method before app has activated may fail, in such cases a temp app container may be set to get the config file
with processed includes, then the result may be passed to the primary app container ctor.
This call is not logically thread-safe, it must be called from the main thread in the app
Replaces all include pragmas - sections with specified names ( ' _include ' by default ) with pointed to configuration file content as obtained via the call to file system specified in every pragma . If no FS specified then LocalFileSystem is used . If no file name specified when try to allocate config node provider . Returns true if include pragmas were found . Note : this method does not process new include pragmas that may have fetched during this call . Caution : the file system used in the operation may rely on the App container that may need to be set - up for the call to succeed therefore calling this method before app has activated may fail in such cases a temp app container may be set to get the config file with processed includes then the result may be passed to the primary app container ctor . This call is not logically thread - safe it must be called from the main thread in the app
public bool ProcessIncludePragmas(bool recurse, string includePragma = null)
        {
          if (includePragma.IsNullOrWhiteSpace())
            includePragma = Configuration.DEFAULT_CONFIG_INCLUDE_PRAGMA;
          var result = false;
          checkCanModify();
          foreach(var child in Children)
          {
            if (child.IsSameName(includePragma))
            {
              var included = getIncludedNode(child);
              if (included!=null)
              {
                child.include( included );
                result = true;
              }
              else
                child.Delete();
              continue;
            }
            if (recurse)
             result |= child.ProcessIncludePragmas(recurse, includePragma);
          }
          return result;
        }
public bool ProcessIncludePragmas ( bool recurse , string includePragma = null ) { if ( includePragma . IsNullOrWhiteSpace ( ) ) includePragma = Configuration . DEFAULT_CONFIG_INCLUDE_PRAGMA ; var result = false ; checkCanModify ( ) ; foreach ( var child in Children ) { if ( child . IsSameName ( includePragma ) ) { var included = getIncludedNode ( child ) ; if ( included != null ) { child . include ( included ) ; result = true ; } else child . Delete ( ) ; continue ; } if ( recurse ) result |= child . ProcessIncludePragmas ( recurse , includePragma ) ; } return result ; }
Replaces all include pragmas - sections with specified names ('_include' by default), with pointed to configuration file content
as obtained via the call to file system specified in every pragma.
Replaces all include pragmas - sections with specified names ( ' _include ' by default ) with pointed to configuration file content as obtained via the call to file system specified in every pragma .
//Children does snapshot
True if pragmas were found
True if pragmas were found
recurse
bool
True to process inner nodes
True to process inner nodes
includePragma
string
Pragma section name, '_include' by default
Pragma section name ' _include ' by default
example
None