当前位置: 首页>>代码示例>>C#>>正文


C# Variant.AsInteger方法代码示例

本文整理汇总了C#中Kirikiri.Tjs2.Variant.AsInteger方法的典型用法代码示例。如果您正苦于以下问题:C# Variant.AsInteger方法的具体用法?C# Variant.AsInteger怎么用?C# Variant.AsInteger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Kirikiri.Tjs2.Variant的用法示例。


在下文中一共展示了Variant.AsInteger方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetStringProperty

 /// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 private static void GetStringProperty(Variant result, Variant str, Variant member
     )
 {
     // processes properties toward strings.
     if (member.IsNumber() != true)
     {
         string name = member.GetString();
         if (name == null)
         {
             ThrowFrom_tjs_error(Error.E_MEMBERNOTFOUND, string.Empty);
         }
         if (name.Equals("length"))
         {
             // get string length
             string s = str.AsString();
             if (s == null)
             {
                 result.Set(0);
             }
             else
             {
                 // tTJSVariantString::GetLength can return zero if 'this' is NULL
                 result.Set(s.Length);
             }
             return;
         }
         else
         {
             if (name[0] >= '0' && name[0] <= '9')
             {
                 string s = str.AsString();
                 int n = int.Parse(name);
                 int len = s.Length;
                 if (n == len)
                 {
                     result.Set(string.Empty);
                     return;
                 }
                 if (n < 0 || n > len)
                 {
                     throw new TJSException(Error.RangeError);
                 }
                 result.Set(Sharpen.Runtime.Substring(s, n, n + 1));
                 return;
             }
         }
         ThrowFrom_tjs_error(Error.E_MEMBERNOTFOUND, name);
     }
     else
     {
         // member.Type() == tvtInteger || member.Type() == tvtReal
         string s = str.AsString();
         int n = member.AsInteger();
         int len = s.Length;
         if (n == len)
         {
             result.Set(string.Empty);
             return;
         }
         if (n < 0 || n > len)
         {
             throw new TJSException(Error.RangeError);
         }
         result.Set(Sharpen.Runtime.Substring(s, n, n + 1));
         return;
     }
 }
开发者ID:fantasydr,项目名称:krkr-cs,代码行数:69,代码来源:NativeConvertedClassBase.cs

示例2: TypeOfMemberIndirect

 /// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 protected internal static void TypeOfMemberIndirect(Variant result, Variant target
     , Variant member, Dispatch2 objthis, int flags)
 {
     if (target.IsObject())
     {
         VariantClosure clo = target.AsObjectClosure();
         if (member.IsInteger() != true)
         {
             string str = member.AsString();
             int hr = clo.PropGet(flags, str, result, clo.mObjThis != null ? clo.mObjThis : objthis
                 );
             if (hr == Error.S_OK)
             {
                 TypeOf(result);
             }
             else
             {
                 if (hr == Error.E_MEMBERNOTFOUND)
                 {
                     result.Set("undefined");
                 }
                 else
                 {
                     if (hr < 0)
                     {
                         ThrowFrom_tjs_error(hr, str);
                     }
                 }
             }
         }
         else
         {
             int hr = clo.PropGetByNum(flags, member.AsInteger(), result, clo.mObjThis != null
                  ? clo.mObjThis : objthis);
             if (hr == Error.S_OK)
             {
                 TypeOf(result);
             }
             else
             {
                 if (hr == Error.E_MEMBERNOTFOUND)
                 {
                     result.Set("undefined");
                 }
                 else
                 {
                     if (hr < 0)
                     {
                         ThrowFrom_tjs_error_num(hr, member.AsInteger());
                     }
                 }
             }
         }
     }
     else
     {
         if (target.IsString())
         {
             GetStringProperty(result, target, member);
             TypeOf(result);
         }
         else
         {
             if (target.IsOctet())
             {
                 GetOctetProperty(result, target, member);
                 TypeOf(result);
             }
             else
             {
                 string mes = Error.VariantConvertErrorToObject.Replace("%1", Utils.VariantToReadableString
                     (target));
                 throw new VariantException(mes);
             }
         }
     }
 }
开发者ID:fantasydr,项目名称:krkr-cs,代码行数:79,代码来源:NativeConvertedClassBase.cs

