コード例 #1
0
 public static IFunction Create(CalcEnum mode)
 {
     switch (mode)
     {
         case CalcEnum.Ave:
             return new AveFunction();
         case CalcEnum.Sum:
             return new SumFunction();
         case CalcEnum.Count:
             return new CountFunction();
     }
     return null;
 }
コード例 #2
0
        static public IFunction Create(CalcEnum mode)
        {
            switch (mode)
            {
            case CalcEnum.Ave:
                return(new AveFunction());

            case CalcEnum.Sum:
                return(new SumFunction());

            case CalcEnum.Count:
                return(new CountFunction());
            }
            return(null);
        }
コード例 #3
0
ファイル: CalcEnum.cs プロジェクト: DevelNet/Calculator
 public void Change(bool intState,bool doubleState,bool complecsState)
 {
     if(intState==true && doubleState == false && complecsState == false)
     {
         calcEnum=CalcEnum.IntCalc;
         return;
     }
     if (intState == false && doubleState == true && complecsState == false)
     {
         calcEnum = CalcEnum.FloatCalc;
         return;
     }
     if (intState == false && doubleState == false && complecsState == true)
     {
         calcEnum = CalcEnum.ComCalc;
         return;
     }
     throw new MultiStateEror();
 }
コード例 #4
0
 public static void getCalculation()
 {
     Console.WriteLine("Select the type of calculation you want to do with " + shapeEnum);
     var values = Enum.GetValues(typeof (CalcEnum));
     for (int i = 0; i < values.Length; i++)
     {
         Console.WriteLine((i+1) + " - " + values.GetValue(i));
     }
     int calcSelection = Int16.Parse(Console.In.ReadLine());
     switch (calcSelection) {
         case 1:
             calcEnum = CalcEnum.Area;
             areaCalc();
             break;
         case 2:
             calcEnum = CalcEnum.Volume;
             volCalc();
             break;
     }
 }
コード例 #5
0
        public async Task <Models.TwoCaptcha> NormalCaptchaAsync(string key2Captcha, string imgCaptchaBase64,
                                                                 NumericEnum numeric     = NumericEnum.NotSpecified, byte minLength         = 0, byte maxLength = 0, RegSenseEnum regSense = RegSenseEnum.CaptchaInNotCaseSensitive,
                                                                 PhraseEnum phrase       = PhraseEnum.CaptchaContainsOneWord, CalcEnum calc = CalcEnum.NotSpecified, LanguageEnum language = LanguageEnum.NotSpecified,
                                                                 string textInstructions = null, int softId = 5287317)
        {
            var client = new HttpClient();

            var fields = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("key", key2Captcha),
                new KeyValuePair <string, string>("json", "1"),
                new KeyValuePair <string, string>("numeric", ((int)numeric).ToString()),
                new KeyValuePair <string, string>("min_len", minLength.ToString()),
                new KeyValuePair <string, string>("max_len", maxLength.ToString()),
                new KeyValuePair <string, string>("regsense", ((int)regSense).ToString()),
                new KeyValuePair <string, string>("phrase", ((int)phrase).ToString()),
                new KeyValuePair <string, string>("calc", ((int)calc).ToString()),
                new KeyValuePair <string, string>("language", ((int)calc).ToString()),
                new KeyValuePair <string, string>("method", "base64"),
                new KeyValuePair <string, string>("body", imgCaptchaBase64),
                new KeyValuePair <string, string>("soft_id", softId.ToString()),
            };

            if (textInstructions != null)
            {
                fields.Add(new KeyValuePair <string, string>("textinstructions", ""));
            }

            var form     = new FormUrlEncodedContent(fields);
            var response = await client.PostAsync("http://2captcha.com/in.php", form);

            response.EnsureSuccessStatusCode();

            var json = await response.Content.ReadAsStringAsync();

            var twoCaptcha = Models.TwoCaptcha.FromJson(json);
            var idRequest  = twoCaptcha.Request;

            if (twoCaptcha.Status == 1)
            {
                do
                {
                    // Wait time before checking if the CAPTCHA has been resolved
                    await Task.Delay(5000);

                    json = await client.GetStringAsync($"http://2captcha.com/res.php?key={key2Captcha}&action=get&id={idRequest}&json=1");

                    twoCaptcha = Models.TwoCaptcha.FromJson(json);

                    if (twoCaptcha.Request == "ERROR_CAPTCHA_UNSOLVABLE")
                    {
                        break;
                    }
                } while (twoCaptcha.Request == "CAPCHA_NOT_READY");
            }

            return(twoCaptcha);
        }
コード例 #6
0
ファイル: CalcEnum.cs プロジェクト: DevelNet/Calculator
 public CalcChangeState()
 {
     calcEnum = CalcEnum.ComCalc;
 }