Beispiel #1
0
 public void Write(object value, StreamAccessor accessor)
 {
     try{
         info.Invoke(null, new object[] { value, accessor });
     }catch (System.Exception e) {
         __dll__.log.WriteError(e, "独自定義ストリーム書込で例外が発生しました。");
         throw;
     }
 }
Beispiel #2
0
        public object InvokeD(System.Delegate deleg, object _arguments)
        {
            ScriptObject arguments = win.ToScriptObject(_arguments);

            Ref::ParameterInfo[] pinfos = deleg.Method.GetParameters();
            object[]             args   = new object[pinfos.Length];
            for (int i = 0; i < pinfos.Length; i++)
            {
                System.Type ptype = pinfos[i].ParameterType;
                args[i] = arguments[i.ToString()].Value;

                if (args[i] == null)
                {
                    // 既定値の採用
                    object[] attrs = pinfos[i].GetCustomAttributes(typeof(CM::DefaultValueAttribute), false);
                    if (attrs.Length != 0)
                    {
                        args[i] = ((CM::DefaultValueAttribute)attrs[0]).Value;
                    }
                    else if (ptype == typeof(Event))
                    {
                        // Event Object の場合
                        args[i] = win.@event;
                    }
                }
                else if (!ptype.IsAssignableFrom(args[i].GetType()))
                {
                    // 自動型変換
                    if (typeof(MshtmlObject).IsAssignableFrom(ptype))
                    {
                        try{
                            Ref::MethodInfo fromObj = ptype.GetMethod("FromObj", Ref::BindingFlags.Static | Ref::BindingFlags.Public);
                            args[i] = fromObj.Invoke(null, new object[] { args[i] });
                        }catch {}
                    }
                    else if (typeof(ScriptObject) == ptype)
                    {
                        args[i] = new ScriptObject(win, args[i]);
                    }
                }
            }

            object ret;

            try{
                ret = deleg.Method.Invoke(deleg.Target, args);
            }catch (System.Reflection.TargetInvocationException e) {
                if (e.InnerException == null)
                {
                    throw;
                }
                throw e.InnerException;
            }
            return(ret);
        }
Beispiel #3
0
        public override void Write(object value, StreamAccessor accessor)
        {
            const Ref::BindingFlags BF   = Ref::BindingFlags.Public | Ref::BindingFlags.NonPublic | Ref::BindingFlags.Static;
            Ref::MethodInfo         info = (Ref::MethodInfo)GetMemberInfo(value.GetType(), this.method, BF, InvokingFlags.Method_ParamObjectAccessor);

            try{
                info.Invoke(null, new object[] { value, accessor });
            }catch (System.Exception e) {
                __dll__.log.WriteError(e, "独自定義ストリーム書込で例外が発生しました。");
                throw;
            }
        }
Beispiel #4
0
            public object Read(StreamAccessor accessor)
            {
                object ret;

                try{
                    ret = info.Invoke(null, new object[] { accessor });
                }catch (System.Exception e) {
                    __dll__.log.WriteError(e, "独自定義ストリーム読込で例外が発生しました。");
                    throw;
                }
                if (!type.IsInstanceOfType(ret))
                {
                    throw new System.InvalidCastException();
                }
                return(ret);
            }
Beispiel #5
0
        public override object Read(System.Type type, StreamAccessor accessor)
        {
            const Ref::BindingFlags BF   = Ref::BindingFlags.Public | Ref::BindingFlags.NonPublic | Ref::BindingFlags.Static;
            Ref::MethodInfo         info = (Ref::MethodInfo)GetMemberInfo(type, this.method, BF, InvokingFlags.Method_ParamAccessor);
            object ret;

            try{
                ret = info.Invoke(null, new object[] { accessor });
            }catch (System.Exception e) {
                __dll__.log.WriteError(e, "独自定義ストリーム読込で例外が発生しました。");
                throw;
            }
            if (!type.IsInstanceOfType(ret))
            {
                throw new System.InvalidCastException();
            }
            return(ret);
        }