/// <summary> /// Set the default instance of <see cref="IdGen"/>. /// </summary> /// <param name="idGen">The instace of <see cref="IdGen"/>.</param> public static void SetDefault(IdGen idGen = null) { if (Instance != null) { throw new InvalidOperationException("Can't set default instance of IdGen twice."); } Instance = idGen ?? new IdGen(); }
/// <summary> /// Specify an unique id of current machine. /// </summary> /// <param name="machineId">An unique id of current machine.</param> public static void SetMachineId(ushort machineId) { if (_instance != null) { throw new InvalidOperationException("Can't set machine id twice."); } _instance = new IdGen(machineId); }
/// <summary> /// Specify an unique id of current machine. /// </summary> public static void Init( ushort machineId, byte machineIdBits = DefaultMachineIdBits, byte sequenceBits = DefaultSequenceBits) { if (_instance != null) { throw new InvalidOperationException("Can't set machine id twice."); } _instance = new IdGen(machineId, machineIdBits, sequenceBits); }