Ejemplo n.º 1
0
 /// <summary>
 /// 构造一个 <see cref="BaseStore{T}"/>。
 /// </summary>
 /// <param name="accessors">给定的 <see cref="IAccessorManager"/>。</param>
 /// <param name="idGeneratorFactory">给定的 <see cref="IIdGeneratorFactory"/>。</param>
 public BaseStore(IAccessorManager accessors,
                  IIdGeneratorFactory idGeneratorFactory)
 {
     Accessors          = accessors;
     CurrentAccessor    = accessors.GetReadAccessor();
     IdGeneratorFactory = idGeneratorFactory;
 }
Ejemplo n.º 2
0
    /// <summary>
    /// 构造一个 <see cref="AbstractAccessorSeeder"/>。
    /// </summary>
    /// <param name="clock">给定的 <see cref="IClockBootstrap"/>。</param>
    /// <param name="idGeneratorFactory">给定的 <see cref="IIdGeneratorFactory"/>。</param>
    protected AbstractAccessorSeeder(IClockBootstrap clock, IIdGeneratorFactory idGeneratorFactory)
    {
        SeedBank = new ConcurrentDictionary <string, object>();

        Clock = clock;
        IdGeneratorFactory = idGeneratorFactory;
    }
Ejemplo n.º 3
0
        public static Population Read(XmlElement xmlPopulation, IGenomeReader genomeReader, IIdGeneratorFactory idGeneratorFactory)
        {
            GenomeList genomeList = new GenomeList();
            XmlNodeList listGenomes = xmlPopulation.SelectNodes("genome");
            foreach(XmlElement xmlGenome in listGenomes)
                genomeList.Add(genomeReader.Read(xmlGenome));

            IdGenerator idGenerator = idGeneratorFactory.CreateIdGenerator(genomeList);
            return new Population(idGenerator, genomeList);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes database for using Id generator.
        /// </summary>
        /// <returns>This instance.</returns>
        public KormBuilder InitDatabaseForIdGenerator()
        {
            IIdGeneratorFactory factory = IdGeneratorFactories.GetFactory(
                ConnectionSettings.ConnectionString, ConnectionSettings.KormProvider);

            using (IIdGenerator idGenerator = factory.GetGenerator(string.Empty))
            {
                idGenerator.InitDatabaseForIdGenerator();
            }
            return(this);
        }
        public static Population Read(XmlElement xmlPopulation, IGenomeReader genomeReader, IIdGeneratorFactory idGeneratorFactory, int index)
        {
            GenomeList genomeList = new GenomeList();
            XmlNodeList listGenomes = xmlPopulation.SelectNodes("genome");
            int i = 0;
            foreach (XmlElement xmlGenome in listGenomes)
            {
                if (i == index)
                {
                    genomeList.Add(genomeReader.Read(xmlGenome));
                    break;
                }
                i++;
            }

            IdGenerator idGenerator = idGeneratorFactory.CreateIdGenerator(genomeList);
            return new Population(idGenerator, genomeList);
        }
 /// <summary>
 /// 获取标识生成器。
 /// </summary>
 /// <typeparam name="TId">指定的标识类型。</typeparam>
 /// <param name="factory">给定的 <see cref="IIdGeneratorFactory"/>。</param>
 /// <param name="generatorType">给定的标识生成器类型。</param>
 /// <param name="aliase">给定的别名(可选)。</param>
 /// <returns>返回 <see cref="IIdGenerator{TId}"/>。</returns>
 public static IIdGenerator <TId> GetIdGenerator <TId>(this IIdGeneratorFactory factory,
                                                       Type generatorType, string?aliase = null)
     where TId : IEquatable <TId>
 => factory.GetIdGenerator <TId>(new TypeNamedKey(generatorType, aliase));
Ejemplo n.º 7
0
 public static Population Read(XmlDocument doc, IGenomeReader genomeReader, IIdGeneratorFactory idGeneratorFactory)
 {
     XmlElement xmlPopulation = (XmlElement)doc.SelectSingleNode("population");
     return Read(xmlPopulation, genomeReader, idGeneratorFactory);
 }
        public static Population Read(XmlDocument doc, IGenomeReader genomeReader, IIdGeneratorFactory idGeneratorFactory)
        {
            XmlElement xmlPopulation = (XmlElement)doc.SelectSingleNode("population");

            return(Read(xmlPopulation, genomeReader, idGeneratorFactory));
        }
        public static Population Read(XmlElement xmlPopulation, IGenomeReader genomeReader, IIdGeneratorFactory idGeneratorFactory)
        {
            GenomeList  genomeList  = new GenomeList();
            XmlNodeList listGenomes = xmlPopulation.SelectNodes("genome");

            foreach (XmlElement xmlGenome in listGenomes)
            {
                genomeList.Add(genomeReader.Read(xmlGenome));
            }

            IdGenerator idGenerator = idGeneratorFactory.CreateIdGenerator(genomeList);

            return(new Population(idGenerator, genomeList));
        }
 public InternalAuditingManager(IIdGeneratorFactory idGeneratorFactory,
                                IOptionsMonitor <DataExtensionOptions> optionsMonitor)
 {
     _idGeneratorFactory = idGeneratorFactory;
     _optionsMonitor     = optionsMonitor;
 }
 public PeopleService(IIdGeneratorFactory idGeneratorFactory)
 {
     _idGeneratorFactory = Check.NotNull(idGeneratorFactory, nameof(idGeneratorFactory));
 }
 public InternalTestAccessorSeeder(IOptionsMonitor <CoreExtensionOptions> options,
                                   IIdGeneratorFactory idGeneratorFactory)
     : base(options.CurrentValue.Clock, idGeneratorFactory)
 {
 }
 /// <summary>
 /// 获取雪花 64 位整型标识生成器(可生成长度 18 位的长整数标识)。
 /// </summary>
 /// <param name="factory">给定的 <see cref="IIdGeneratorFactory"/>。</param>
 /// <returns>返回 <see cref="IIdGenerator{Int64}"/>。</returns>
 public static IIdGenerator <long> GetSnowflakeIdGenerator(this IIdGeneratorFactory factory)
 => factory.GetIdGenerator <long>(typeof(SnowflakeIdGenerator));
 /// <summary>
 /// 获取 MongoDB 字符串型标识生成器(可生成长度 24 位且包含数字、字母的字符串标识)。
 /// </summary>
 /// <param name="factory">给定的 <see cref="IIdGeneratorFactory"/>。</param>
 /// <returns>返回 <see cref="IIdGenerator{String}"/>。</returns>
 public static IIdGenerator <string> GetMongoIdGenerator(this IIdGeneratorFactory factory)
 => factory.GetIdGenerator <string>(typeof(MongoIdGenerator));
 /// <summary>
 /// 获取 COMB <see cref="Guid"/> 格式的雪花标识生成器。
 /// </summary>
 /// <param name="factory">给定的 <see cref="IIdGeneratorFactory"/>。</param>
 /// <returns>返回 <see cref="IIdGenerator{Guid}"/>。</returns>
 public static IIdGenerator <Guid> GetCombSnowflakeIdGenerator(this IIdGeneratorFactory factory)
 => factory.GetIdGenerator <Guid>(typeof(CombSnowflakeIdGenerator));
    => factory.GetCombIdGeneratorForMySql();     // 使用与 MySQL 数据库相同的排序方式

    /// <summary>
    /// 获取支持 SQL Server 排序类型的 COMB 标识生成器(uniqueidentifier)。
    /// </summary>
    /// <param name="factory">给定的 <see cref="IIdGeneratorFactory"/>。</param>
    /// <returns>返回 <see cref="IIdGenerator{Guid}"/>。</returns>
    public static IIdGenerator <Guid> GetCombIdGeneratorForSqlServer(this IIdGeneratorFactory factory)
    => factory.GetIdGenerator <Guid>(typeof(CombIdGenerator), nameof(CombIdGenerators.ForSqlServer));
 /// <summary>
 /// 获取支持 SQLite 排序类型的 COMB 标识生成器(text)。
 /// </summary>
 /// <param name="factory">给定的 <see cref="IIdGeneratorFactory"/>。</param>
 /// <returns>返回 <see cref="IIdGenerator{Guid}"/>。</returns>
 public static IIdGenerator <Guid> GetCombIdGeneratorForSqlite(this IIdGeneratorFactory factory)
 => factory.GetCombIdGeneratorForMySql();     // 使用与 MySQL 数据库相同的排序方式
 /// <summary>
 /// 获取支持 Oracle 排序类型的 COMB 标识生成器(raw(16))。
 /// </summary>
 /// <param name="factory">给定的 <see cref="IIdGeneratorFactory"/>。</param>
 /// <returns>返回 <see cref="IIdGenerator{Guid}"/>。</returns>
 public static IIdGenerator <Guid> GetCombIdGeneratorForOracle(this IIdGeneratorFactory factory)
 => factory.GetIdGenerator <Guid>(typeof(CombIdGenerator), nameof(CombIdGenerators.ForOracle));