示例3: GetOctetProperty

 /// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 private static void GetOctetProperty(Variant result, Variant octet, Variant member
     )
 {
     // processes properties toward octets.
     if (member.IsNumber() != true)
     {
         string name = member.GetString();
         if (name == null)
         {
             ThrowFrom_tjs_error(Error.E_MEMBERNOTFOUND, string.Empty);
         }
         if (name.Equals("length"))
         {
             // get string length
             ByteBuffer o = octet.AsOctet();
             if (o != null)
             {
                 result.Set(o.Capacity());
             }
             else
             {
                 result.Set(0);
             }
             return;
         }
         else
         {
             if (name[0] >= '0' && name[0] <= '9')
             {
                 ByteBuffer o = octet.AsOctet();
                 int n = int.Parse(name);
                 int len = o != null ? o.Capacity() : 0;
                 if (n < 0 || n >= len)
                 {
                     throw new TJSException(Error.RangeError);
                 }
                 result.Set(o.Get(n));
                 return;
             }
         }
         ThrowFrom_tjs_error(Error.E_MEMBERNOTFOUND, name);
     }
     else
     {
         // member.Type() == tvtInteger || member.Type() == tvtReal
         ByteBuffer o = octet.AsOctet();
         int n = member.AsInteger();
         int len = o != null ? o.Capacity() : 0;
         if (n < 0 || n >= len)
         {
             throw new TJSException(Error.RangeError);
         }
         result.Set(o.Get(n));
         return;
     }
 }
开发者ID:fantasydr,项目名称:krkr-cs,代码行数:58,代码来源:NativeConvertedClassBase.cs

示例4: SetPropertyIndirect

 /// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 protected internal static void SetPropertyIndirect(Variant target, Variant member
     , Variant param, Dispatch2 objthis, int flags)
 {
     if (target.IsObject())
     {
         VariantClosure clo = target.AsObjectClosure();
         if (member.IsInteger() != true)
         {
             string str = member.AsString();
             int hr = clo.PropSet(flags, str, param, clo.mObjThis != null ? clo.mObjThis : objthis
                 );
             if (hr < 0)
             {
                 ThrowFrom_tjs_error(hr, str);
             }
         }
         else
         {
             int hr = clo.PropSetByNum(flags, member.AsInteger(), param, clo.mObjThis != null ?
                 clo.mObjThis : objthis);
             if (hr < 0)
             {
                 ThrowFrom_tjs_error_num(hr, member.AsInteger());
             }
         }
     }
     else
     {
         if (target.IsString())
         {
             SetStringProperty(param, target, member);
         }
         else
         {
             if (target.IsOctet())
             {
                 SetOctetProperty(param, target, member);
             }
             else
             {
                 string mes = Error.VariantConvertErrorToObject.Replace("%1", Utils.VariantToReadableString
                     (target));
                 throw new VariantException(mes);
             }
         }
     }
 }
开发者ID:fantasydr,项目名称:krkr-cs,代码行数:49,代码来源:NativeConvertedClassBase.cs

示例5: CharacterCodeFrom

 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 public static void CharacterCodeFrom(Variant val)
 {
     char[] ch = new char[1];
     ch[0] = (char)val.AsInteger();
     val.Set(new string(ch));
 }
开发者ID:fantasydr,项目名称:krkr-cs,代码行数:7,代码来源:NativeConvertedClassBase.cs

示例6: OperatePropertyIndirect0

 /// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 protected internal static void OperatePropertyIndirect0(VariantClosure clo, Variant
     name, Variant result, Dispatch2 objthis, int ope)
 {
     if (name.IsInteger() != true)
     {
         string str = name.AsString();
         int hr = clo.Operation(ope, str, result, null, clo.mObjThis != null ? clo.mObjThis
              : objthis);
         if (hr < 0)
         {
             ThrowFrom_tjs_error(hr, str);
         }
     }
     else
     {
         int hr = clo.OperationByNum(ope, name.AsInteger(), result, null, clo.mObjThis !=
             null ? clo.mObjThis : objthis);
         if (hr < 0)
         {
             ThrowFrom_tjs_error_num(hr, name.AsInteger());
         }
     }
 }
开发者ID:fantasydr,项目名称:krkr-cs,代码行数:25,代码来源:NativeConvertedClassBase.cs

示例7: VariantToJavaObject

 /// <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();
//.........这里部分代码省略.........
开发者ID:fantasydr,项目名称:krkr-cs,代码行数:101,代码来源:NativeJavaClass.cs

示例8: Set

 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 public override int Set(Variant param, Dispatch2 objthis)
 {
     RegExpNI _this = (RegExpNI)objthis.GetNativeInstance(Kirikiri.Tjs2.RegExpClass.mClassID
         );
     if (_this == null)
     {
         return Error.E_NATIVECLASSCRASH;
     }
     _this.mStart = param.AsInteger();
     return Error.S_OK;
 }
