public IIdGenerator CreateSnowflakeIdGenerator() { var parameters = new Dictionary <string, object> { { "WorkerIdBits", 10 }, { "WorkerId", 1 }, { "Sequence", 1 } }; return(_builder.Build(nameof(SnowflakeId), parameters)); }
private void BuildIdGenerator(XmlNode idGenNode) { if (!idGenNode.Attributes.TryGetValueAsString("Name", out string name, SmartSqlConfig.Properties)) { throw new SmartSqlException("IdGenerator.Name can not be null."); } if (!idGenNode.Attributes.TryGetValueAsString("Type", out string typeString, SmartSqlConfig.Properties)) { throw new SmartSqlException("IdGenerator.Type can not be null."); } var parameters = ParseProperties(idGenNode); var idGen = _idGeneratorBuilder.Build(typeString, parameters); SmartSqlConfig.IdGenerators.Add(name, idGen); }
protected override void BuildIdGenerator() { var settingsXPath = $"{CONFIG_PREFIX}:IdGenerator"; var idGeneratorNode = XmlConfigRoot.SelectSingleNode(settingsXPath, XmlNsManager); if (idGeneratorNode == null) { return; } if (!idGeneratorNode.Attributes.TryGetValueAsString("Type", out string typeString, SmartSqlConfig.Properties)) { throw new SmartSqlException("IdGenerator.Type can not be null."); } var parameters = ParseProperties(idGeneratorNode); SmartSqlConfig.IdGenerator = _idGeneratorBuilder.Build(typeString, parameters); }