Exemplo n.º 1
0
        private static int?ParseProtocol(string Value)
        {
            Value = TextHelpers.Split2(Value, "-").Item1;
            int prot;

            if (int.TryParse(Value, out prot) && prot >= 0 && prot <= 255)
            {
                return(prot);
            }
            return(null);
        }
Exemplo n.º 2
0
 protected override void WriteNonEmptyMatchValue(Capture capture)
 {
     if (Options.HighlightMatch)
     {
         base.WriteNonEmptyMatchValue(capture);
     }
     else if (Options.IncludeLineNumber)
     {
         ((LineNumberValueWriter)ValueWriter).LineNumber += TextHelpers.CountLines(Input, capture.Index, capture.Length);
     }
 }
Exemplo n.º 3
0
        private void WriteValues(ImmutableArray <OptionValueItem> values)
        {
            foreach (OptionValueItem value in values)
            {
                Write(Options.Indent);

                string text = TextHelpers.Indent(value.Text, Options.Indent);

                WriteTextLine(new HelpItem(text, ""));
            }
        }
Exemplo n.º 4
0
        public static User GetRandomUser()
        {
            var r = new Random((int)DateTime.Now.Ticks);

            return(new User()
            {
                //Name = TextHelpers.GetRandomWord(10),
                Email = TextHelpers.GetRandomWord(10) + "@" + TextHelpers.GetRandomWord(6) + "." + TextHelpers.GetRandomWordWithoutNumbers(2),
                Password = TextHelpers.GetRandomWord(8) + r.Next(0, 9)
            });
        }
Exemplo n.º 5
0
    public static ImageSource GetIcon(string path, double size)
    {
        string key = path + "@" + size.ToString();

        ImageSource image = null;

        IconCacheLock.EnterReadLock();
        bool bFound = IconCache.TryGetValue(key, out image);

        IconCacheLock.ExitReadLock();
        if (bFound)
        {
            return(image);
        }

        try
        {
            var pathIndex = TextHelpers.Split2(path, "|");

            IconExtractor extractor = new IconExtractor(pathIndex.Item1);
            int           index     = MiscFunc.parseInt(pathIndex.Item2);
            if (index < extractor.Count)
            {
                image = ToImageSource(extractor.GetIcon(index, new System.Drawing.Size((int)size, (int)size)));
            }

            if (image == null)
            {
                if (File.Exists(MiscFunc.NtOsKrnlPath)) // if running in WOW64 this does not exist
                {
                    image = ToImageSource(Icon.ExtractAssociatedIcon(MiscFunc.NtOsKrnlPath));
                }
                else // fall back to an other icon
                {
                    image = ToImageSource(Icon.ExtractAssociatedIcon(MiscFunc.Shell32Path));
                }
            }

            image.Freeze();
        }
        catch (Exception err)
        {
            AppLog.Exception(err);
        }

        IconCacheLock.EnterWriteLock();
        if (!IconCache.ContainsKey(key))
        {
            IconCache.Add(key, image);
        }
        IconCacheLock.ExitWriteLock();
        return(image);
    }
Exemplo n.º 6
0
        protected bool AtSlashNineHack()
        {
            // Use _cs.DecodedCurrentChar because it is smart enough to know that \93 is not a \9
            if (CS.CurrentChar == '\\' &&
                CS.Peek(1) == '9' &&
                TextHelpers.DecodeCurrentChar(CS).Char == 9)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 7
0
        private void AddJavaScriptError()
        {
            //Absolute\Path\To\LexerOrParser.js:68
            //                break;
            //                ^^^^^
            //
            //SyntaxError: Unexpected token break
            //    at exports.runInThisContext (vm.js:53:16)
            //    at Module._compile (module.js:373:25)
            //    at Object.Module._extensions..js (module.js:416:10)
            //    at Module.load (module.js:343:32)
            //    at Function.Module._load (module.js:300:12)
            //    at Module.require (module.js:353:17)
            //    at require (internal/module.js:12:17)
            //    at Object.<anonymous> (Absolute\Path\To\AntlrJavaScriptTest.js:1:85)
            //    at Module._compile (module.js:409:26)
            //    at Object.Module._extensions..js (module.js:416:10)
            string   message         = "";
            string   grammarFileName = "";
            TextSpan errorSpan       = TextSpan.Empty;

            try
            {
                int    semicolonLastIndex = _buffer[0].LastIndexOf(':');
                string codeFileName       = Path.GetFileName(_buffer[0].Remove(semicolonLastIndex));
                if (_grammarCodeMapping.TryGetValue(codeFileName, out List <TextSpanMapping> mapping))
                {
                    int codeLine = int.Parse(_buffer[0].Substring(semicolonLastIndex + 1));
                    grammarFileName = GetGrammarFromCodeFileName(RuntimeInfo.Runtimes[Runtime.JavaScript], codeFileName);
                    errorSpan       = TextHelpers.GetSourceTextSpanForLine(mapping, codeLine, grammarFileName);
                }
            }
            catch
            {
            }
            if (_buffer.Count > 0)
            {
                message = _buffer.LastOrDefault(line => !line.StartsWith("    at")) ?? "";
            }
            string finalMessage = "";

            if (grammarFileName != "")
            {
                finalMessage = grammarFileName + ":";
            }
            if (!errorSpan.IsEmpty)
            {
                finalMessage += errorSpan.GetLineColumn().BeginLine + ":";
            }
            finalMessage += message == "" ? "Unknown Error" : message;
            AddError(new ParsingError(errorSpan, finalMessage, WorkflowStage.ParserCompiled));
        }
Exemplo n.º 8
0
 void FindRowsThatCannotBeMerged()
 {
     foreach (var r in TableRows)
     {
         foreach (var c in r.RowCells)
         {
             if (c.GetText().ToLower().StartsWith("супруг") || TextHelpers.LooksLikeRussianPersonName(c.GetText()))
             {
                 r.HasPersonName = true;
             }
         }
     }
 }
Exemplo n.º 9
0
    public void Can_make_lines_from_object_properties_with_dates_and_arrays()
    {
        var strings = TextHelpers.PrintObject(new TestObject(), "MM/dd/yyyy h:mm tt");

        Assert.Equal(new[] {
            "MyString: Hello World",
            "MyInteger: 201",
            "MyStrings: 5, 6, 7, 8",
            "MyIntegers: 1, 2, 3, 4",
            "MyDateTime: 12/01/2018 9:09 AM",
            "MyDate: 09/10/2008 12:00 AM",
            "MyDateTimes: 09/10/2008 12:00 AM, 12/01/2018 9:09 AM, 09/10/2008 12:00 AM",
        }, strings);
    }
Exemplo n.º 10
0
    public void Can_format_dates_to_ISO8601_by_default()
    {
        var strings = TextHelpers.PrintObject(new TestObject());

        Assert.Equal(new[] {
            "MyString: Hello World",
            "MyInteger: 201",
            "MyStrings: 5, 6, 7, 8",
            "MyIntegers: 1, 2, 3, 4",
            "MyDateTime: 2018-12-01T09:09:08",
            "MyDate: 2008-09-10T00:00:00",
            "MyDateTimes: 2008-09-10T00:00:00, 2018-12-01T09:09:08, 2008-09-10T00:00:00",
        }, strings);
    }
Exemplo n.º 11
0
        private CommandResult ListPatterns(char ch)
        {
            var rows = new List <(string name, string description)>();

            if (ch >= 0 && ch <= 0x7F)
            {
                rows.Add(("Name", TextHelpers.SplitCamelCase(((AsciiChar)ch).ToString())));
            }

            int charCode = ch;

            rows.Add(("Decimal", charCode.ToString(CultureInfo.InvariantCulture)));
            rows.Add(("Hexadecimal", charCode.ToString("X", CultureInfo.InvariantCulture)));

            List <PatternInfo> patterns = GetPatterns(ch).ToList();

            int width = Math.Max(
                rows.Max(f => f.name.Length),
                patterns.Select(f => f.Pattern.Length).DefaultIfEmpty().Max());

            WriteLine();

            foreach ((string name, string description) in rows)
            {
                WriteRow(name, description);
            }

            WriteLine();

            if (patterns.Count > 0)
            {
                WriteRow("PATTERN", "DESCRIPTION");

                foreach (PatternInfo item in patterns)
                {
                    WriteRow(item.Pattern, item.Description, Colors.Syntax);
                }

                return(CommandResult.Success);
            }
            else
            {
                WriteLine("No pattern found");
                return(CommandResult.NoMatch);
            }

            void WriteRow(
                string value1,
                string?value2,
                in ConsoleColors colors1 = default,
Exemplo n.º 12
0
        public void TextHelpers_Decode3()
        {
            Assert.AreEqual("PQ RST U",
                            TextHelpers.DecodeText(new StringTextProvider("PQ \\52\\53 \\54\n \\U"),
                                                   0, 17, forStringToken: false));

            Assert.AreEqual("PQ RST U",
                            TextHelpers.DecodeText(new StringTextProvider("PQ RST U"),
                                                   0, 8, forStringToken: false));

            Assert.AreEqual("R2\r2",
                            TextHelpers.DecodeText(new StringTextProvider("\\0000522\\D \\32"),
                                                   0, 14, forStringToken: false));
        }
Exemplo n.º 13
0
    //////////////////////////////////////////////////////////////////////////////////////////////
    // App resource handling


    public string GetAppResourceStr(string resourcePath)
    {
        // Note: PackageManager requirers admin privilegs

        var AppResource = TextHelpers.Split2(resourcePath.Substring(2, resourcePath.Length - 3), "?");
        var package     = packageManager.FindPackage(AppResource.Item1);

        if (package != null)
        {
            string pathToPri = Path.Combine(package.InstalledLocation.Path, "resources.pri");
            return(MiscFunc.GetResourceStr(pathToPri, AppResource.Item2));
        }

        return(resourcePath);
    }
Exemplo n.º 14
0
 public static void InitialiseConnection(DatabaseType db)
 {
     if (db == DatabaseType.Sql)
     {
         // TODO - Set up the Sql connection properly
         SQLConnector sql = new SQLConnector();
         Connection = sql;
     }
     else if (db == DatabaseType.TextFile)
     {
         // TODO - Create the text connection
         TextHelpers text = new TextHelpers();
         Connection = text;
     }
 }
Exemplo n.º 15
0
        public void ThenTheJudgeCanSeeInformationAboutTheirCase()
        {
            _browsers[_c.CurrentUser].Driver.WaitUntilVisible(JudgeWaitingRoomPage.ReturnToHearingRoomLink).Displayed.Should().BeTrue();
            _browsers[_c.CurrentUser].Driver.WaitUntilVisible(JudgeWaitingRoomPage.ContactVho).Displayed.Should().BeTrue();
            _browsers[_c.CurrentUser].Driver.WaitUntilVisible(JudgeWaitingRoomPage.HearingTitle).Text.Should().Be($"{_c.Test.Case.Name} ({_c.Test.Hearing.Case_type_name}) case number: {_c.Test.Hearing.Cases.First().Number}");

            var startDate        = _c.TimeZone.Adjust(_c.Test.Hearing.Scheduled_date_time);
            var dateAndStartTime = startDate.ToString(DateFormats.JudgeWaitingRoomPageTime);
            var endTime          = startDate.AddMinutes(_c.Test.Hearing.Scheduled_duration).ToString(DateFormats.JudgeWaitingRoomPageTimeEnd);
            var displayedTime    = TextHelpers.RemoveSpacesOnSafari(_browsers[_c.CurrentUser].Driver.WaitUntilVisible(JudgeWaitingRoomPage.HearingDateTime).Text);

            displayedTime.Should().Be($"{dateAndStartTime} to {endTime}");

            _browsers[_c.CurrentUser].Driver.WaitUntilVisible(JudgeWaitingRoomPage.StartHearingText).Displayed.Should().BeTrue();
            _browsers[_c.CurrentUser].Driver.WaitUntilVisible(JudgeWaitingRoomPage.IsEveryoneConnectedText).Displayed.Should().BeTrue();
        }
Exemplo n.º 16
0
        public void GenerateCommentString_Returns()
        {
            var customComment = "// custom comment";

            var expectedComment =
                @$ "// <auto-generated>
// This code was generated by a kontent-generators-net tool
// (see https://github.com/Kentico/kontent-generators-net).
//
// custom comment
// </auto-generated>{Environment.NewLine}{Environment.NewLine}";

            var result = TextHelpers.GenerateCommentString(customComment);

            Assert.Equal(expectedComment, result);
        }
Exemplo n.º 17
0
        public void ThenTheUserCanSeeInformationAboutTheirCase()
        {
            _browsers[_c.CurrentUser].Driver.WaitUntilVisible(WaitingRoomPage.HearingCaseDetails).Text.Should().Contain(_c.Test.Case.Name);
            _browsers[_c.CurrentUser].Driver.WaitUntilVisible(WaitingRoomPage.HearingCaseDetails).Text.Should().Contain($"case number: {_c.Test.Hearing.Cases.First().Number}");

            var displayedDateTime = TextHelpers.RemoveSpacesOnSafari(_browsers[_c.CurrentUser].Driver.WaitUntilVisible(WaitingRoomPage.HearingDate).Text);

            displayedDateTime.Should().Contain(_c.TimeZone.Adjust(_c.Test.Hearing.Scheduled_date_time).ToString(DateFormats.WaitingRoomPageDate));
            displayedDateTime.Should().Contain(_c.TimeZone.Adjust(_c.Test.Hearing.Scheduled_date_time).ToString(DateFormats.WaitingRoomPageTime));

            var endTime = _c.TimeZone.Adjust(_c.Test.Hearing.Scheduled_date_time).AddMinutes(_c.Test.Hearing.Scheduled_duration).ToString(DateFormats.WaitingRoomPageTime);

            displayedDateTime.Should().Contain(endTime);

            _browsers[_c.CurrentUser].Driver.WaitUntilVisible(WaitingRoomPage.ContactVhTeam).Displayed.Should().BeTrue();
        }
Exemplo n.º 18
0
        public void SidePanel_Click(object sender, RoutedEventArgs e)
        {
            if (e.ToString() == "System.Windows.Input.KeyEventArgs")
            {
                KeyEventArgs keyEventArgs = e as KeyEventArgs;
                if (!(keyEventArgs.Key.ToString() == "Space") && !(keyEventArgs.Key.ToString() == "Return"))
                {
                    return;
                }
            }

            string name = TextHelpers.get2nd((sender as Control).Name, "_");

            App.SetConfig("GUI", "CurPage", name);
            SwitchPage(name);
        }
Exemplo n.º 19
0
        protected override void WriteMatch(Capture capture)
        {
            int index = capture.Index;

            if (index >= _lastEndIndex)
            {
                int solIndex = FindStartOfLine(index);

                if (solIndex > _lastEndIndex)
                {
                    if (solIndex > 0)
                    {
                        solIndex--;

                        if (solIndex > 0 &&
                            Input[solIndex - 1] == '\r')
                        {
                            solIndex--;
                        }
                    }

                    WriteUnmatchedLines(solIndex);
                }

                _lineNumber++;
            }

            if (Options.IncludeLineNumber)
            {
                _lineNumber += TextHelpers.CountLines(Input, index, capture.Length);
            }

            int i = index + capture.Length;

            while (i < Input.Length)
            {
                if (Input[i] == '\n')
                {
                    i++;
                    break;
                }

                i++;
            }

            _lastEndIndex = i;
        }
Exemplo n.º 20
0
        private void ReloadFunctions()
        {
            bool            filtering = CbFilterFunctions.IsChecked.HasValue && CbFilterFunctions.IsChecked.Value;
            string          filter    = TbFilterForFunctions.Text;
            List <NodeData> newNodes  = new List <NodeData>();

            if (Query != null)
            {
                foreach (KeyValuePair <string, AdvancedKeywordInfo> kvp in SqlEditor.SuggestionObjects.Functions)
                {
                    if (filtering)
                    {
                        if (filter.Length <= 0)
                        {
                            continue;
                        }

                        if (kvp.Key.IndexOf(filter, StringComparison.InvariantCultureIgnoreCase) == -1)
                        {
                            continue;
                        }

                        var node = new NodeData(kvp.Value.Name)
                        {
                            Tag         = kvp.Value,
                            ImageIndex  = 5,
                            ToolTipText = TextHelpers.Wrap(kvp.Value.Description, 120)
                        };

                        newNodes.Add(node);
                    }
                    else
                    {
                        NodeData node = new NodeData(kvp.Value.Name)
                        {
                            Tag         = kvp.Value,
                            ImageIndex  = 5,
                            ToolTipText = TextHelpers.Wrap(kvp.Value.Description, 120)
                        };

                        newNodes.Add(node);
                    }
                }
            }

            FillFunctionsTree(newNodes);
        }
Exemplo n.º 21
0
        protected override void WriteStartMatch(CaptureInfo capture)
        {
            ResultStorage?.Add(capture.Value);

            if (Options.IncludeLineNumber)
            {
                _lineNumber += TextHelpers.CountLines(Input, _solIndex, capture.Index - _solIndex);
                ((LineNumberValueWriter)ValueWriter).LineNumber = _lineNumber;
            }

            int solIndex = FindStartOfLine(capture);

            if (Options.ContextBefore > 0)
            {
                WriteContextBefore(0, solIndex, _lineNumber);
            }

            Write(Options.Indent);

            if (Options.IncludeLineNumber)
            {
                WriteLineNumber(_lineNumber);
            }

            if (capture.Index >= _eolIndex)
            {
                MatchingLineCount++;

                int length = capture.Length;

                if (length > 0)
                {
                    if (Input[capture.Index + length - 1] == '\n')
                    {
                        length--;
                    }

                    MatchingLineCount += TextHelpers.CountLines(Input, capture.Index, length);
                }
            }

            _solIndex = solIndex;
            _eolIndex = FindEndOfLine(capture);

            WriteStartLine(_solIndex, capture.Index);
        }
Exemplo n.º 22
0
        protected virtual bool TryParsePaths(out ImmutableArray <PathInfo> paths)
        {
            paths = ImmutableArray <PathInfo> .Empty;

            if (Path.Any() &&
                !TryEnsureFullPath(Path, PathOrigin.Argument, out paths))
            {
                return(false);
            }

            ImmutableArray <PathInfo> pathsFromFile = ImmutableArray <PathInfo> .Empty;

            if (PathsFrom != null)
            {
                if (!FileSystemHelpers.TryReadAllText(PathsFrom, out string?content, ex => Logger.WriteError(ex)))
                {
                    return(false);
                }

                IEnumerable <string> lines = TextHelpers.ReadLines(content).Where(f => !string.IsNullOrWhiteSpace(f));

                if (!TryEnsureFullPath(lines, PathOrigin.File, out pathsFromFile))
                {
                    return(false);
                }

                paths = paths.AddRange(pathsFromFile);
            }

            if (Console.IsInputRedirected)
            {
                ImmutableArray <PathInfo> pathsFromInput = ConsoleHelpers.ReadRedirectedInputAsLines()
                                                           .Where(f => !string.IsNullOrEmpty(f))
                                                           .Select(f => new PathInfo(f, PathOrigin.RedirectedInput))
                                                           .ToImmutableArray();

                paths = paths.AddRange(pathsFromInput);
            }

            if (paths.IsEmpty)
            {
                paths = ImmutableArray.Create(new PathInfo(Environment.CurrentDirectory, PathOrigin.CurrentDirectory));
            }

            return(true);
        }
        public TransactionPreviewViewModel(Wallet wallet, TransactionInfo info, TransactionBroadcaster broadcaster,
                                           BuildTransactionResult transaction)
        {
            var destinationAmount = transaction.CalculateDestinationAmount().ToDecimal(MoneyUnit.BTC);

            var fee = transaction.Fee;

            BtcAmountText = $"{destinationAmount} bitcoins ";

            FiatAmountText = $"(≈{(destinationAmount * wallet.Synchronizer.UsdExchangeRate).FormattedFiat()} USD) ";

            Labels = info.Labels.Labels.ToArray();

            AddressText = info.Address.ToString();

            ConfirmationTimeText = $"Approximately {TextHelpers.TimeSpanToFriendlyString(info.ConfirmationTimeSpan)} ";

            BtcFeeText = $"{fee.ToDecimal(MoneyUnit.Satoshi)} satoshis ";

            FiatFeeText =
                $"(≈{(fee.ToDecimal(MoneyUnit.BTC) * wallet.Synchronizer.UsdExchangeRate).FormattedFiat()} USD)";

            NextCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                var transactionAuthorizationInfo = new TransactionAuthorizationInfo(transaction);
                var authDialog       = AuthorizationHelpers.GetAuthorizationDialog(wallet, transactionAuthorizationInfo);
                var authDialogResult = await NavigateDialog(authDialog, authDialog.DefaultTarget);

                if (authDialogResult.Result)
                {
                    IsBusy = true;

                    // Dequeue any coin-joining coins.
                    await wallet.ChaumianClient.DequeueAllCoinsFromMixAsync(DequeueReason.TransactionBuilding);

                    await broadcaster.SendTransactionAsync(transactionAuthorizationInfo.Transaction);
                    Navigate().Clear();

                    IsBusy = false;
                }
                else if (authDialogResult.Kind == DialogResultKind.Normal)
                {
                    await ShowErrorAsync("Authorization", "The Authorization has failed, please try again.", "");
                }
            });
        }
Exemplo n.º 24
0
        protected string BuildLongReply(string[] asFiles)
        {
            var dir = GetPath(string.Empty);

            var sb = new StringBuilder();

            foreach (var t in asFiles)
            {
                var file = t;
                file = Path.Combine(dir, file);

                var info = ConnectionObject.FileSystemObject.GetFileInfo(file);
                if (info == null)
                {
                    continue;
                }

                sb.Append($"{info.GetAttributeString()} 1 owner group ");

                if (info.IsDirectory())
                {
                    sb.Append("            1 ");
                }
                else
                {
                    var fileSize = info.GetSize().ToString();
                    sb.Append($"{TextHelpers.RightAlignString(fileSize, 13, ' ')} ");
                }

                var fileDate = info.GetModifiedTime();

                var day = fileDate.Day.ToString();

                sb.Append($"{TextHelpers.Month(fileDate.Month)} ");

                if (day.Length == 1)
                {
                    sb.Append(" ");
                }

                sb.AppendLine($"{day} {fileDate:hh} : {fileDate:mm} {t}");
            }

            return(sb.ToString());
        }
Exemplo n.º 25
0
 public AboutPage()
 {
     InitializeComponent();
     lblTitle.Content  = App.mName;
     lblVerNum.Content = App.mVersion;
     //lblHWID.Content = App.lic.GetUID();
     lblLicenseFor.Content = "Private non Commercial Use";
     if (App.lic.LicenseStatus == LicenseStatus.UNDEFINED)
     {
         lblUser.Content       = TextHelpers.Split2(System.Security.Principal.WindowsIdentity.GetCurrent().Name, "\\").Item2;
         lblSupporting.Content = "why are you not supporting Private WinTen? 😢";
     }
     else if (App.lic.LicenseStatus == LicenseStatus.VALID)
     {
         if (App.lic.CommercialUse)
         {
             lblLicenseFor.Content = "Commercial Use";
             lblUser.Content       = "Licensed To:";
             lblSupporting.Content = App.lic.LicenseName;
         }
         else
         {
             lblUser.Content       = App.lic.LicenseName;
             lblSupporting.Content = "is supporting Private WinTen, great! 😀";
         }
     }
     else
     {
         lblLicense.Content = "License INVALID:";
         if (App.lic.WasVoided())
         {
             lblLicenseFor.Content = "This licence has been Voided!";
         }
         else if (App.lic.HasExpired())
         {
             lblLicenseFor.Content = "This licence has Expired!";
         }
         else
         {
             lblLicenseFor.Content = "The license file is broken!";
         }
         lblUser.Content       = "Licensee Name:";
         lblSupporting.Content = App.lic.LicenseName;
     }
 }
Exemplo n.º 26
0
 private void AddVehicle(DataRow r, Person person)
 {
     if (r.ColumnOrdering.ColumnOrder.ContainsKey(DeclarationField.Vehicle))
     {
         var s = r.GetContents(DeclarationField.Vehicle).Replace("не имеет", "");
         if (!DataHelper.IsEmptyValue(s))
         {
             person.Vehicles.Add(new Vehicle(s));
         }
     }
     else if (r.ColumnOrdering.ColumnOrder.ContainsKey(DeclarationField.DeclarantVehicle))
     {
         var s = r.GetContents(DeclarationField.DeclarantVehicle).Replace("не имеет", "");
         if (!DataHelper.IsEmptyValue(s))
         {
             person.Vehicles.Add(new Vehicle(s));
         }
     }
     else if (r.ColumnOrdering.ColumnOrder.ContainsKey(DeclarationField.VehicleType))
     {
         var t = r.GetContents(DeclarationField.VehicleType).Replace("не имеет", "");
         var m = r.GetContents(DeclarationField.VehicleModel, false).Replace("не имеет", "");
         var splitVehicleModels = TextHelpers.SplitByEmptyLines(m);
         if (splitVehicleModels.Length > 1)
         {
             for (int i = 0; i < splitVehicleModels.Length; ++i)
             {
                 person.Vehicles.Add(new Vehicle(splitVehicleModels[i], "", splitVehicleModels[i]));
             }
         }
         else
         {
             var text = t + " " + m;
             if (t == m)
             {
                 text = t;
                 m    = "";
             }
             if (!DataHelper.IsEmptyValue(m) || !DataHelper.IsEmptyValue(t))
             {
                 person.Vehicles.Add(new Vehicle(text.Trim(), t, m));
             }
         }
     }
 }
Exemplo n.º 27
0
        public void TestUpdateOptionalParameterValid(ResourceId resource, TextHelpers.FieldTypes fType, Properties.Caption caption, Properties.Search search, Properties.Match match, Properties.Web web, Properties.Highlight highlight, Properties.Require require)
        {
            var guid    = GuidsForUpdate[resource].Values.First();
            var id      = UuidUtil.GetId(FieldsCreator.Data[$"{Defines.ReferenceResource[resource].First()}-{HRBCClientPrivate.API.Field.FieldType.SingleLineText.ToString()}-2"].Guid);
            var handler = new DefaultManager();
            var props   = TextHelpers.GeneratePropertiesWithoutRequired(Defines.FieldTypeApi, caption, search, match, web, highlight, require);

            props[Properties.PropertyName.Field.GetEnumStringValue()] = id;
            var request  = TextHelpers.GenerateUpdateRequest(resource, guid.ToString(), props);
            var response = handler.Send <object>(FieldManager.FieldHandlingRelativeUrl, JsonConvert.SerializeObject(request), HttpMethod.PUT);

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.NoContent));

            //Verify
            var result = (new FieldManager()).GetFieldDetails(guid);

            TextHelpers.VerifyProperties(result.Result.Values.SingleOrDefault().Value.Properties, props);
        }
