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


C# Dispatch2.GetNativeInstance方法代码示例

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


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

示例1: SaveStructuredDataForObject

 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 /// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
 public static void SaveStructuredDataForObject(Dispatch2 dsp, AList<Dispatch2> stack
     , TextWriteStreamInterface stream, string indentstr)
 {
     // check object recursion
     int count = stack.Count;
     for (int i = 0; i < count; i++)
     {
         Dispatch2 d = stack[i];
         if (d == dsp)
         {
             // object recursion detected
             stream.Write("null /* object recursion detected */");
             return;
         }
     }
     // determin dsp's object type
     DictionaryNI dicni;
     ArrayNI arrayni;
     if (dsp != null)
     {
         dicni = (DictionaryNI)dsp.GetNativeInstance(DictionaryClass.ClassID);
         if (dicni != null)
         {
             // dictionary
             stack.AddItem(dsp);
             dicni.SaveStructuredData(stack, stream, indentstr);
             stack.Remove(stack.Count - 1);
             return;
         }
         else
         {
             arrayni = (ArrayNI)dsp.GetNativeInstance(ArrayClass.ClassID);
             if (arrayni != null)
             {
                 // array
                 stack.AddItem(dsp);
                 arrayni.SaveStructuredData(stack, stream, indentstr);
                 stack.Remove(stack.Count - 1);
                 return;
             }
             else
             {
                 // other objects
                 stream.Write("null /* (object) \"");
                 // stored as a null
                 Variant val = new Variant(dsp, dsp);
                 stream.Write(LexBase.EscapeC(val.AsString()));
                 stream.Write("\" */");
                 return;
             }
         }
     }
     stream.Write("null");
 }
开发者ID:fantasydr,项目名称:krkr-cs,代码行数:56,代码来源:ArrayNI.cs

示例2: Assign

 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 /// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
 public virtual void Assign(Dispatch2 dsp, bool clear)
 {
     // copy members from "dsp" to "Owner"
     // determin dsp's object type
     ArrayNI arrayni = null;
     CustomObject owner = mOwner.Get();
     if (dsp != null && (arrayni = (ArrayNI)dsp.GetNativeInstance(ArrayClass.ClassID))
          != null)
     {
         // convert from array
         if (clear)
         {
             owner.Clear();
         }
         int count = arrayni.mItems.Count;
         for (int i = 0; i < count; i++)
         {
             Variant v = arrayni.mItems[i];
             string name = v.AsString();
             i++;
             if (i >= count)
             {
                 break;
             }
             Variant v2 = arrayni.mItems[i];
             owner.PropSet(Interface.MEMBERENSURE | Interface.IGNOREPROP, name, v2, owner);
         }
     }
     else
     {
         // otherwise
         if (clear)
         {
             owner.Clear();
         }
         DictionaryNI.AssignCallback callback = new DictionaryNI.AssignCallback(owner);
         dsp.EnumMembers(Interface.IGNOREPROP, callback, dsp);
     }
 }
开发者ID:fantasydr,项目名称:krkr-cs,代码行数:41,代码来源:DictionaryNI.cs

示例3: Process

 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 /// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
 protected internal override int Process(Variant result, Variant[] param, Dispatch2
     objthis)
 {
     RandomGeneratorNI _this = (RandomGeneratorNI)objthis.GetNativeInstance(Kirikiri.Tjs2.RandomGeneratorClass
         .mClassID);
     if (_this == null)
     {
         return Error.E_NATIVECLASSCRASH;
     }
     int hr = _this.Construct(param, objthis);
     if (hr < 0)
     {
         return hr;
     }
     _this.Randomize(param);
     return Error.S_OK;
 }
开发者ID:fantasydr,项目名称:krkr-cs,代码行数:19,代码来源:RandomGeneratorClass.cs

示例4: Process

 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 protected internal override int Process(Variant result, Variant[] param, Dispatch2
     objthis)
 {
     DateNI _this = (DateNI)objthis.GetNativeInstance(Kirikiri.Tjs2.DateClass.mClassID
         );
     if (_this == null)
     {
         return Error.E_NATIVECLASSCRASH;
     }
     if (param.Length < 1)
     {
         return Error.E_BADPARAMCOUNT;
     }
     _this.mDateTime.Set(Calendar.DAY_OF_MONTH, param[0].AsInteger());
     return Error.S_OK;
 }
开发者ID:fantasydr,项目名称:krkr-cs,代码行数:17,代码来源:DateClass.cs

