Exemple #1
0
        static void Main(string[] args)
        {
            StrategyEnum[] searchStrategies = new StrategyEnum[] { StrategyEnum.DistinctClientIP, StrategyEnum.DistinctFqdnIP, StrategyEnum.CountClientCalls };
            FileReader     fileReader       = new FileReader("IISLog.log", searchStrategies);

            fileReader.ProcessLogFile();

            PrintResult(fileReader.StrategySearch.Result);
        }
Exemple #2
0
 /// <summary>
 /// Verifies if compA wins against compB
 /// </summary>
 /// <param name="compA"></param>
 /// <param name="compB"></param>
 /// <returns></returns>
 public bool GetRuleResult(StrategyEnum compA, StrategyEnum compB)
 {
     try
     {
         return(RPSRules[(int)compA, (int)compB]);
     }
     catch
     {
         throw;
     }
 }
 private string[] CreatePlayerConfig(Team team, int port, StrategyEnum strategy)
 {
     return(new[]
     {
         $"TeamID={team.ToString().ToLower()}",
         "urls=http://127.0.0.1:0",
         $"CsIP={csIP}",
         $"CsPort={port}",
         $"Strategy={(int)strategy}",
         "Verbose=false"
     });
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="StopJobParameters" /> class.
 /// </summary>
 /// <param name="Strategy">Strategy (required).</param>
 public StopJobParameters(StrategyEnum Strategy = default(StrategyEnum))
 {
     // to ensure "Strategy" is required (not null)
     if (Strategy == null)
     {
         throw new InvalidDataException("Strategy is a required property for StopJobParameters and cannot be null");
     }
     else
     {
         this.Strategy = Strategy;
     }
 }
Exemple #5
0
        public static IStrategy GetStrategy(StrategyEnum strategyEnum, int complexity = 0)
        {
            switch (strategyEnum)
            {
            case StrategyEnum.NoStrategy:
                return(new NoStrategy());

            case StrategyEnum.ProofOfWork:
                return(new ProofOfWorkStrategy(complexity));
            }

            return(null);
        }
        public static IStrategy Create(StrategyEnum strategy, Player player, ILogger log)
        {
            switch (strategy)
            {
            case StrategyEnum.SimpleStrategy:
                return(new SimpleStrategy(player, log));

            case StrategyEnum.AdvancedStrategy:
                return(new AdvancedStrategy(player, log));

            default:
                return(null);
            }
        }
Exemple #7
0
        public bool AfterShipStatus(StrategyEnum strategy, BothShore shore)
        {
            /*
             * L 0 1
             * L 0 2
             * L 1 0
             * L 2 0
             * L 1 1
             * R 0 1
             * R 0 2
             * R 1 0
             * R 2 0
             * R 1 1
             */
            switch (strategy)
            {
            case StrategyEnum.StrategyEnum1:
                return(AfterShipStatus(shore, SideEnum.Left, 0, 1));

            case StrategyEnum.StrategyEnum2:
                return(AfterShipStatus(shore, SideEnum.Left, 0, 2));

            case StrategyEnum.StrategyEnum3:
                return(AfterShipStatus(shore, SideEnum.Left, 1, 0));

            case StrategyEnum.StrategyEnum4:
                return(AfterShipStatus(shore, SideEnum.Left, 2, 0));

            case StrategyEnum.StrategyEnum5:
                return(AfterShipStatus(shore, SideEnum.Left, 1, 1));

            case StrategyEnum.StrategyEnum6:
                return(AfterShipStatus(shore, SideEnum.Right, 0, 1));

            case StrategyEnum.StrategyEnum7:
                return(AfterShipStatus(shore, SideEnum.Right, 0, 2));

            case StrategyEnum.StrategyEnum8:
                return(AfterShipStatus(shore, SideEnum.Right, 1, 0));

            case StrategyEnum.StrategyEnum9:
                return(AfterShipStatus(shore, SideEnum.Right, 2, 0));

            case StrategyEnum.StrategyEnum10:
                return(AfterShipStatus(shore, SideEnum.Right, 1, 1));
            }
        }
        private static By GetBy(string locator)
        {
            var locatorKey = "";
            var strategy   = "";

            Utilities.ParseLocator(locator, ref locatorKey, ref strategy);
            StrategyEnum strategyEnum = Utilities.ParseEnum <StrategyEnum>(strategy);

            if (strategyEnum == StrategyEnum.ClassName)
            {
                return(By.ClassName(locatorKey));
            }
            else if (strategyEnum == StrategyEnum.Css)
            {
                return(By.CssSelector(locatorKey));
            }
            else if (strategyEnum == StrategyEnum.Tag)
            {
                return(By.TagName(locatorKey));
            }
            else if (strategyEnum == StrategyEnum.Id)
            {
                return(By.Id(locatorKey));
            }
            else if (strategyEnum == StrategyEnum.Link)
            {
                return(By.LinkText(locatorKey));
            }
            else if (strategyEnum == StrategyEnum.Name)
            {
                return(By.Name(locatorKey));
            }
            else if (strategyEnum == StrategyEnum.Partial)
            {
                return(By.PartialLinkText(locatorKey));
            }
            else if (strategyEnum == StrategyEnum.XPath)
            {
                return(By.XPath(locatorKey));
            }

            throw new Exception($"Locator {locator} does not support.");
        }
Exemple #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StopJobsParameters" /> class.
 /// </summary>
 /// <param name="JobIds">JobIds (required).</param>
 /// <param name="Strategy">Strategy (required).</param>
 public StopJobsParameters(List <long?> JobIds = default(List <long?>), StrategyEnum Strategy = default(StrategyEnum))
 {
     // to ensure "JobIds" is required (not null)
     if (JobIds == null)
     {
         throw new InvalidDataException("JobIds is a required property for StopJobsParameters and cannot be null");
     }
     else
     {
         this.JobIds = JobIds;
     }
     // to ensure "Strategy" is required (not null)
     if (Strategy == null)
     {
         throw new InvalidDataException("Strategy is a required property for StopJobsParameters and cannot be null");
     }
     else
     {
         this.Strategy = Strategy;
     }
 }
Exemple #10
0
 public HuntStrategy(StrategyEnum strategy)
     : base(strategy)
 {
 }
Exemple #11
0
 public EyeStrategy(StrategyEnum strategy) : base(strategy)
 {
 }
Exemple #12
0
 protected Strategy(StrategyEnum strategy)
 {
     this._Strategy = strategy;
 }
Exemple #13
0
        public static Loan Create(double commitment, DateTime start, DateTime end, int riskRating, StrategyEnum strategy)
        {
            Loan loan = null;

            switch (strategy)
            {
            case StrategyEnum.AvisedLine:
                if (riskRating <= 3)
                {
                    loan = NewAdvisedLine(commitment, start, end, riskRating);
                }
                break;

            case StrategyEnum.Revolver:
                loan = NewRevolver(commitment, start, end, riskRating);
                break;

            case StrategyEnum.Term:
                loan = NewTermLoan(commitment, start, end, riskRating);
                break;
            }
            return(loan);
        }
Exemple #14
0
 public EyeStrategy(StrategyEnum strategy)
     : base(strategy)
 {
 }
Exemple #15
0
 public FleeStrategy(StrategyEnum strategy)
     : base(strategy)
 {
 }
Exemple #16
0
 public HouseStrategy(StrategyEnum strategy)
     : base(strategy)
 {
 }
Exemple #17
0
 /// <summary>
 /// Converts a string into a List of competitors
 /// </summary>
 /// <param name="input"></param>
 /// <returns></returns>
 public List <CompetitorData> StringToCompetitors(string input, out string errorMessage)
 {
     try
     {
         List <CompetitorData> result = new List <CompetitorData>();
         int    bracketsCount = 0, playerCount = 0, index = 0;
         string name = string.Empty;
         errorMessage = string.Empty;
         StrategyEnum strategy = StrategyEnum.Invalid;
         if (!string.IsNullOrEmpty(input))
         {
             while (index < input.Length)
             {
                 if (input[index] == '[')
                 {
                     bracketsCount++;
                 }
                 else if (input[index] == ']')
                 {
                     bracketsCount--;
                 }
                 index++;
                 if (bracketsCount > 1)
                 {
                     if (input[index] == '\"' && playerCount == 0)
                     {
                         index++;                     //Ignores the opening " symbol
                         while (input[index] != '\"') //Name field
                         {
                             name = string.Concat(name, input[index++]);
                         }
                         if (!string.IsNullOrEmpty(name)) //Valid name field
                         {
                             playerCount++;
                         }
                         else
                         {
                             errorMessage = "Player name field error";//Throw exception, incomplete player field
                             return(result);
                         }
                         index++; //Ignores the closing " symbol
                     }
                     if (input[index] == '\"' && playerCount == 1)
                     {
                         //Strategy value
                         index++;//Ignores the opening " symbol
                         strategy = ParseStrategy(input[index++]);
                         if (strategy == StrategyEnum.Invalid)
                         {
                             errorMessage = string.Format("Invalid strategy {0}", input[index - 1]);//Throw exception, invalid strategy field
                             return(result);
                         }
                         else
                         {
                             result.Add(new CompetitorData {
                                 Name = name, Strategy = strategy
                             });
                             strategy    = StrategyEnum.Invalid;
                             name        = string.Empty;
                             playerCount = 0;
                         }
                     }
                 }
             }
             if (bracketsCount > 0)
             {
                 errorMessage = "Brackets mismatch";//Throw exception, brackets mismatch
             }
         }
         if (!IsPowerOfTwo(result.Count))
         {
             errorMessage = "The amount of competitors is not valid, must be 2^n";
         }
         return(result);
     }
     catch
     {
         throw;
     }
 }
Exemple #18
0
 public RandomStrategy(StrategyEnum strategy)
     : base(strategy)
 {
 }
Exemple #19
0
 public HouseStrategy(StrategyEnum strategy)
     : base(strategy)
 {
 }
Exemple #20
0
 public HuntStrategy(StrategyEnum strategy)
     : base(strategy)
 {
 }
Exemple #21
0
 public RandomStrategy(StrategyEnum strategy)
     : base(strategy)
 {
 }
Exemple #22
0
 protected Strategy(StrategyEnum strategy)
 {
     this._Strategy = strategy;
 }
Exemple #23
0
 public FleeStrategy(StrategyEnum strategy)
     : base(strategy)
 {
 }