From 1a1c8e71fcd14858f595029f089b2d4a00202b32 Mon Sep 17 00:00:00 2001
From: ogi <Administrator@S-OGI-PC>
Date: Fri, 05 Dec 2025 09:24:16 +0900
Subject: [PATCH] プロジェクトファイルを追加。

---
 ProtosExpan/CustomTypes/DecimalValue.cs |   80 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 80 insertions(+), 0 deletions(-)

diff --git a/ProtosExpan/CustomTypes/DecimalValue.cs b/ProtosExpan/CustomTypes/DecimalValue.cs
new file mode 100644
index 0000000..3e4fdba
--- /dev/null
+++ b/ProtosExpan/CustomTypes/DecimalValue.cs
@@ -0,0 +1,80 @@
+namespace customTypes
+{
+    /// <summary>
+    /// gRPC送信用decimal
+    /// </summary>
+    public partial class DecimalValue
+    {
+        private const decimal NanoFactor = 1_000_000_000;
+        public DecimalValue(long units, int nanos)
+        {
+            Units = units;
+            Nanos = nanos;
+        }
+
+        /// <summary>
+        /// 暗然変換
+        /// decimal = DecimalValue
+        /// </summary>
+        /// <param name="grpcDecimal"></param>
+        public static implicit operator decimal(DecimalValue grpcDecimal)
+        {
+            return grpcDecimal.Units + grpcDecimal.Nanos / NanoFactor;
+        }
+
+        /// <summary>
+        /// 暗然変換
+        /// DecimalValue = decimal
+        /// </summary>
+        /// <param name="value"></param>
+        public static implicit operator DecimalValue(decimal value)
+        {
+            var units = decimal.ToInt64(value);
+            var nanos = decimal.ToInt32((value - units) * NanoFactor);
+            return new DecimalValue(units, nanos);
+        }
+
+        /// <summary>
+        /// 比較
+        /// </summary>
+        /// <param name="val"></param>
+        /// <returns></returns>
+        public int CompareTo(DecimalValue val)
+        {
+            decimal self = this;
+            decimal inVal = val;
+            return self.CompareTo(inVal);
+        }
+
+        /// <summary>
+        /// c#基本型の値を返す
+        /// </summary>
+        /// <returns></returns>
+        public decimal ToDecimal()
+        {
+            decimal self = this;
+            return self;
+        }
+
+        /// <summary>
+        /// 文字列
+        /// </summary>
+        /// <returns></returns>
+        public string ToText(string format = "")
+        {
+            decimal self = this;
+            if (format.Length > 0) { return self.ToString(format); }
+            return self.ToString();
+        }
+
+        /// <summary>
+        /// SQL文の値セット
+        /// </summary>
+        /// <returns></returns>
+        public string ToSqlValue()
+        {
+            decimal self = this;
+            return self.ToString();
+        }
+    }
+}

--
Gitblit v1.10.0