예제 #1
0
        public IOverlapRemovalAlgorithm <TVertex> CreateAlgorithm(string newAlgorithmType,
                                                                  IOverlapRemovalContext <TVertex> context, IOverlapRemovalParameters parameters)
        {
            if (context == null || context.Rectangles == null)
            {
                return(null);
            }

            switch (newAlgorithmType)
            {
            case "FSA":
                return(new FSAAlgorithm <TVertex>(context.Rectangles, parameters));

            /*case "OneWayFSA":
             *      return new OneWayFSAAlgorithm<TVertex>( context.Rectangles, parameters as OneWayFSAParameters );*/
            default:
                return(null);
            }
        }
        /// <inheritdoc />
        public IOverlapRemovalAlgorithm <TVertex> CreateAlgorithm(
            string algorithmType,
            IOverlapRemovalContext <TVertex> context,
            IOverlapRemovalParameters parameters)
        {
            if (algorithmType is null)
            {
                throw new ArgumentNullException(nameof(algorithmType));
            }
            if (context is null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (parameters is null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            switch (algorithmType)
            {
            case FSAAlgorithm:
                return(new FSAAlgorithm <TVertex>(context.Rectangles, parameters));

            case OneWayFSAAlgorithm:
            {
                if (parameters is OneWayFSAParameters oneWayFSAParams)
                {
                    return(new OneWayFSAAlgorithm <TVertex>(context.Rectangles, oneWayFSAParams));
                }

                throw new ArgumentException(
                          $"Must use {nameof(OneWayFSAParameters)} to create a {nameof(OneWayFSAAlgorithm<object>)} algorithm.",
                          nameof(parameters));
            }

            default:
                return(null);
            }
        }