Exemplo n.º 1
0
 public DWSMethodDefinition(string name, NativeAction callback)
 {
     _name        = name;
     _callback    = callback;
     _args        = new DelphiArray <DWSParameterDefinition>();
     _comCallback = Callback;
 }
Exemplo n.º 2
0
        internal NativeEvaluator EvaluateCallArgs(string actionName, NativeAction action, IEnumerable <string> parameters, IEnumerable <ParameterEvaluator> evaluators)
        {
            var actionId = NativeActionPrefix + actionName;

            _nativeActions.Add(actionId, action);

            AddSpanElement(actionId);

            return(e =>
            {
                var evaluatedConstraints = new Constraints();
                foreach (var parameter in parameters.Zip(evaluators, Tuple.Create))
                {
                    var evaluatedParameter = parameter.Item2(e, parameter.Item1);
                    if (evaluatedParameter == null)
                    {
                        return null;
                    }

                    evaluatedConstraints = evaluatedConstraints.AddValue(parameter.Item1, evaluatedParameter);
                }

                return SemanticItem.From(e.Item.Question, actionId, evaluatedConstraints);
            });
        }
 static CallbackHandler()
 {
     preRenderQueuesCallback    = new NativeAction(preRenderQueues);
     postRenderQueuesCallback   = new NativeAction(postRenderQueues);
     renderQueueStartedCallback = new ByteStringBoolRenderQueueEvent(renderQueueStarted);
     renderQueueEndedCallback   = new ByteStringBoolRenderQueueEvent(renderQueueEnded);
 }
Exemplo n.º 4
0
 static CallbackHandler()
 {
     onInitCB = new OnInitDelegate(OnInitStatic);
     onExitCB = new OnExitDelegate(OnExitStatic);
     onIdleCB = new NativeAction(OnIdleStatic);
     onMovedToBackgroundCB = new NativeAction(OnMovedToBackgroundStatic);
     onMovedToForegroundCB = new NativeAction(OnMovedToForegroundStatic);
 }
 static CallbackHandler()
 {
     preRenderTargetUpdateCb  = preRenderTargetUpdate;
     postRenderTargetUpdateCb = postRenderTargetUpdate;
     preViewportUpdateCb      = preViewportUpdate;
     postViewportUpdateCb     = postViewportUpdate;
     viewportAddedCb          = viewportAdded;
     viewportRemovedCb        = viewportRemoved;
 }
Exemplo n.º 6
0
        private void PickImage(NativeAction actionPick)
        {
#if UNITY_ANDROID
            NativeGallery.RequestPermission((result, action) =>
            {
                if (result == (int)NativeGallery.Permission.Granted)
                {
                    NativeGallery.GetImageFromGalleryForAndroid((path) =>
                    {
                        if (path.IsNotNullAndEmpty())
                        {
                            mPhotoPath = path;
                            ImageDownloadUtils.Instance.SetAsyncImage("file://" + path, ImgPhoto);
                            BtnDel.gameObject.SetActive(true);
                        }
                        Debug.Log("Image path: " + path);
                    }, "选择图片", "image/*", false, action);
                }
            }, (int)actionPick);
#elif UNITY_IOS
            // NativeGallery.Permission rest;
            if (actionPick == NativeAction.Album)
            {
                NativeGallery.Permission rest = NativeGallery.RequestIPhonePermission(1);
                if (rest == NativeGallery.Permission.Granted)
                {
                    NativeGallery.GetImageFromGallery((backPath) =>
                    {
                        if (backPath.IsNotNullAndEmpty())
                        {
                            mPhotoPath = backPath;
                            ImageDownloadUtils.Instance.SetAsyncImage("file://" + backPath, ImgPhoto, false);
                            BtnDel.gameObject.SetActive(true);
                        }
                    }, "选择图片", "image/*");
                }
            }
            else if (actionPick == NativeAction.Camera)
            {
                NativeGallery.Permission rest = NativeGallery.RequestIPhonePermission(4);
                if (rest == NativeGallery.Permission.Granted)
                {
                    NativeGallery.GetIPhoneCameraImageFromGallery((backPath) =>
                    {
                        if (backPath.IsNotNullAndEmpty())
                        {
                            mPhotoPath = backPath;
                            ImageDownloadUtils.Instance.SetAsyncImage("file://" + backPath, ImgPhoto, false);
                            BtnDel.gameObject.SetActive(true);
                        }
                    }, "选择图片", "image/*");
                }
            }
#else
#endif
        }