示例5: PropSetByNum

 // property set by index number
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 /// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
 public override int PropSetByNum(int flag, int num, Variant param, Dispatch2 objthis
     )
 {
     if (!GetValidity())
     {
         return Error.E_INVALIDOBJECT;
     }
     ArrayNI ni = (ArrayNI)objthis.GetNativeInstance(ArrayClass.ClassID);
     if (ni == null)
     {
         return Error.E_NATIVECLASSCRASH;
     }
     if (num < 0)
     {
         num += ni.mItems.Count;
     }
     if (num >= ni.mItems.Count)
     {
         if ((flag & Interface.MEMBERMUSTEXIST) != 0)
         {
             return Error.E_MEMBERNOTFOUND;
         }
         //ni.mItems.resize(num+1);
         for (int i = ni.mItems.Count; i <= num; i++)
         {
             ni.mItems.AddItem(new Variant());
         }
     }
     if (num < 0)
     {
         return Error.E_MEMBERNOTFOUND;
     }
     Variant val = ni.mItems[num];
     return DefaultPropSet(flag, val, param, objthis);
 }
开发者ID:fantasydr,项目名称:krkr-cs,代码行数:38,代码来源:ArrayObject.cs

示例6: FuncCall

 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 /// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
 public override int FuncCall(int flag, string membername, Variant result, Variant
     [] param, Dispatch2 objthis)
 {
     if (membername != null)
     {
         return base.FuncCall(flag, membername, result, param, objthis);
     }
     if (param.Length < mParamTypes.Length)
     {
         return Error.E_INVALIDPARAM;
     }
     // パラメータが少ない
     if (result != null)
     {
         result.Clear();
     }
     object self;
     if (mIsStatic)
     {
         self = null;
     }
     else
     {
         // static 时は null
         if (objthis == null)
         {
             return Error.E_NATIVECLASSCRASH;
         }
         NativeJavaInstance ni = (NativeJavaInstance)objthis.GetNativeInstance(mClassID);
         if (ni == null)
         {
             return Error.E_FAIL;
         }
         self = ni.GetNativeObject();
         if (self == null)
         {
             return Error.E_NATIVECLASSCRASH;
         }
     }
     int er = Error.S_OK;
     object[] args = NativeJavaClass.VariantArrayToJavaObjectArray(param, mParamTypes);
     try
     {
         object ret = mProcess.Invoke(self, args);
         if (result != null)
         {
             NativeJavaClass.JavaObjectToVariant(result, mReturnType, ret);
         }
     }
     catch (ArgumentException)
     {
         er = Error.E_INVALIDPARAM;
     }
     catch (MemberAccessException)
     {
         er = Error.E_ACCESSDENYED;
     }
     catch (TargetInvocationException e)
     {
         Exception t = e.InnerException;
         if (t is VariantException)
         {
             throw (VariantException)t;
         }
         else
         {
             if (t is TJSException)
             {
                 throw (TJSException)t;
             }
             else
             {
                 throw new TJSException(t.ToString());
             }
         }
     }
     return er;
 }
开发者ID:fantasydr,项目名称:krkr-cs,代码行数:80,代码来源:NativeJavaClassMethod.cs

示例7: Process

 /// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
 protected internal override int Process(Variant result, Variant[] param, Dispatch2
     objthis)
 {
     RegExpNI _this = (RegExpNI)objthis.GetNativeInstance(Kirikiri.Tjs2.RegExpClass.mClassID
         );
     if (_this == null)
     {
         return Error.E_NATIVECLASSCRASH;
     }
     if (param.Length < 1)
     {
         return Error.E_BADPARAMCOUNT;
     }
     string target = param[0].AsString();
     bool purgeempty = false;
     if (param.Length >= 3)
     {
         purgeempty = param[2].AsBoolean();
     }
     Holder<Dispatch2> array = new Holder<Dispatch2>(null);
     _this.Split(array, target, purgeempty);
     if (result != null)
     {
         result.Set(array.mValue, array.mValue);
     }
     return Error.S_OK;
 }
开发者ID:fantasydr,项目名称:krkr-cs,代码行数:28,代码来源:RegExpClass.cs

示例8: PropSet

 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 /// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
 public override int PropSet(int flag, string membername, Variant param, Dispatch2
     objthis)
 {
     if (membername != null)
     {
         return base.PropSet(flag, membername, param, objthis);
     }
     if (objthis == null)
     {
         return Error.E_NATIVECLASSCRASH;
     }
     if (param == null)
     {
         return Error.E_FAIL;
     }
     if (mSet == null)
     {
         return Error.E_ACCESSDENYED;
     }
     object self;
     if (mIsStaticSet)
     {
         self = null;
     }
     else
     {
         // static 时は null
         NativeJavaInstance ni = (NativeJavaInstance)objthis.GetNativeInstance(mClassID);
         if (ni == null)
         {
             return Error.E_FAIL;
         }
         self = ni.GetNativeObject();
         if (self == null)
         {
             return Error.E_NATIVECLASSCRASH;
         }
     }
     int er = Error.S_OK;
     object arg = NativeJavaClass.VariantToJavaObject(param, mParamType);
     if (arg == null)
     {
         return Error.E_INVALIDPARAM;
     }
     object[] args = new object[1];
     args[0] = arg;
     try
     {
         mSet.Invoke(self, args);
     }
     catch (ArgumentException)
     {
         er = Error.E_INVALIDPARAM;
     }
     catch (MemberAccessException)
     {
         er = Error.E_ACCESSDENYED;
     }
     catch (TargetInvocationException e)
     {
         Exception t = e.InnerException;
         if (t is VariantException)
         {
             throw (VariantException)t;
         }
         else
         {
             if (t is TJSException)
             {
                 throw (TJSException)t;
             }
             else
             {
                 throw new TJSException(t.ToString());
             }
         }
     }
     return er;
 }
开发者ID:fantasydr,项目名称:krkr-cs,代码行数:81,代码来源:NativeJavaClassProperty.cs

示例9: PropGet

 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 /// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
 public override int PropGet(int flag, string membername, Variant result, Dispatch2
     objthis)
 {
     if (membername != null)
     {
         return base.PropGet(flag, membername, result, objthis);
     }
     if (result == null)
     {
         return Error.E_FAIL;
     }
     if (mGet == null)
     {
         return Error.E_ACCESSDENYED;
     }
     object self;
     if (mIsStaticGet)
     {
         self = null;
     }
     else
     {
         // static 时は null
         if (objthis == null)
         {
             return Error.E_NATIVECLASSCRASH;
         }
         NativeJavaInstance ni = (NativeJavaInstance)objthis.GetNativeInstance(mClassID);
         if (ni == null)
         {
             return Error.E_FAIL;
         }
         self = ni.GetNativeObject();
         if (self == null)
         {
             return Error.E_NATIVECLASSCRASH;
         }
     }
     int er = Error.S_OK;
     try
     {
         object ret = mGet.Invoke(self, new object[]{});
         NativeJavaClass.JavaObjectToVariant(result, mReturnType, ret);
     }
     catch (ArgumentException)
     {
         er = Error.E_INVALIDPARAM;
     }
     catch (MemberAccessException)
     {
         er = Error.E_ACCESSDENYED;
     }
     catch (TargetInvocationException e)
     {
         Exception t = e.InnerException;
         if (t is VariantException)
         {
             throw (VariantException)t;
         }
         else
         {
             if (t is TJSException)
             {
                 throw (TJSException)t;
             }
             else
             {
                 throw new TJSException(t.ToString());
             }
         }
     }
     return er;
 }
开发者ID:fantasydr,项目名称:krkr-cs,代码行数:75,代码来源:NativeJavaClassProperty.cs

示例10: 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

示例11: DeleteMemberByNum

 // delete member by index number
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 /// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
 public override int DeleteMemberByNum(int flag, int num, Dispatch2 objthis)
 {
     if (!GetValidity())
     {
         return Error.E_INVALIDOBJECT;
     }
     ArrayNI ni = (ArrayNI)objthis.GetNativeInstance(ArrayClass.ClassID);
     if (ni == null)
     {
         return Error.E_NATIVECLASSCRASH;
     }
     if (num < 0)
     {
         num += ni.mItems.Count;
     }
     if (num < 0 || num >= ni.mItems.Count)
     {
         return Error.E_MEMBERNOTFOUND;
     }
     ni.mItems.Remove(num);
     return Error.S_OK;
 }
开发者ID:fantasydr,项目名称:krkr-cs,代码行数:25,代码来源:ArrayObject.cs

示例12: Get

 public override int Get(Variant result, Dispatch2 objthis)
 {
     RegExpNI _this = (RegExpNI)objthis.GetNativeInstance(Kirikiri.Tjs2.RegExpClass.mClassID
         );
     if (_this == null)
     {
         return Error.E_NATIVECLASSCRASH;
     }
     result.Set(_this.mRightContext);
     return Error.S_OK;
 }
开发者ID:fantasydr,项目名称:krkr-cs,代码行数:11,代码来源:RegExpClass.cs

示例13: CreateNewByNum

 // create new object by index number
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 /// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
 public override int CreateNewByNum(int flag, int num, Holder<Dispatch2> result, Variant
     [] param, Dispatch2 objthis)
 {
     if (!GetValidity())
     {
         return Error.E_INVALIDOBJECT;
     }
     ArrayNI ni = (ArrayNI)objthis.GetNativeInstance(ArrayClass.ClassID);
     if (ni == null)
     {
         return Error.E_NATIVECLASSCRASH;
     }
     int membercount = ni.mItems.Count;
     if (num < 0)
     {
         num = membercount + num;
     }
     if ((flag & Interface.MEMBERMUSTEXIST) != 0 && (num < 0 || membercount <= num))
     {
         return Error.E_MEMBERNOTFOUND;
     }
     Variant val = new Variant((membercount <= num || num < 0) ? VoidValue : ni.mItems
         [num]);
     return DefaultCreateNew(flag, val, result, param, objthis);
 }
开发者ID:fantasydr,项目名称:krkr-cs,代码行数:28,代码来源:ArrayObject.cs

示例14: Process

 /// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
 protected internal override int Process(Variant result, Variant[] param, Dispatch2
     objthis)
 {
     DictionaryNI ni = (DictionaryNI)objthis.GetNativeInstance(Kirikiri.Tjs2.DictionaryClass
         .ClassID);
     if (ni == null)
     {
         return Error.E_NATIVECLASSCRASH;
     }
     if (!ni.IsValid())
     {
         return Error.E_INVALIDOBJECT;
     }
     if (param.Length < 1)
     {
         return Error.E_BADPARAMCOUNT;
     }
     AList<Dispatch2> stack = new AList<Dispatch2>();
     VariantClosure clo = param[0].AsObjectClosure();
     if (clo.mObjThis != null)
     {
         ni.AssignStructure(clo.mObjThis, stack);
     }
     else
     {
         if (clo.mObject != null)
         {
             ni.AssignStructure(clo.mObject, stack);
         }
         else
         {
             throw new TJSException(Error.NullAccess);
         }
     }
     return Error.S_OK;
 }
开发者ID:fantasydr,项目名称:krkr-cs,代码行数:37,代码来源:DictionaryClass.cs

示例15: AssignStructure

 /// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 public virtual void AssignStructure(Dispatch2 dsp, AList<Dispatch2> stack)
 {
     // assign structured data from dsp
     ArrayNI arrayni = (ArrayNI)dsp.GetNativeInstance(ArrayClass.ClassID);
     if (arrayni != null)
     {
         // copy from array
         stack.AddItem(dsp);
         try
         {
             mItems.Clear();
             int count = arrayni.mItems.Count;
             for (int i = 0; i < count; i++)
             {
                 Variant v = arrayni.mItems[i];
                 if (v.IsObject())
                 {
                     // object
                     Dispatch2 dsp1 = v.AsObject();
                     // determin dsp's object type
                     //DictionaryNI dicni = null;
                     //ArrayNI arrayni1 = null;
                     if (dsp1 != null && dsp1.GetNativeInstance(DictionaryClass.ClassID) != null)
                     {
                         //dicni = (DictionaryNI)ni.mValue;
                         // dictionary
                         bool objrec = false;
                         int scount = stack.Count;
                         for (int j = 0; j < scount; j++)
                         {
                             Dispatch2 d = stack[j];
                             if (d == dsp1)
                             {
                                 // object recursion detected
                                 objrec = true;
                                 break;
                             }
                         }
                         if (objrec)
                         {
                             mItems.AddItem(new Variant());
                         }
                         else
                         {
                             // becomes null
                             Dispatch2 newobj = TJS.CreateDictionaryObject();
                             mItems.AddItem(new Variant(newobj, newobj));
                             DictionaryNI newni;
                             if ((newni = (DictionaryNI)newobj.GetNativeInstance(DictionaryClass.ClassID)) !=
                                 null)
                             {
                                 newni.AssignStructure(dsp1, stack);
                             }
                         }
                     }
                     else
                     {
                         if (dsp1 != null && dsp1.GetNativeInstance(ArrayClass.ClassID) != null)
                         {
                             // array
                             bool objrec = false;
                             int scount = stack.Count;
                             for (int j = 0; j < scount; j++)
                             {
                                 Dispatch2 d = stack[j];
                                 if (d == dsp1)
                                 {
                                     // object recursion detected
                                     objrec = true;
                                     break;
                                 }
                             }
                             if (objrec)
                             {
                                 mItems.AddItem(new Variant());
                             }
                             else
                             {
                                 // becomes null
                                 Dispatch2 newobj = TJS.CreateArrayObject();
                                 mItems.AddItem(new Variant(newobj, newobj));
                                 ArrayNI newni;
                                 if ((newni = (ArrayNI)newobj.GetNativeInstance(ArrayClass.ClassID)) != null)
                                 {
                                     newni.AssignStructure(dsp1, stack);
                                 }
                             }
                         }
                         else
                         {
                             // other object types
                             mItems.AddItem(v);
                         }
                     }
                 }
                 else
                 {
                     // others
//.........这里部分代码省略.........
开发者ID:fantasydr,项目名称:krkr-cs,代码行数:101,代码来源:ArrayNI.cs


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