示例#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
 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.");
 }