Exemplo n.º 7
0
 static CallbackHandler()
 {
     deleteCB   = new NativeAction(DeleteStatic);
     sizedCB    = new NativeAction(ResizeStatic);
     closingCB  = new NativeAction(ClosingStatic);
     closedCB   = new NativeAction(ClosedStatic);
     activateCB = new ActivateCB(ActivateStatic);
     createInternalResourcesCB  = new ModifyResourcesCB(CreateInternalResourcesStatic);
     destroyInternalResourcesCB = new ModifyResourcesCB(DestroyInternalResourcesStatic);
 }
Exemplo n.º 8
0
        public DataContainer HowToDo(string actionName, NativeAction action)
        {
            var evaluatorId = NativeActionPrefix + actionName;

            HowToDo(evaluatorId);

            _nativeActions.Add(evaluatorId, action);
            AddSpanElement(evaluatorId);

            return(this);
        }
Exemplo n.º 9
0
        internal NativeEvaluator EvaluateCallArgsSpan(string actionName, NativeAction action, params string[] parameters)
        {
            var evaluators = new List <ParameterEvaluator>();

            foreach (var parameter in parameters)
            {
                ParameterEvaluator evaluator = (e, p) => e.EvaluateOne(p);
                evaluators.Add(evaluator);
            }

            return(EvaluateCallArgs(actionName, action, parameters, evaluators));
        }
Exemplo n.º 10
0
        private void processAbilityPattern()
        {
            var parametersCopy = _parameters.ToArray();
            var methodCopy     = _method;
            var methodName     = _method.Name;
            var nativeActionId = DataContainer.NativeActionPrefix + _method.Name;

            NativeEvaluator evaluator = c =>
            {
                var evaluatedValues = new List <Tuple <string, SemanticItem> >();
                var context         = new ModuleContext(c);
                foreach (var parameterPair in parametersCopy)
                {
                    var parameter = parameterPair.Item1;
                    var source    = parameterPair.Item2;

                    var value = context.Evaluate(parameter, source);
                    evaluatedValues.Add(Tuple.Create(parameter.Name, value));
                }

                var prerequisitiesSatisfied = evaluatedValues.All(t => t.Item2 != null);
                if (!prerequisitiesSatisfied)
                {
                    return(null);
                }

                var call = encodeCall(nativeActionId, evaluatedValues);
                return(call);
            };

            NativeAction action = c =>
            {
                var arguments = decodeArguments(parametersCopy.Select(t => t.Item1), c);
                methodCopy.Invoke(this, arguments);
                return(true);
            };

            Container.Pattern(_currentPattern)
            .HowToDo(methodName, evaluator)
            .AddNativeAction(nativeActionId, action);
        }
        private static extern IntPtr NativeRenderQueue_Create(NativeAction preRender, NativeAction postRender, ByteStringBoolRenderQueueEvent renderStarted, ByteStringBoolRenderQueueEvent renderEnded
#if FULL_AOT_COMPILE
                                                              , IntPtr instanceHandle
#endif
                                                              );
Exemplo n.º 12
0
        private static extern void App_registerDelegates(IntPtr app, OnInitDelegate onInitCB, OnExitDelegate onExitCB, NativeAction onIdleCB, NativeAction onMovedToBackgroundCB, NativeAction onMovedToForegroundCB
#if FULL_AOT_COMPILE
                                                         , IntPtr instanceHandle
#endif
                                                         );
Exemplo n.º 13
0
        private static extern IntPtr ManagedRenderTargetListener_Create(NativeAction preRenderTargetUpdateCb, NativeAction postRenderTargetUpdateCb, NativeAction preViewportUpdateCb, NativeAction postViewportUpdateCb, NativeAction viewportAddedCb, NativeAction viewportRemovedCb
#if FULL_AOT_COMPILE
                                                                        , IntPtr instanceHandle
#endif
                                                                        );
Exemplo n.º 14
0
 internal void AddNativeAction(string nativeActionId, NativeAction action)
 {
     _nativeActions.Add(nativeActionId, action);
     AddSpanElement(nativeActionId);
 }
Exemplo n.º 15
0
        private static extern void NativeOSWindow_setCallbacks(IntPtr nativeWindow, NativeAction deleteCB, NativeAction sizedCB, NativeAction closingCB, NativeAction closedCB, ActivateCB activateCB, ModifyResourcesCB createInternalResourcesCB, ModifyResourcesCB destroyInternalResourcesCB
#if FULL_AOT_COMPILE
                                                               , IntPtr instanceHandle
#endif
                                                               );
 static CallbackHandler()
 {
     prepareResourceCallback = new NativeAction(prepareResource);
     loadResourceCallback    = new NativeAction(loadResource);
 }
        private static extern IntPtr ManagedManualResourceLoader_Create(NativeAction prepareResource, NativeAction loadResource
#if FULL_AOT_COMPILE
                                                                        , IntPtr instanceHandle
#endif
                                                                        );