예제 #1
0
        /// <summary>
        /// Gets a new instance of a context checker based on a given context.
        /// Note: Execute within transaction.
        /// </summary>
        /// <param name="context">Test bench, Parameteric Exploration, or Test bench Suite</param>
        /// <returns>A new context specific checker if context is supported, otherwise null.</returns>
        /// <exception cref="ArgumentNullException" />
        /// <exception cref="ArgumentOutOfRangeException" />
        public static ContextChecker GetContextChecker(IMgaModel context)
        {
            if (context == null)
            {
                throw new ArgumentNullException();
            }

            ContextChecker contextChecker = null;

            // get specialized context checker based on the context type.
            if (context.MetaBase.Name == typeof(CyPhy.TestBench).Name)
            {
                contextChecker = new TestBenchChecker(CyPhyClasses.TestBench.Cast(context));
            }
            else if (context.MetaBase.Name == typeof(CyPhy.CADTestBench).Name)
            {
                contextChecker = new StructuralFEATestBenchChecker(CyPhyClasses.CADTestBench.Cast(context));
            }
            else if (context.MetaBase.Name == typeof(CyPhy.KinematicTestBench).Name)
            {
                contextChecker = new KinematicTestBenchChecker(CyPhyClasses.KinematicTestBench.Cast(context));
            }
            else if (context.MetaBase.Name == typeof(CyPhy.CFDTestBench).Name)
            {
                contextChecker = new CFDTestBenchChecker(CyPhyClasses.CFDTestBench.Cast(context));
            }
            else if (context.MetaBase.Name == typeof(CyPhy.BlastTestBench).Name)
            {
                contextChecker = new BlastTestBenchChecker(CyPhyClasses.BlastTestBench.Cast(context));
            }
            else if (context.MetaBase.Name == typeof(CyPhy.BallisticTestBench).Name)
            {
                contextChecker = new BallisticTestBenchChecker(CyPhyClasses.BallisticTestBench.Cast(context));
            }
            else if (context.MetaBase.Name == typeof(CyPhy.TestBenchSuite).Name)
            {
                contextChecker = new TestBenchSuiteChecker(CyPhyClasses.TestBenchSuite.Cast(context));
            }
            else if (context.MetaBase.Name == typeof(CyPhy.ParametricExploration).Name)
            {
                contextChecker = new ParametricExplorationChecker(CyPhyClasses.ParametricExploration.Cast(context));
            }
            else if (context.MetaBase.Name == typeof(CyPhy.CarTestBench).Name)
            {
                contextChecker = new CarTestBenchChecker(CyPhyClasses.CarTestBench.Cast(context));
            }
            else
            {
                throw new ArgumentOutOfRangeException(string.Format("Given context is {0}, which is not supported. Try to run it on a test bench, PET or SoT.", context.Meta.Name));
            }

            return(contextChecker);
        }
예제 #2
0
        /// <summary>
        /// Gets a new instance of a context checker based on a given context.
        /// Note: Execute within transaction.
        /// </summary>
        /// <param name="context">Test bench, Parameteric Exploration, or Test bench Suite</param>
        /// <returns>A new context specific checker if context is supported, otherwise null.</returns>
        /// <exception cref="ArgumentNullException" />
        /// <exception cref="ArgumentOutOfRangeException" />
        public static ContextChecker GetContextChecker(IMgaModel context)
        {
            if (context == null)
            {
                throw new ArgumentNullException();
            }
            
            ContextChecker contextChecker = null;

            // get specialized context checker based on the context type.
            if (context.MetaBase.Name == typeof(CyPhy.TestBench).Name)
            {
                contextChecker = new TestBenchChecker(CyPhyClasses.TestBench.Cast(context));
            }
            else if (context.MetaBase.Name == typeof(CyPhy.CADTestBench).Name)
            {
                contextChecker = new StructuralFEATestBenchChecker(CyPhyClasses.CADTestBench.Cast(context));
            }
            else if (context.MetaBase.Name == typeof(CyPhy.KinematicTestBench).Name)
            {
                contextChecker = new KinematicTestBenchChecker(CyPhyClasses.KinematicTestBench.Cast(context));
            }
            else if (context.MetaBase.Name == typeof(CyPhy.CFDTestBench).Name)
            {
                contextChecker = new CFDTestBenchChecker(CyPhyClasses.CFDTestBench.Cast(context));
            }
            else if (context.MetaBase.Name == typeof(CyPhy.BlastTestBench).Name)
            {
                contextChecker = new BlastTestBenchChecker(CyPhyClasses.BlastTestBench.Cast(context));
            }
            else if (context.MetaBase.Name == typeof(CyPhy.BallisticTestBench).Name)
            {
                contextChecker = new BallisticTestBenchChecker(CyPhyClasses.BallisticTestBench.Cast(context));
            }
            else if (context.MetaBase.Name == typeof(CyPhy.TestBenchSuite).Name)
            {
                contextChecker = new TestBenchSuiteChecker(CyPhyClasses.TestBenchSuite.Cast(context));
            }
            else if (context.MetaBase.Name == typeof(CyPhy.ParametricExploration).Name)
            {
                contextChecker = new ParametricExplorationChecker(CyPhyClasses.ParametricExploration.Cast(context));
            }
            else if (context.MetaBase.Name == typeof(CyPhy.CarTestBench).Name)
            {
                contextChecker = new CarTestBenchChecker(CyPhyClasses.CarTestBench.Cast(context));
            }
            else
            {
                throw new ArgumentOutOfRangeException(string.Format("Given context is {0}, which is not supported. Try to run it on a test bench, PET or SoT.", context.Meta.Name));
            }

            return contextChecker;
        }