开发者ID:fantasydr,项目名称:krkr-cs,代码行数:12,代码来源:RegExpClass.cs

示例9: CallSetMissing

 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 /// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
 private bool CallSetMissing(string name, Variant value)
 {
     // call 'missing' method for PopSet
     if (mProsessingMissing)
     {
         return false;
     }
     mProsessingMissing = true;
     bool res = false;
     try
     {
         Variant val = new Variant(value);
         SimpleGetSetProperty prop = new SimpleGetSetProperty(val);
         try
         {
             Variant[] args = new Variant[3];
             args[0] = new Variant(1);
             // true: set
             args[1] = new Variant(name);
             // member name
             args[2] = new Variant(prop);
             //tTJSVariant *pargs[3] = {args +0, args +1, args +2};
             Variant funcresult = new Variant();
             int er = FuncCall(0, mmissing_name, funcresult, args, this);
             if (er < 0)
             {
                 res = false;
             }
             else
             {
                 res = funcresult.AsInteger() != 0;
             }
         }
         finally
         {
         }
     }
     finally
     {
         //prop.Release();
         mProsessingMissing = false;
     }
     return res;
 }
开发者ID:fantasydr,项目名称:krkr-cs,代码行数:46,代码来源:CustomObject.cs

示例10: Randomize


//.........这里部分代码省略.........
                     {
                         throw new TJSException(Error.NullAccess);
                     }
                     string state;
                     Variant val = new Variant();
                     data = new MersenneTwisterData();
                     // get state array
                     //TJSThrowFrom_tjs_error
                     int hr = clo.PropGet(Interface.MEMBERMUSTEXIST, "state", val, null);
                     if (hr < 0)
                     {
                         Error.ThrowFrom_tjs_error(hr, null);
                     }
                     state = val.AsString();
                     if (state.Length != MT_N * 8)
                     {
                         throw new TJSException(Error.NotReconstructiveRandomizeData);
                     }
                     int p = 0;
                     for (int i = 0; i < MT_N; i++)
                     {
                         long n = 0;
                         int tmp;
                         for (int j = 0; j < 8; j++)
                         {
                             int c = state[p + j];
                             tmp = -1;
                             if (c >= '0' && c <= '9')
                             {
                                 n = c - '0';
                             }
                             else
                             {
                                 if (c >= 'a' && c <= 'f')
                                 {
                                     n = c - 'a' + 10;
                                 }
                                 else
                                 {
                                     if (c >= 'A' && c <= 'F')
                                     {
                                         n = c - 'A' + 10;
                                     }
                                 }
                             }
                             if (tmp == -1)
                             {
                                 throw new TJSException(Error.NotReconstructiveRandomizeData);
                             }
                             else
                             {
                                 n <<= 4;
                                 n += tmp;
                             }
                         }
                         p += 8;
                         data.state.Put(i, n & unchecked((long)(0xffffffffL)));
                     }
                     // get other members
                     hr = clo.PropGet(Interface.MEMBERMUSTEXIST, "left", val, null);
                     if (hr < 0)
                     {
                         Error.ThrowFrom_tjs_error(hr, null);
                     }
                     data.left = val.AsInteger();
                     hr = clo.PropGet(Interface.MEMBERMUSTEXIST, "next", val, null);
                     data.next = val.AsInteger();
                     if (mGenerator != null)
                     {
                         mGenerator = null;
                     }
                     mGenerator = new MersenneTwister(data);
                 }
                 catch (VariantException)
                 {
                     data = null;
                     throw new TJSException(Error.NotReconstructiveRandomizeData);
                 }
                 catch (TJSException)
                 {
                     data = null;
                     throw new TJSException(Error.NotReconstructiveRandomizeData);
                 }
                 data = null;
             }
             else
             {
                 // 64bitじゃなくて、32bit にしてしまっている。实用上问题あれば修正。
                 int n = param[0].AsInteger();
                 int[] tmp = new int[1];
                 tmp[0] = n;
                 if (mGenerator != null)
                 {
                     mGenerator = null;
                 }
                 mGenerator = new MersenneTwister(tmp);
             }
         }
     }
 }
开发者ID:fantasydr,项目名称:krkr-cs,代码行数:101,代码来源:RandomGeneratorNI.cs


注:本文中的Kirikiri.Tjs2.Variant.AsInteger方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。