Kirikiri.Tjs2.VariantClosure.Set C# (CSharp) Method

Set() public method

public Set ( Dispatch2 obj ) : void
obj Dispatch2
return void
        public virtual void Set(Dispatch2 obj)
        {
            Set(obj, null);
        }

Same methods

VariantClosure::Set ( Dispatch2 obj, Dispatch2 objthis ) : void
VariantClosure::Set ( Kirikiri clo ) : void

Usage Example

Exemplo n.º 1
0
 /// <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 < 2)
     {
         return Error.E_BADPARAMCOUNT;
     }
     string target = param[0].AsString();
     string to = null;
     bool func;
     VariantClosure funcval = null;
     if (param[1].IsObject() != true)
     {
         to = param[1].AsString();
         func = false;
     }
     else
     {
         funcval = param[1].AsObjectClosure();
         if (funcval.mObjThis == null)
         {
             funcval.mObjThis = objthis;
         }
         func = true;
     }
     string ret = null;
     Matcher m = _this.RegEx.Matcher(target);
     if (func == false)
     {
         ret = m.ReplaceAll(to);
     }
     else
     {
         int hr;
         VariantClosure clo = new VariantClosure(null, null);
         Variant funcret = new Variant();
         Variant arrayval = new Variant(clo);
         Variant[] args = new Variant[1];
         args[0] = arrayval;
         int size = target.Length;
         ret = string.Empty;
         for (int i = 0; i < size; )
         {
             if (m.Find(i))
             {
                 ret += Sharpen.Runtime.Substring(target, i, m.Start());
                 Dispatch2 array = Kirikiri.Tjs2.RegExpClass.GetResultArray(true, _this, m);
                 clo.Set(array, array);
                 hr = funcval.FuncCall(0, null, funcret, args, null);
                 if (hr >= 0)
                 {
                     ret += funcret.AsString();
                 }
                 i = m.End();
             }
             else
             {
                 break;
             }
         }
     }
     if (result != null)
     {
         result.Set(ret);
     }
     return Error.S_OK;
 }