Exemplo n.º 28
0
        public void TextHelpers_Decode2()
        {
            // Try parsing a unicode char that's larger than 0xFFFF

            CharacterStream cs = new CharacterStream(new StringTextProvider(@"\abcd1234"));

            Assert.IsTrue(TextHelpers.AtEscape(cs));
            Assert.IsTrue(TextHelpers.AtUnicodeEscape(cs));

            DecodedChar dc = TextHelpers.DecodeCurrentChar(cs);

            Assert.AreEqual(7, dc.EncodedLength);
            Assert.IsTrue(dc.RequiresUtf32);
            Assert.AreEqual(0xABCD12, dc.CharUtf32);
            Assert.AreEqual('\0', dc.Char);
            Assert.IsTrue(cs.Advance(dc.EncodedLength));
            Assert.AreEqual('3', cs.CurrentChar);
        }
Exemplo n.º 29
0
    public static void LoadWnd(Window wnd, string name)
    {
        string wndPos = App.GetConfig("GUI", name + "WndPos", null);

        if (wndPos != null)
        {
            var LT = TextHelpers.Split2(wndPos, ":");
            wnd.Left = MiscFunc.parseInt(LT.Item1);
            wnd.Top  = MiscFunc.parseInt(LT.Item2);
        }
        string wndSize = App.GetConfig("GUI", name + "WndSize", null);

        if (wndSize != null)
        {
            var WH = TextHelpers.Split2(wndSize, ":");
            wnd.Width  = MiscFunc.parseInt(WH.Item1);
            wnd.Height = MiscFunc.parseInt(WH.Item2);
        }
    }
