Exemplo n.º 1
0
 private DateTime?GetDateEnrolled()
 {
     if (Identifiers.Any())
     {
         return(Identifiers.First().RegistrationDate);
     }
     return(null);
 }
Exemplo n.º 2
0
 public bool MatchesItem(Item item)
 {
     if (item == null)
     {
         return(false);
     }
     if (excludedIdentifiers.Any(id => item.Prefab.Identifier == id || item.HasTag(id)))
     {
         return(false);
     }
     return(Identifiers.Any(id => item.Prefab.Identifier == id || item.HasTag(id)));
 }
Exemplo n.º 3
0
 public bool MatchesItem(ItemPrefab itemPrefab)
 {
     if (itemPrefab == null)
     {
         return(false);
     }
     if (excludedIdentifiers.Any(id => itemPrefab.Identifier == id || itemPrefab.Tags.Contains(id)))
     {
         return(false);
     }
     return(Identifiers.Any(id => itemPrefab.Identifier == id || itemPrefab.Tags.Contains(id)));
 }
Exemplo n.º 4
0
        private void AddIdentifier(string value)
        {
            if (Identifiers.Any(e => e.Name.Equals(value)))
            {
                return;
            }

            int index = Identifiers.Count + 1;

            Identifiers.Add(new Identifier
            {
                Index = index,
                Type  = Lexemes.Any() ? Lexemes.Last()?.Token ?? "" : "",
                Name  = value
            }
                            );
        }
Exemplo n.º 5
0
        static string[] ExcludeFiles(string[] filerows, string[] targetfiles)
        {
            int count1 = filerows.Length;

            string[] filestocopy = filerows.Except(targetfiles).ToArray();
            int      count2      = filestocopy.Length;

            Log($"Excluded files (exists in target): {count1 - count2}");


            if (true)
            {
                count1      = filestocopy.Length;
                filestocopy = filestocopy.Where(f => !Regex.IsMatch(Path.GetFileName(f.Split('\t')[2]), ".*DS_Store", RegexOptions.IgnoreCase)).ToArray();
                count2      = filestocopy.Length;
                Log($"Excluded files (DS_Store): {count1 - count2}");

                count1      = filestocopy.Length;
                filestocopy = filestocopy.Where(f => !Regex.IsMatch(Path.GetFileName(f.Split('\t')[2]), "thumbs.db", RegexOptions.IgnoreCase)).ToArray();
                count2      = filestocopy.Length;
                Log($"Excluded files (thumbs.db): {count1 - count2}");
            }


            if (Excludes != null && Excludes.Length > 0)
            {
                foreach (string exclude in Excludes)
                {
                    if (LogWriter.Verbose)
                    {
                        string[] junk = filestocopy.Where(f => Regex.IsMatch(f.Split('\t')[2], exclude, RegexOptions.IgnoreCase)).ToArray();
                        Log($"Excluded files (file pattern: '{exclude}'): {junk.Length}", true);
                        foreach (string filerow in junk)
                        {
                            Log($"Exclude file: '{filerow}'", true);
                        }
                    }

                    count1      = filestocopy.Length;
                    filestocopy = filestocopy.Where(f => !Regex.IsMatch(f.Split('\t')[2], exclude, RegexOptions.IgnoreCase)).ToArray();
                    count2      = filestocopy.Length;
                    Log($"Excluded files (file pattern: '{exclude}'): {count1 - count2}");
                }
            }


            if (Identifiers != null)
            {
                if (LogWriter.Verbose)
                {
                    string[] junk = filestocopy.Where(f => f.Split('\t')[2].StartsWith("ProductContent") && !Identifiers.Any(i => f.Split('\t')[2].StartsWith($"ProductContent\\{i}"))).ToArray();
                    Log($"Excluded files (identifiers): {junk.Length}", true);
                    foreach (string filerow in junk)
                    {
                        Log($"Exclude file: '{filerow}'", true);
                    }
                }

                count1 = filestocopy.Length;
                DateTime t1 = DateTime.Now;
                filestocopy = filestocopy.Where(f => !f.Split('\t')[2].StartsWith("ProductContent") || Identifiers.Any(i => f.Split('\t')[2].StartsWith($"ProductContent\\{i}"))).ToArray();
                DateTime t2 = DateTime.Now;
                count2 = filestocopy.Length;
                Log($"Excluded files (identifiers): {count1 - count2} (Calc time: {t2 - t1})");
            }


            if (Maxsize > 0)
            {
                if (LogWriter.Verbose)
                {
                    string[] junk = filestocopy.Where(f => long.Parse(f.Split('\t')[1]) > Maxsize).ToArray();
                    Log($"Excluded files (max file size): {junk.Length}", true);
                    foreach (string filerow in junk)
                    {
                        Log($"Exclude file: '{filerow}'", true);
                    }
                }

                count1      = filestocopy.Length;
                filestocopy = filestocopy.Where(f => long.Parse(f.Split('\t')[1]) <= Maxsize).ToArray();
                count2      = filestocopy.Length;
                Log($"Excluded files (max file size): {count1 - count2}");
            }


            return(filestocopy);
        }
Exemplo n.º 6
0
        public OuterLexemes Parse(string code)
        {
            int lineNumber    = 1;
            var lexemeBuilder = new StringBuilder();

            foreach (string symbol in code.Select(c => c.ToString()))
            {
                int realLineNumber = lineNumber;
                if (symbol.Equals("\n"))
                {
                    lineNumber++;
                }

                if (TrimDelimiters.Contains(symbol) || Delimiters.Contains(symbol))
                {
                    string lexeme = lexemeBuilder.ToString();

                    if (PredefinedWords.Contains(lexeme) || Operators.Contains(lexeme))
                    {
                        AddLexeme(lexeme, realLineNumber);
                    }
                    else if (IsIdentifier(lexeme))
                    {
                        // Duplicated identifier
                        if (Lexemes.Any() && Lexemes.Last().SubString.Equals("var") &&
                            Identifiers.Any(e => e.Name.Equals(lexeme)))
                        {
                            AddError($"Duplicate declaration of {lexeme} identifier", realLineNumber);
                            lexemeBuilder.Clear();
                            continue;
                        }

                        // Usage of undeclared identifier
                        if (Lexemes.Any() && !Lexemes.Last().SubString.Equals("var") &&
                            !Lexemes.Last().SubString.Equals("program") && !Identifiers.Any(e => e.Name.Equals(lexeme)))
                        {
                            AddError($"Usage of undeclared identifier: {lexeme}", realLineNumber);
                            lexemeBuilder.Clear();
                            continue;
                        }

                        AddIdentifier(lexeme);
                        AddLexeme(lexeme, realLineNumber, IdentifierType.Identifier);
                    }
                    else if (IsConstant(lexeme))
                    {
                        AddConstant(lexeme);
                        AddLexeme(lexeme, realLineNumber, IdentifierType.Constant);
                    }
                    else if (!string.IsNullOrEmpty(lexeme))
                    {
                        AddError($"Unknown lexeme: {lexeme}", realLineNumber);
                        lexemeBuilder.Clear();
                        continue;
                    }

                    if (Delimiters.Contains(symbol))
                    {
                        AddLexeme(symbol, realLineNumber);
                    }

                    lexemeBuilder.Clear();
                    continue;
                }

                if (!TrimDelimiters.Contains(symbol))
                {
                    lexemeBuilder.Append(symbol);
                }
            }

            return(new OuterLexemes()
            {
                Identifiers = Identifiers,
                Constants = Constants,
                Lexemes = Lexemes,
                Errors = Errors,
                Grammar = GrammarLexemes
            });
        }