Beispiel #1
0
        public override void OnInvoke(MethodInterceptionArgs args)
        {
            if (RunMethodPre)
            {
                args.Proceed();
            }

            if (DefaultProvider != null && !_defaultProviderSet)
            {
                _defaultProvider    = (TypedValueProvider)Activator.CreateInstance(DefaultProvider);
                _defaultProviderSet = true;
            }

            if (GameFunction)
            {
                try
                {
                    args.ReturnValue = JsonConvert.DeserializeObject(ScriptInterface.Instance.CallGameFunction(Name, args.Arguments.ToArray()), (args.Method as MethodInfo).ReturnType);
                }
                catch
                {
                    args.ReturnValue = DefaultValue ?? _defaultProvider.Provide((args.Method as MethodInfo).ReturnType);
                }
            }
            else
            {
                args.ReturnValue = FlashUtil.Call(Name, (args.Method as MethodInfo).ReturnType, args.Arguments.ToArray());
            }
            if (RunMethodPost && !RunMethodPre)
            {
                args.Proceed();
            }
        }
Beispiel #2
0
        public override void OnGetValue(LocationInterceptionArgs args)
        {
            base.OnGetValue(args);

            if (DefaultProvider != null && !_defaultProviderSet)
            {
                _defaultProvider    = (TypedValueProvider)Activator.CreateInstance(DefaultProvider);
                _defaultProviderSet = true;
            }
            if (Get)
            {
                if (ConvertType == null)
                {
                    ConvertType = args.Location.LocationType;
                }
                try
                {
                    args.Value = Json ? JsonConvert.DeserializeObject(FlashUtil.Call(Name), ConvertType) : FlashUtil.Call(Name, ConvertType);
                }
                catch
                {
                    args.Value = _defaultProvider.Provide(ConvertType);
                }
            }
        }
Beispiel #3
0
        public override void OnGetValue(LocationInterceptionArgs args)
        {
            if (DefaultProvider != null && !_defaultProviderSet)
            {
                _defaultProvider    = (TypedValueProvider)Activator.CreateInstance(DefaultProvider);
                _defaultProviderSet = true;
            }

            if (Get)
            {
                if (RequireNotNull != null && ScriptInterface.Instance.IsNull(RequireNotNull))
                {
                    args.Value = DefaultValue ?? _defaultProvider.Provide(ConvertType);
                }
                else
                {
                    try
                    {
                        if (ConvertType == null)
                        {
                            ConvertType = args.Location.LocationType;
                        }
                        if (Select != null)
                        {
                            args.Value = JsonConvert.DeserializeObject(FlashUtil.Call("selectArrayObjects", Names[GetIndex], Select), ConvertType);
                        }
                        else
                        {
                            args.Value = JsonConvert.DeserializeObject(FlashUtil.Call("getGameObject" + (Static ? "S" : ""), Names[GetIndex]), ConvertType);
                        }
                    }
                    catch
                    {
                        args.Value = DefaultValue ?? _defaultProvider.Provide(ConvertType);
                    }
                }
            }
            else
            {
                base.OnGetValue(args);
            }
        }