AsDouble() public méthode

public AsDouble ( ) : double
Résultat double
Exemple #1
0
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 public static string VariantToExpressionString(Variant val)
 {
     // convert given variant to string which can be interpret as an expression.
     // this function does not convert objects ( returns empty string )
     if (val.IsVoid())
     {
         return "void";
     }
     else
     {
         if (val.IsInteger())
         {
             return val.AsString();
         }
         else
         {
             if (val.IsReal())
             {
                 string s = Variant.RealToHexString(val.AsDouble());
                 return s + " /* " + val.AsString() + " */";
             }
             else
             {
                 if (val.IsString())
                 {
                     string s = LexBase.EscapeC(val.AsString());
                     return "\"" + s + "\"";
                 }
                 else
                 {
                     if (val.IsOctet())
                     {
                         string s = Variant.OctetToListString(val.AsOctet());
                         return "<%" + s + "%>";
                     }
                     else
                     {
                         return string.Empty;
                     }
                 }
             }
         }
     }
 }
Exemple #2
0
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 public static object VariantToJavaObject(Variant param, Type type)
 {
     if (type.IsPrimitive)
     {
         // プリミティブタイプの场合
         if (type.Equals(typeof(int)))
         {
             return Sharpen.Extensions.ValueOf(param.AsInteger());
         }
         else
         {
             if (type.Equals(typeof(double)))
             {
                 return (param.AsDouble());
             }
             else
             {
                 if (type.Equals(typeof(bool)))
                 {
                     return Sharpen.Extensions.ValueOf(param.AsInteger() != 0 ? true : false);
                 }
                 else
                 {
                     if (type.Equals(typeof(float)))
                     {
                         return ((float)param.AsDouble());
                     }
                     else
                     {
                         if (type.Equals(typeof(long)))
                         {
                             return Sharpen.Extensions.ValueOf(param.AsInteger());
                         }
                         else
                         {
                             if (type.Equals(typeof(char)))
                             {
                                 return ((char)param.AsInteger());
                             }
                             else
                             {
                                 if (type.Equals(typeof(byte)))
                                 {
                                     return (unchecked((byte)param.AsInteger()));
                                 }
                                 else
                                 {
                                     if (type.Equals(typeof(short)))
                                     {
                                         return ((short)param.AsInteger());
                                     }
                                     else
                                     {
                                         // may be Void.TYPE
                                         return null;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     else
     {
         if (type.Equals(typeof(string)))
         {
             return param.AsString();
         }
         else
         {
             if (type.Equals(typeof(ByteBuffer)))
             {
                 return param.AsOctet();
             }
             else
             {
                 if (type.Equals(typeof(Variant)))
                 {
                     return param;
                 }
                 else
                 {
                     if (type.Equals(typeof(VariantClosure)))
                     {
                         return param.AsObjectClosure();
                     }
                     else
                     {
                         if (type.Equals(typeof(Dispatch2)))
                         {
                             return param.AsObject();
                         }
                         else
                         {
                             if (type.Equals(param.ToJavaObject().GetType()))
                             {
                                 return param.ToJavaObject();
                             }
                             else
                             {
                                 // その他 のクラス
                                 return null;
                             }
                         }
                     }
                 }
             }
         }
     }
 }