Files
DP44/Common/DTS.Common.Utilities/FirmwareVersionToLong.cs
2026-04-17 14:55:32 -04:00

34 lines
939 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.Common.Utilities
{
/// <summary>
/// produces a long value given a firmware version in string representation
/// </summary>
public class FirmwareVersionToLong
{
/// <summary>
/// Produces a long value given a firmware version represented as a string
/// </summary>
/// <param name="version">firmware version</param>
/// <returns>firmware version as a long</returns>
public static long Query(string version)
{
var result = 0L;
var chars = version.Length > 4 ? 4 : version.Length;
var shift = 48;
for (var i = 0; i < chars; i++)
{
result += version[i] << shift;
shift -= 16;
}
return result;
}
}
}