Пример #1
0
 private void updateVirusList()
 {
     virusList.Items.Clear();
     VHASH.Clear();
     SIZES.Clear();
     foreach (var info in virusInfos)
     {
         VHASH.Add(info.Key);
         SIZES.Add(info.Value.size);
         virusList.Items.Add(new VirusItem(info.Key, info.Value.size, info.Value.info, info.Value.keep));
     }
 }
Пример #2
0
        public IActionResult AddPizza(PIZZAS pizza, SIZES size, CRUSTS crust, List <TOPPINGS> topping)
        {
            var API = new ValuesApi(new Configuration {
                BasePath = "https://localhost:44368/"
            });

            var fleshedOutPizza = API.ApiValuesPIZZASIZECRUSTGet(pizza, size, crust, topping);

            return(PizzaMenu(new List <APizza> {
                fleshedOutPizza
            }));
        }
Пример #3
0
 private void TryKillVirus(FileInfo info)
 {
     if (info.Exists && SIZES.Contains(info.Length))
     {
         FileStream file = info.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
         string     hash = BitConverter.ToString(SHA1.ComputeHash(file));
         file.Close();
         if (VHASH.Contains(hash))
         {
             DeleteFile(info);
         }
     }
 }
        public ActionResult <APizza> GetPizzaInfo(PIZZAS PIZZA, SIZES SIZE)
        {
            APizza pizza;
            ASize  size;

            switch (SIZE)
            {
            case SIZES.SMALL:
                size = new SmallSize();
                break;

            case SIZES.MEDIUM:
                size = new MediumSize();
                break;

            case SIZES.LARGE:
                size = new LargeSize();
                break;

            default:
                return(StatusCode(400, "Size not recognized"));
            }

            switch (PIZZA)
            {
            case PIZZAS.MEAT:
                pizza = new MeatPizza(size);
                break;

            case PIZZAS.HAWAIIAN:
                pizza = new HawaiianPizza(size);
                break;

            case PIZZAS.VEGAN:
                pizza = new VeganPizza(size);
                break;

            case PIZZAS.CUSTOM:
                return(StatusCode(400, "You entered a custom pizza without providing the crust or toppings"));

            default:
                return(StatusCode(400, "Size not recognized"));
            }

            pizza.CalculatePrice();
            return(Ok(pizza));
        }
Пример #5
0
 private void KillProcess()
 {
     //遍历电脑中的进程
     foreach (var process in Process.GetProcesses())
     {
         try
         {
             FileInfo info = new FileInfo(process.MainModule.FileName);
             Dispatcher.BeginInvoke(ShowStatus, status, "进程:" + info.Name);
             if (info.Exists && SIZES.Contains(info.Length))
             {
                 FileStream file = info.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                 string     hash = BitConverter.ToString(SHA1.ComputeHash(file));
                 file.Close();
                 if (VHASH.Contains(hash))
                 {
                     try
                     {
                         process.Kill();
                         Dispatcher.BeginInvoke(Println, console, "结束病毒进程:" + info.Name);
                         DeleteFile(info);
                     }
                     catch (Exception e)
                     {
                         Dispatcher.BeginInvoke(Println, console, "病毒进程处理失败:" + info.FullName);
                         Dispatcher.BeginInvoke(Println, console, e.Message);
                     }
                 }
             }
         }
         catch (Exception)
         {
             //Console.WriteLine(e.Message);
             //Dispatcher.BeginInvoke(Println, console, e.Message);
         }
     }
 }
        public ActionResult <APizza> GetPizzaInfo(PIZZAS PIZZA, SIZES SIZE, CRUSTS CRUST, [FromQuery] List <TOPPINGS> TOPPING)
        {
            APizza          pizza;
            ASize           size;
            ACrust          crust;
            List <ATopping> toppings = new List <ATopping>();

            switch (SIZE)
            {
            case SIZES.SMALL:
                size = new SmallSize();
                break;

            case SIZES.MEDIUM:
                size = new MediumSize();
                break;

            case SIZES.LARGE:
                size = new LargeSize();
                break;

            default:
                return(StatusCode(400, "Size not recognized"));
            }

            switch (CRUST)
            {
            case CRUSTS.DEEPDISH:
                crust = new DeepDishCrust();
                break;

            case CRUSTS.STANDARD:
                crust = new StandardCrust();
                break;

            case CRUSTS.STUFFED:
                crust = new StuffedCrust();
                break;

            case CRUSTS.THIN:
                crust = new ThinCrust();
                break;

            default:
                return(StatusCode(400, "Crust not recognized"));
            }

            foreach (TOPPINGS toppingEnum in TOPPING)
            {
                switch (toppingEnum)
                {
                case TOPPINGS.BACON:
                    toppings.Add(new Bacon());
                    break;

                case TOPPINGS.CHICKEN:
                    toppings.Add(new Chicken());
                    break;

                case TOPPINGS.EXTRACHEESE:
                    toppings.Add(new ExtraCheese());
                    break;

                case TOPPINGS.GREENPEPPER:
                    toppings.Add(new GreenPepper());
                    break;

                case TOPPINGS.HAM:
                    toppings.Add(new Ham());
                    break;

                case TOPPINGS.NOCHEESE:
                    toppings.Add(new NoCheese());
                    break;

                case TOPPINGS.PINEAPPLE:
                    toppings.Add(new Pineapple());
                    break;

                case TOPPINGS.REDPEPPER:
                    toppings.Add(new RedPepper());
                    break;

                case TOPPINGS.SAUSAGE:
                    toppings.Add(new Sausage());
                    break;

                default:
                    return(StatusCode(400, "Topping not recognized"));
                }
            }
            pizza = new APizza
            {
                PIZZA    = PIZZA,
                Name     = Enum.GetName <PIZZAS>(PIZZA),
                Crust    = crust,
                Toppings = toppings
            };
            switch (PIZZA)
            {
            case PIZZAS.MEAT:
                pizza          = new MeatPizza(size);
                pizza.Crust    = crust;
                pizza.Toppings = toppings;
                break;

            case PIZZAS.HAWAIIAN:
                pizza          = new HawaiianPizza(size);
                pizza.Crust    = crust;
                pizza.Toppings = toppings;
                break;

            case PIZZAS.VEGAN:
                pizza          = new VeganPizza(size);
                pizza.Crust    = crust;
                pizza.Toppings = toppings;
                break;

            case PIZZAS.CUSTOM:
                pizza = new CustomPizza(crust, size, toppings);
                break;

            default:
                return(StatusCode(400, "Size not recognized"));
            }

            pizza.CalculatePrice();
            return(Ok(pizza));
        }
Пример #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ASize" /> class.
 /// </summary>
 /// <param name="name">name.</param>
 /// <param name="price">price.</param>
 /// <param name="id">id.</param>
 /// <param name="size">size.</param>
 public ASize(string name = default(string), double?price = default(double?), int?id = default(int?), SIZES size = default(SIZES))
 {
     this.Name  = name;
     this.Price = price;
     this.Id    = id;
     this.Size  = size;
 }
        /// <summary>
        ///
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="PIZZA"></param>
        /// <param name="SIZE"></param>
        /// <returns>Task of ApiResponse (APizza)</returns>
        public async System.Threading.Tasks.Task <ApiResponse <APizza> > ApiValuesPIZZASIZEGetAsyncWithHttpInfo(PIZZAS PIZZA, SIZES SIZE)
        {
            // verify the required parameter 'PIZZA' is set
            if (PIZZA == null)
            {
                throw new ApiException(400, "Missing required parameter 'PIZZA' when calling ValuesApi->ApiValuesPIZZASIZEGet");
            }
            // verify the required parameter 'SIZE' is set
            if (SIZE == null)
            {
                throw new ApiException(400, "Missing required parameter 'SIZE' when calling ValuesApi->ApiValuesPIZZASIZEGet");
            }

            var    localVarPath         = "/api/Values/{PIZZA}/{SIZE}";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new List <KeyValuePair <String, String> >();
            var    localVarHeaderParams = new Dictionary <String, String>(this.Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
            };
            String localVarHttpContentType    = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "text/plain",
                "application/json",
                "text/json"
            };
            String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            if (PIZZA != null)
            {
                localVarPathParams.Add("PIZZA", this.Configuration.ApiClient.ParameterToString(PIZZA));                // path parameter
            }
            if (SIZE != null)
            {
                localVarPathParams.Add("SIZE", this.Configuration.ApiClient.ParameterToString(SIZE));               // path parameter
            }
            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)await this.Configuration.ApiClient.CallApiAsync(localVarPath,
                                                                                                            Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                                            localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("ApiValuesPIZZASIZEGet", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <APizza>(localVarStatusCode,
                                            localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)),
                                            (APizza)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(APizza))));
        }
        /// <summary>
        ///
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="PIZZA"></param>
        /// <param name="SIZE"></param>
        /// <returns>Task of APizza</returns>
        public async System.Threading.Tasks.Task <APizza> ApiValuesPIZZASIZEGetAsync(PIZZAS PIZZA, SIZES SIZE)
        {
            ApiResponse <APizza> localVarResponse = await ApiValuesPIZZASIZEGetAsyncWithHttpInfo(PIZZA, SIZE);

            return(localVarResponse.Data);
        }
        /// <summary>
        ///
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="PIZZA"></param>
        /// <param name="SIZE"></param>
        /// <returns>APizza</returns>
        public APizza ApiValuesPIZZASIZEGet(PIZZAS PIZZA, SIZES SIZE)
        {
            ApiResponse <APizza> localVarResponse = ApiValuesPIZZASIZEGetWithHttpInfo(PIZZA, SIZE);

            return(localVarResponse.Data);
        }
        /// <summary>
        ///
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="PIZZA"></param>
        /// <param name="SIZE"></param>
        /// <param name="CRUST"></param>
        /// <param name="TOPPING"> (optional)</param>
        /// <returns>Task of APizza</returns>
        public async System.Threading.Tasks.Task <APizza> ApiValuesPIZZASIZECRUSTGetAsync(PIZZAS PIZZA, SIZES SIZE, CRUSTS CRUST, List <TOPPINGS> TOPPING = null)
        {
            ApiResponse <APizza> localVarResponse = await ApiValuesPIZZASIZECRUSTGetAsyncWithHttpInfo(PIZZA, SIZE, CRUST, TOPPING);

            return(localVarResponse.Data);
        }
        /// <summary>
        ///
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="PIZZA"></param>
        /// <param name="SIZE"></param>
        /// <param name="CRUST"></param>
        /// <param name="TOPPING"> (optional)</param>
        /// <returns>APizza</returns>
        public APizza ApiValuesPIZZASIZECRUSTGet(PIZZAS PIZZA, SIZES SIZE, CRUSTS CRUST, List <TOPPINGS> TOPPING = null)
        {
            ApiResponse <APizza> localVarResponse = ApiValuesPIZZASIZECRUSTGetWithHttpInfo(PIZZA, SIZE, CRUST, TOPPING);

            return(localVarResponse.Data);
        }