CK.RouteConfig.Impl.ActionCompositeConfiguration.CheckValidity C# (CSharp) Method

CheckValidity() public method

Checks that children are valid (action's name must be unique).
public CheckValidity ( string routeName, IActivityMonitor monitor ) : bool
routeName string Name of the route that references this action.
monitor IActivityMonitor Monitor to report errors.
return bool
        public override bool CheckValidity( string routeName, IActivityMonitor monitor )
        {
            if( monitor == null ) throw new ArgumentNullException( "monitor" );
            bool result = true;
            for( int i = 0; i < _children.Count; ++i )
            {
                var child = _children[i];
                bool validChild = true;
                for( int j = ++i; j < _children.Count; ++j )
                {
                    if( _children[j].Name == child.Name )
                    {
                        monitor.SendLine( LogLevel.Error, string.Format( "Duplicate action name '{0}' in {1} '{2}', route '{3}'.", child.Name, TypeDisplayName, Name, routeName ), null );
                        validChild = false;
                    }
                }
                validChild &= child.CheckValidity( routeName, monitor );
                // Remove child to continue the process but avoid cascading errors.
                if( !validChild ) _children.RemoveAt( i-- );
                result &= validChild;
            }
            return result;
        }