コード例 #1
0
 public override double CreateType(IJsonStruct jsonStruct)
 {
     if (jsonStruct == null)
     {
         return(default(double));
     }
     else if (jsonStruct is IJsonFloat jf)
     {
         return(jf.Float);
     }
     throw new Exception($"Cannot convert {jsonStruct.GetType().FullName} to a double.");
 }
コード例 #2
0
ファイル: TypeHandlerInt.cs プロジェクト: aarrgard/solidjson
 public override int CreateType(IJsonStruct jsonStruct)
 {
     if (jsonStruct == null)
     {
         return(default(int));
     }
     else if (jsonStruct is IJsonInteger js)
     {
         return((int)js.Integer);
     }
     throw new Exception($"Cannot convert {jsonStruct.GetType().FullName} to a string.");
 }
コード例 #3
0
 public override bool CreateType(IJsonStruct jsonStruct)
 {
     if (jsonStruct == null)
     {
         return(default(bool));
     }
     else if (jsonStruct is IJsonBoolean jb)
     {
         return(jb.Boolean);
     }
     throw new Exception($"Cannot convert {jsonStruct.GetType().FullName} to a boolean.");
 }
コード例 #4
0
 public override string CreateType(IJsonStruct jsonStruct)
 {
     if (jsonStruct == null)
     {
         return(null);
     }
     else if (jsonStruct is IJsonString js)
     {
         return(js.String);
     }
     throw new Exception($"Cannot convert {jsonStruct.GetType().FullName} to a string.");
 }