Exemplo n.º 30
0
        public void TestUpdateOptionalParameterValid(ResourceId resource, TextHelpers.FieldTypes fType, Properties.Caption caption, Properties.Search search, Properties.Match match, Properties.Web web, Properties.Highlight highlight, Properties.Require require, Properties.Length length, Properties.Default deft)
        {
            var guid = TextHelpers.Guid[fType](resource, FieldsCreator, Defines.FieldTypeApi, TextHelpers.ApplicationFieldNames[Defines.FieldTypeApi]().First());

            //Update lenght to avoid missing lenght case if other tests effect to preparing data
            TextHelpers.UpdateLenghtProperty(resource, Defines.FieldTypeApi, guid);

            var handler  = new DefaultManager();
            var props    = TextHelpers.GeneratePropertiesWithoutRequired(Defines.FieldTypeApi, caption, search, match, web, highlight, require, length, deft);
            var request  = TextHelpers.GenerateUpdateRequest(resource, guid.ToString(), props);
            var response = handler.Send <object>(FieldManager.FieldHandlingRelativeUrl, JsonConvert.SerializeObject(request), HttpMethod.PUT);

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.NoContent));

            //Verify
            var result = (new FieldManager()).GetFieldDetails(guid);

            TextHelpers.VerifyProperties(result.Result.Values.SingleOrDefault().Value.Properties, props);
        }