public void Configure(IConfigSectionNode node) { var appRoot = node.NavigateSection("/" + ErlConsts.ERLANG_CONFIG_SECTION); if (appRoot == null) { throw new ErlException( StringConsts.CONFIGURATION_NAVIGATION_SECTION_REQUIRED_ERROR, ErlConsts.ERLANG_CONFIG_SECTION); } // Configure global node variables ErlAbstractNode.s_DefaultCookie = new ErlAtom( appRoot.AttrByName(ErlConsts.ERLANG_COOKIE_ATTR) .ValueAsString(ErlAbstractNode.s_DefaultCookie.Value)); ErlAbstractNode.s_UseShortNames = appRoot.AttrByName(ErlConsts.ERLANG_SHORT_NAME_ATTR) .ValueAsBool(ErlAbstractNode.s_UseShortNames); ErlAbstractConnection.ConnectTimeout = appRoot.AttrByName(ErlConsts.ERLANG_CONN_TIMEOUT_ATTR) .ValueAsInt(ErlAbstractConnection.ConnectTimeout); // Configure local node and remote connections var cfg = new MemoryConfiguration(); cfg.CreateFromNode(appRoot); var root = cfg.Root; var nodes = root.Children .Where(n => n.Name.EqualsIgnoreCase(ErlConsts.ERLANG_NODE_SECTION)); var localNodes = nodes.Where(n => n.AttrByName(ErlConsts.CONFIG_IS_LOCAL_ATTR).ValueAsBool()).ToArray(); if (localNodes.Length != 1) { throw new ErlException(StringConsts.ERL_CONFIG_SINGLE_NODE_ERROR, localNodes.Length); } var localNode = localNodes[0]; // Create and configure local node s_Node = new ErlLocalNode(localNode.Value, localNode); // Configure connections to all remote nodes //m_AllNodes = nodes.Where(n => !n.AttrByName(ErlConsts.CONFIG_IS_LOCAL_ATTR).ValueAsBool()); m_AllNodes = root; }
public void Configure(IConfigSectionNode node) { var root = node.NavigateSection("/" + ErlConsts.ERLANG_CONFIG_SECTION); if (root == null) throw new ErlException( StringConsts.CONFIGURATION_NAVIGATION_SECTION_REQUIRED_ERROR, ErlConsts.ERLANG_CONFIG_SECTION); // Configure global node variables ErlAbstractNode.s_DefaultCookie = new ErlAtom( root.AttrByName(ErlConsts.ERLANG_COOKIE_ATTR) .ValueAsString(ErlAbstractNode.s_DefaultCookie.Value)); ErlAbstractNode.s_UseShortNames = root.AttrByName(ErlConsts.ERLANG_SHORT_NAME_ATTR) .ValueAsBool(ErlAbstractNode.s_UseShortNames); ErlAbstractConnection.ConnectTimeout = root.AttrByName(ErlConsts.ERLANG_CONN_TIMEOUT_ATTR) .ValueAsInt(ErlAbstractConnection.ConnectTimeout); // Configure local node and remote connections var nodes = root.Children .Where(n => n.Name.EqualsIgnoreCase(ErlConsts.ERLANG_NODE_SECTION)) .ToArray(); var localNodes = nodes.Where(n => n.Value.IndexOf('@') < 0).ToArray(); if (localNodes.Length != 1) throw new ErlException(StringConsts.ERL_CONFIG_SINGLE_NODE_ERROR, localNodes.Length); var localNode = localNodes[0]; // Create and configure local node s_Node = new ErlLocalNode(localNode.Value, localNode); // Configure connections to all remote nodes m_RemoteNodes = nodes.Where(n => n.Value.IndexOf('@') != -1).ToArray(); }