예제 #1
0
 public static void VerifySuspectIsInTrafficStopInfo(Ped Suspect)
 {
     if (!SuspectsTrafficStopQuestionsInfo.Select(x => x.Item1).Contains(Suspect))
     {
         SuspectsTrafficStopQuestionsInfo.Add(Suspect, new TrafficStopQuestionsInfo());
     }
 }
예제 #2
0
        static ODataExpressionLanguageTokenizer()
        {
            const string followedByNonWord = @"(?=\W|$)";
            var          tokenToRegex      = new TupleList <ODataTokenKind, string>
            {
                { ODataTokenKind.NullLiteral, "null" },
                { ODataTokenKind.BinaryLiteral, "(binary|X)'[A-Fa-f0-9]+'" },
                { ODataTokenKind.BooleanLiteral, "true|false" },
                // see comment on the enum
                //{ ODataTokenKind.ByteLiteral, "[A-Fa-f0-9]+" },
                { ODataTokenKind.DateTimeLiteral, @"datetime'(?<year>\d\d\d\d)-(?<month>\d\d)-(?<day>\d\d)T(?<hour>\d\d):(?<minute>\d\d)(:(?<second>\d\d)((?<fraction>\.\d+))?)?'" },
                { ODataTokenKind.Int64Literal, "-?[0-9]+L" },
                { ODataTokenKind.DecimalLiteral, @"-?[0-9]+(\.[0-9]+)?(M|m)" },
                { ODataTokenKind.SingleLiteral, @"-?[0-9]+\.[0-9]+f" },
                { ODataTokenKind.DoubleLiteral, @"-?[0-9]+((\.[0-9]+)|(E[+-]?[0-9]+))" },
                { ODataTokenKind.Int32Literal, "-?[0-9]+" },
                { ODataTokenKind.GuidLiteral, @"guid'(?<digits>DDDDDDDD-DDDD-DDDD-DDDD-DDDDDDDDDDDD)'".Replace("D", "[A-Fa-f0-9]") },
                { ODataTokenKind.StringLiteral, "'(?<chars>(''|[^'])*)'" },
                { ODataTokenKind.Eq, @"eq" + followedByNonWord },
                { ODataTokenKind.Ne, @"ne" + followedByNonWord },
                { ODataTokenKind.Gt, @"gt" + followedByNonWord },
                { ODataTokenKind.Ge, @"ge" + followedByNonWord },
                { ODataTokenKind.Lt, @"lt" + followedByNonWord },
                { ODataTokenKind.Le, @"le" + followedByNonWord },
                { ODataTokenKind.And, @"and" + followedByNonWord },
                { ODataTokenKind.Or, @"or" + followedByNonWord },
                { ODataTokenKind.Not, @"not" + followedByNonWord },
                { ODataTokenKind.Add, @"add" + followedByNonWord },
                { ODataTokenKind.Sub, @"sub" + followedByNonWord },
                { ODataTokenKind.Mul, @"mul" + followedByNonWord },
                { ODataTokenKind.Div, @"div" + followedByNonWord },
                { ODataTokenKind.Mod, @"mod" + followedByNonWord },
                { ODataTokenKind.Asc, @"asc" + followedByNonWord },
                { ODataTokenKind.Desc, @"desc" + followedByNonWord },
                // TODO VNEXT time, date-time offset
                { ODataTokenKind.LeftParen, @"\(" },
                { ODataTokenKind.RightParen, @"\)" },
                { ODataTokenKind.Star, @"\*" },
                { ODataTokenKind.Identifier, @"[a-zA-z_][a-zA-Z_0-9]*" },
                { ODataTokenKind.WhiteSpace, @"\s+" },
                { ODataTokenKind.Comma, "," },
                { ODataTokenKind.Slash, "/" },
                { ODataTokenKind.Error, @"." }, // matches any character not already matched
                { ODataTokenKind.Eof, "$" },    // matches an empty string positioned at the end of the string
            };

            TokenizerRegex = new Regex(
                tokenToRegex.Select(t => string.Format("(?<{0}>{1})", t.Item1, t.Item2))
                .ToDelimitedString("|"),
                RegexOptions.ExplicitCapture | RegexOptions.Compiled
                );
        }
예제 #3
0
        public static void DisplayDependencyErrors()
        {
            string ModsWithErrors = "";

            foreach (string s in Plugins_URL_Errors.Select(x => x.Item1).Distinct().ToList())
            {
                ModsWithErrors += s + ",";
            }
            Popup pop = new Popup("Albo1125.Common detected errors", "Errors were detected in your installation of the following of my modifications, so they will not load: " + ModsWithErrors, new List <string>()
            {
                "Continue"
            }, false, false, NextDependencyErrorCallback);

            pop.Display();
        }
예제 #4
0
        /// <summary>
        ///   Retrieves the containing workspace of a given type.
        /// </summary>
        /// <typeparam name="TWorkspace">The type of the workspace to look for.</typeparam>
        /// <exception cref="InvalidOperationException">Thrown when a workspace of the requested type was not found.</exception>
        /// <exception cref="NotImplementedException">Thrown when multiple workspaces are found. No method to disambiguate between them has been implemented yet.</exception>
        public TWorkspace GetInnerWorkspace <TWorkspace>()
        {
            Type searchFor = typeof(TWorkspace);
            var  matching  = _workspaces
                             .Select(
                w => w.Item2.GetType().IsOfGenericType(typeof(NonGenericWorkspace <>))
                                                ? w.Item2.GetType().GetProperty("Inner", ReflectionHelper.InstanceMembers).GetValue(w.Item2)
                                                : w.Item2)
                             .Where(w => w.GetType() == searchFor).ToList();

            switch (matching.Count)
            {
            case 0:
                string message = String.Format("The requested inner workspace of type \"{0}\" was not found.", searchFor);
                throw new InvalidOperationException(message);

            case 1:
                return((TWorkspace)matching.First());

            default:
                throw new NotImplementedException("Multiple matching workspaces were found, which is currently not supported.");
            }
        }