Exemple #1
0
        /// <summary>
        /// Get all the key=value pairs (pins) exposed by the implementor.
        /// </summary>
        /// <param name="item">The optional item. The item with its parts
        /// can optionally be passed to this method for those parts requiring
        /// to access further data.</param>
        /// <returns>The pins: <c>tot-count</c>=total count of pseudonyms;
        /// for each pseudonym, a <c>pseudonym</c> pin with value equal to
        /// <c>+</c>=author's pseudonym or <c>-</c>=non-author pseudonym,
        /// followed by the filtered pseudonym (including digits).
        /// </returns>
        public override IEnumerable <DataPin> GetDataPins(IItem item)
        {
            DataPinBuilder builder = new DataPinBuilder(
                DataPinHelper.DefaultFilter);

            builder.Set("tot", Pseudonyms?.Count ?? 0, false);

            if (Pseudonyms?.Count > 0)
            {
                builder.AddValues("pseudonym",
                                  from p in Pseudonyms
                                  select builder.ApplyFilter(options: true,
                                                             p.IsAuthor ? "+" : "-",
                                                             true,
                                                             p.Value));
            }

            return(builder.Build(this));
        }
        /// <summary>
        /// Get all the key=value pairs (pins) exposed by the implementor.
        /// </summary>
        /// <param name="item">The optional item. The item with its parts
        /// can optionally be passed to this method for those parts requiring
        /// to access further data.</param>
        /// <returns>The pins: collections of unique values keyed under these
        /// IDs: <c>tot-count</c>=total events count, <c>type-TAG-count</c>,
        /// <c>date-value</c>, <c>place</c> (filtered, with digits),
        /// <c>participant</c> (filtered, with digits, prefixed by tag +
        /// <c>:</c>).</returns>
        public override IEnumerable <DataPin> GetDataPins(IItem item)
        {
            DataPinBuilder builder = new DataPinBuilder(
                DataPinHelper.DefaultFilter);

            builder.Set("tot", Events?.Count ?? 0, false);

            if (Events?.Count > 0)
            {
                foreach (BioEvent e in Events)
                {
                    if (!string.IsNullOrEmpty(e.Type))
                    {
                        builder.Increase(e.Type, false, "type-");
                    }

                    if (e.Date != null)
                    {
                        builder.AddValue("date-value", e.Date.GetSortValue());
                    }

                    if (e.Places?.Count > 0)
                    {
                        builder.AddValues("place",
                                          e.Places, filter: true, filterOptions: true);
                    }

                    if (e.Participants?.Count > 0)
                    {
                        builder.AddValues("participant",
                                          from p in e.Participants
                                          select builder.ApplyFilter(options: true,
                                                                     p.Tag + ":", true, p.Id));
                    }
                }
            }

            return(builder.Build(this));
        }
Exemple #3
0
        /// <summary>
        /// Get all the key=value pairs (pins) exposed by the implementor.
        /// </summary>
        /// <param name="item">The optional item. The item with its parts
        /// can optionally be passed to this method for those parts requiring
        /// to access further data.</param>
        /// <returns>The pins: <c>tot-count</c> and a list of pins under these
        /// keys: <c>tag-place</c>=TAG:place (place filtered, with digits),
        /// <c>tag-date</c>=TAG:normalized date value, <c>date-value</c>,
        /// <c>tag-VALUE-count</c>.
        /// The normalized date value is a fixed-format number of type
        /// +0000.00 or -0000.00 allowing a text sort.
        /// </returns>
        public override IEnumerable <DataPin> GetDataPins(IItem item)
        {
            DataPinBuilder builder = new DataPinBuilder(
                DataPinHelper.DefaultFilter);

            builder.Set("tot", Chronotopes?.Count ?? 0, false);

            if (Chronotopes?.Count > 0)
            {
                foreach (Chronotope coords in Chronotopes)
                {
                    builder.Increase(coords.Tag, false, "tag-");

                    string tag = coords.Tag ?? "";
                    if (!string.IsNullOrEmpty(coords.Place))
                    {
                        builder.AddValue(
                            "tag-place",
                            builder.ApplyFilter(options: true,
                                                tag + ":",
                                                true,
                                                coords.Place));
                    }
                    if (coords.Date != null)
                    {
                        double d = coords.Date.GetSortValue();
                        builder.AddValue("date-value", d);

                        builder.AddValue(
                            "tag-date",
                            $"{tag}:{+d:0000.00;-d:0000.00}");
                    }
                }
            }

            return(builder.Build(this));
        }