コード例 #1
0
        public static string PathExists(string path, string tableName, Enums.GenerateType generateType)
        {
            string[] pArr  = tableName.Split('_');
            string   _path = path + "\\" + (pArr.Length >= 3 ? pArr[1] : tableName) + "\\AutoCode";

            if (!Directory.Exists(_path))
            {
                Directory.CreateDirectory(_path);
            }
            if (generateType == Enums.GenerateType.DataAccess)
            {
                return(_path + "\\" + tableName + Config.DataAccessSuffix + ".cs");
            }
            else if (generateType == Enums.GenerateType.Logic)
            {
                return(_path + "\\" + tableName + Config.BusinessLogicSuffix + ".cs");
            }
            else if (generateType == Enums.GenerateType.Model)
            {
                return(_path + "\\" + tableName + Config.BusinessEntitiesSuffix + ".cs");
            }
            else if (generateType == Enums.GenerateType.DbContext)
            {
                return(_path + "\\" + tableName + Config.BusinessEntitiesSuffix + ".cs");
            }
            else
            {
                return(string.Empty);
            }
        }
コード例 #2
0
        /// <summary>
        /// The calculate numbers.
        /// </summary>
        /// <param name="typesOfDrawn">
        /// The t drawn.
        /// </param>
        /// <param name="generateType">
        /// The generate type.
        /// </param>
        /// <param name="count">
        /// The count.
        /// </param>
        /// <exception cref="ArgumentOutOfRangeException">
        /// </exception>
        public void CalculateNumbers(Enums.TypesOfDrawn typesOfDrawn, Enums.GenerateType generateType, int count)
        {
            // Get the method information using the method info class
            MethodInfo mi = this.GetType().GetMethod(typesOfDrawn + "Execute");

            switch (typesOfDrawn)
            {
            case Enums.TypesOfDrawn.ByInterval:
            case Enums.TypesOfDrawn.ByOccurrence:
            case Enums.TypesOfDrawn.ByAverageSteps:
            case Enums.TypesOfDrawn.ByAverageRandoms:
            case Enums.TypesOfDrawn.BySums:
            case Enums.TypesOfDrawn.Calculated:
                switch (generateType)
                {
                case Enums.GenerateType.EachByEach:
                    this.RunMethodWithEachTime(mi, count, typesOfDrawn);
                    break;

                case Enums.GenerateType.GetTheBest:
                    this.RunMethodWithEachTimeAndGetTheBestNumbers(mi, count, typesOfDrawn);
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(generateType), generateType, null);
                }

                break;

            case Enums.TypesOfDrawn.All:
                foreach (Enums.TypesOfDrawn drawn in (Enums.TypesOfDrawn[])Enum.GetValues(typeof(Enums.TypesOfDrawn)))
                {
                    MethodInfo mis = this.GetType().GetMethod(drawn.ToString() + "Execute");
                    if (mis != null)
                    {
                        switch (generateType)
                        {
                        case Enums.GenerateType.EachByEach:
                            RunMethodWithEachTime(mis, count, drawn);
                            break;

                        case Enums.GenerateType.GetTheBest:
                            RunMethodWithEachTimeAndGetTheBestNumbers(mis, count, drawn);
                            break;

                        default:
                            throw new ArgumentOutOfRangeException(nameof(generateType), generateType, null);
                        }
                    }
                }

                break;

            case Enums.TypesOfDrawn.ByDistributionBasedCurrentDraw:
                switch (generateType)
                {
                case Enums.GenerateType.EachByEach:
                    break;

                case Enums.GenerateType.GetTheBest:
                    break;

                case Enums.GenerateType.Unique:
                    MethodInfo mis = this.GetType().GetMethod("CalcTheFiveMostCommonNumbers");
                    if (mis != null)
                    {
                        RunMethodWithEachTime(mis, count, typesOfDrawn);
                    }

                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(generateType), generateType, null);
                }

                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(typesOfDrawn), typesOfDrawn, null);
            }

            // Invoke the method
            // (null- no parameter for the method call
            // or you can pass the array of parameters...)
            if (mi != null)
            {
                mi.Invoke(this, null);
            }
        }