Ejemplo n.º 1
0
        public IIdGenerator CreateSnowflakeIdGenerator()
        {
            var parameters = new Dictionary <string, object>
            {
                { "WorkerIdBits", 10 },
                { "WorkerId", 1 },
                { "Sequence", 1 }
            };

            return(_builder.Build(nameof(SnowflakeId), parameters));
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }