示例#1
0
        /// <summary>
        /// Creates a processor set loaded with the provided processors.
        /// </summary>
        /// <remarks>
        /// <para>
        /// An empty processor set will be created if <paramref name="processors"/> is null
        /// or contains no processors.
        /// </para>
        /// </remarks>
        /// <param name="processors">The processors to include in the set.</param>
        /// <returns>The processor set</returns>
        public static ProcessorSet Create(INMGenProcessor[] processors)
        {
            INMGenProcessor[] lprocessors = ArrayUtil.Compress(processors);

            if (lprocessors == null)
            {
                lprocessors = new INMGenProcessor[0];
            }
            else if (lprocessors == processors)
            {
                lprocessors = (INMGenProcessor[])processors.Clone();
            }

            return(new ProcessorSet(lprocessors));
        }
示例#2
0
        public static InputBuilder Create(ISceneQuery filter
                                          , IInputBuildProcessor[] processors
                                          , InputBuildOption options)
        {
            IInputBuildProcessor[] lprocessors = ArrayUtil.Compress(processors);

            if (lprocessors == null || lprocessors.Length == 0)
            {
                return(null);
            }

            for (int i = lprocessors.Length - 1; i >= 0; i--)
            {
                IInputBuildProcessor processor = lprocessors[i];

                if (processor.DuplicatesAllowed)
                {
                    continue;
                }

                System.Type ta = processor.GetType();

                for (int j = i - 1; j >= 0; j--)
                {
                    System.Type tb = lprocessors[j].GetType();

                    if (ta.IsAssignableFrom(tb) || tb.IsAssignableFrom(ta))
                    {
                        return(null);
                    }
                }
            }

            if (lprocessors == processors)
            {
                lprocessors = (IInputBuildProcessor[])lprocessors.Clone();
            }

            InputBuildContext context = new InputBuildContext(filter, options);

            return(new InputBuilder(context, lprocessors));
        }