/// <summary>
        /// Creates and seeds a new part.
        /// </summary>
        /// <param name="item">The item this part should belong to.</param>
        /// <param name="roleId">The optional part role ID.</param>
        /// <param name="factory">The part seeder factory. This is used
        /// for layer parts, which need to seed a set of fragments.</param>
        /// <returns>A new part.</returns>
        /// <exception cref="ArgumentNullException">item or factory</exception>
        public override IPart GetPart(IItem item, string roleId,
                                      PartSeederFactory factory)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            MsWatermarksPart part = new MsWatermarksPart();

            SetPartMetadata(part, roleId, item);

            for (int n = 1; n <= Randomizer.Seed.Next(1, 3 + 1); n++)
            {
                part.Watermarks.Add(new Faker <MsWatermark>()
                                    .RuleFor(w => w.Subject, f => f.Lorem.Word())
                                    .RuleFor(w => w.SimilarityRank, f => f.Random.Short(1, 5))
                                    .RuleFor(w => w.Description, f => f.Lorem.Sentence())
                                    .RuleFor(w => w.Place, f => f.Lorem.Word())
                                    .RuleFor(w => w.Date, HistoricalDate.Parse($"{1200 + n} AD"))
                                    .RuleFor(w => w.ExternalIds, SeederHelper.GetExternalIds(1, 3))
                                    .Generate());
            }

            return(part);
        }
Exemple #2
0
        /// <summary>
        /// Creates and seeds a new part.
        /// </summary>
        /// <param name="item">The item this part should belong to.</param>
        /// <param name="roleId">The optional part role ID.</param>
        /// <param name="factory">The part seeder factory. This is used
        /// for layer parts, which need to seed a set of fragments.</param>
        /// <returns>A new part.</returns>
        /// <exception cref="ArgumentNullException">item or factory</exception>
        public override IPart GetPart(IItem item, string roleId,
                                      PartSeederFactory factory)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            int birthYear = Randomizer.Seed.Next(1200, 1300);

            PersonPart part = new Faker <PersonPart>()
                              .RuleFor(p => p.PersonId, f => f.Lorem.Word())
                              .RuleFor(p => p.ExternalIds, SeederHelper.GetExternalIds(1, 2))
                              .RuleFor(p => p.Names, new List <PersonName>(new[]
            {
                new Faker <PersonName>()
                .RuleFor(pn => pn.Language, "lat")
                .RuleFor(pn => pn.Parts, f =>
                         new List <PersonNamePart>(new[]
                {
                    new PersonNamePart
                    {
                        Type  = "first",
                        Value = f.Lorem.Word(),
                    },
                    new PersonNamePart
                    {
                        Type  = "last",
                        Value = f.Lorem.Word(),
                    }
                }))
                .Generate()
            }))
                              .RuleFor(p => p.Sex, f => f.PickRandom('M', 'F'))
                              .RuleFor(e => e.Chronotopes, new List <Chronotope>
            {
                SeederHelper.GetChronotope("birth", birthYear),
                SeederHelper.GetChronotope("death", birthYear + 80),
            })
                              .RuleFor(p => p.Bio, f => f.Lorem.Sentence())
                              .Generate();

            SetPartMetadata(part, roleId, item);

            return(part);
        }
Exemple #3
0
        /// <summary>
        /// Creates and seeds a new part.
        /// </summary>
        /// <param name="item">The item this part should belong to.</param>
        /// <param name="roleId">The optional part role ID.</param>
        /// <param name="factory">The part seeder factory. This is used
        /// for layer parts, which need to seed a set of fragments.</param>
        /// <returns>A new part.</returns>
        /// <exception cref="ArgumentNullException">item or factory</exception>
        public override IPart GetPart(IItem item, string roleId,
                                      PartSeederFactory factory)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            PersonEventsPart part = new PersonEventsPart();

            SetPartMetadata(part, roleId, item);

            for (int n = 1; n <= Randomizer.Seed.Next(1, 3 + 1); n++)
            {
                part.Events.Add(new Faker <BioEvent>()
                                .RuleFor(e => e.Type, f => n == 1?
                                         "birth" : f.PickRandom("work", "marriage"))
                                .RuleFor(e => e.Date, HistoricalDate.Parse($"{n} AD"))
                                .RuleFor(e => e.Places,
                                         f => new List <string>(new[] { f.Lorem.Word() }))
                                .RuleFor(e => e.Description, f => f.Lorem.Sentence())
                                .RuleFor(e => e.Sources, SeederHelper.GetDocReferences(1, 3))
                                .RuleFor(e => e.Participants, SeederHelper.GetDecoratedIds(1, 3))
                                .RuleFor(e => e.Work, f => f.Lorem.Sentence(1, 3))
                                .RuleFor(e => e.Rank, f => f.Random.Short(0, 3))
                                .RuleFor(e => e.IsWorkDubious, f => f.Random.Bool(0.2f))
                                .RuleFor(e => e.IsWorkLost, f => f.Random.Bool(0.2f))
                                .RuleFor(e => e.ExternalIds, SeederHelper.GetExternalIds(1, 3))
                                .Generate());
            }

            return(part);
        }