コード例 #1
0
        public WebElementInstruction(string what) : this()
        {
            what = " " + what + " ";
            var regex = new Regex("^" +
                                  Optional(CapturingGroup("Order", NumberStrippingOffNthTextSuffix)) +
                                  Optional(CapturingGroup("SubjectTagName", $"\\s?{NotPrecedingAnyControlWord}(button){SpaceOrEnd}|(link){SpaceOrEnd}|(input){SpaceOrEnd}|(textfield){SpaceOrEnd}|(textarea){SpaceOrEnd}")) +
                                  Optional(CapturingGroup("Accuracy", $"\\s?{NotPrecedingAnyControlWord}(like)\\s?")) +
                                  CapturingGroup("Subject") +
                                  Optional(
                                      CapturingGroup("Direction",
                                                     Or(
                                                         ControlWord("next to"),
                                                         ControlWord("under"),
                                                         ControlWord("above"),
                                                         ControlWord("below"),
                                                         ControlWord("left from"),
                                                         ControlWord("right from"),
                                                         ControlWord("near"),
                                                         ControlWord("from left"),
                                                         ControlWord("from right"),
                                                         ControlWord("from top"),
                                                         ControlWord("from bottom")
                                                         ))) +
                                  Optional(CapturingGroup("Locale")) +
                                  Optional(ControlWord("inside") + CapturingGroup("Area")) +
                                  Optional(ControlWord("with") + CapturingGroup("Text"))
                                  + "$", RegexOptions.IgnoreCase);

            var result = regex.Match(what);

            if (result.Success == false)
            {
                SubjectName = what;
            }
            else
            {
                var orderString = GetCapturedValue(result, "Order") ?? string.Empty;
                orderString      = ParseNumber(orderString);
                Order            = string.IsNullOrEmpty(orderString)?(int?)null: int.Parse(orderString) - 1;
                Direction        = ParseDirection(GetCapturedValue(result, "Direction"));
                Locale           = GetCapturedValue(result, "Locale");
                With             = GetCapturedValue(result, "Text");
                Accuracy         = GetCapturedValue(result, "Accuracy")?.ToLower() == "like"?CompareAccuracy.Partial : CompareAccuracy.Exact;
                Area             = GetCapturedValue(result, "Area");
                SubjectName      = GetCapturedValue(result, "Subject");
                this.SubjectType = MapToSubjectTypeAndAddTagnamesRange(GetCapturedValue(result, "SubjectTagName"), TagNames);
                if (!TagNames.Any())
                {
                    TagNames = null;
                }
            }
        }
コード例 #2
0
 public EditPlotFolderViewModel([NotNull] PlotFolder folder, int?currentUserId, IUriService uriService)
 {
     if (folder == null)
     {
         throw new ArgumentNullException(nameof(folder));
     }
     PlotFolderId = folder.PlotFolderId;
     TodoField    = folder.TodoField;
     ProjectId    = folder.ProjectId;
     Fill(folder, currentUserId, uriService);
     if (TagNames.Any())
     {
         PlotFolderTitleAndTags = folder.MasterTitle + " " + folder.PlotTags.GetTagString();
     }
     else
     {
         PlotFolderTitleAndTags = folder.MasterTitle;
     }
 }
コード例 #3
0
ファイル: ItemQuery.cs プロジェクト: ofer987/Financier
        public ItemResult GetResults()
        {
            Item[] items;
            using (var db = new Context())
            {
                items = (
                    from i in db.Items
                    join s in db.Statements on i.StatementId equals s.Id
                    join c in db.Cards on s.CardId equals c.Id
                    join a in db.Accounts on c.AccountName equals a.Name
                    join it in db.ItemTags on i.Id equals it.ItemId
                    join t in db.Tags on it.TagId equals t.Id
                    where true &&
                    a.Name == AccountName &&
                    i.PostedAt >= From &&
                    i.PostedAt < To &&
                    (
                        ItemType == ItemTypes.Debit && i.Amount >= 0 ||
                        ItemType == ItemTypes.Credit && i.Amount < 0
                    ) &&
                    TagNames.Any(tagName => tagName == t.Name)
                    select i
                    )
                        .Include(item => item.ItemTags)
                        .ThenInclude(itemTag => itemTag.Tag)
                        .Include(item => item.Statement)
                        .ThenInclude(s => s.Card)
                        .AsEnumerable()
                        .ToArray();
            }

            var externalItems = items
                                .Reject(item => item.Tags.HasInternalTransfer())
                                .Distinct()
                                .ToArray();

            return(new ItemResult(this, externalItems));
        }