using ServerCore; using ServerBase; namespace ServerCommon; public enum EchoSystemMethod { None = 0, Get = 1, Put = 2, Delete = 3, Post = 4 } public static class EchoSystemHelper { public const int DoubleCalculateDigitsLong = 100; public static void checkDeltaDouble(this CaliumEventRequest request) { request.m_calium_delta = checkDouble(request.m_calium_delta); request.m_sapphire_delta = checkDouble(request.m_sapphire_delta); } public static HttpRequestMessage makeRequestMessage(EchoSystemMethod method, string urlPath) { var http_method = getMethod(method); NullReferenceCheckHelper.throwIfNull(http_method); var request = new HttpRequestMessage(http_method, urlPath); return request; } private static double checkDouble(double delta) { var delta_long = (long)(delta * DoubleCalculateDigitsLong); return delta_long / (double)DoubleCalculateDigitsLong; } private static HttpMethod? getMethod(EchoSystemMethod method) { return method switch { EchoSystemMethod.Get => new HttpMethod("GET"), EchoSystemMethod.Put => new HttpMethod("PUT"), EchoSystemMethod.Delete => new HttpMethod("DELETE"), EchoSystemMethod.Post => new HttpMethod("POST"), _ => null }; } }