Neutronium.Core.Binding.CSharpToJavascriptConverter.InternalMap C# (CSharp) Method

InternalMap() public method

public InternalMap ( object from, object iadditional = null ) : IJSCSGlue
from object
iadditional object
return IJSCSGlue
        public IJSCSGlue InternalMap(object from, object iadditional=null)
        {
            if (from == null)
                return new JsGenericObject(_Context, null);

            var res = _Cacher.GetCached(from);
            if (res != null)
                return res;

            var command = from as ICommand;
            if (command != null)
                return _CommandFactory.Build(command);

            var simpleCommand = from as ISimpleCommand;
            if (simpleCommand != null)
                return _CommandFactory.Build(simpleCommand);

            var resultCommand = from as IResultCommand;
            if (resultCommand != null)
                return _CommandFactory.Build(resultCommand);

            var type = from.GetType();
            if (_Context.WebView.Factory.IsTypeBasic(type))
                return new JSBasicObject(from);

            if (type.IsEnum)
            {
                var trueres = new JSBasicObject(from);
                _Cacher.Cache(from, trueres);
                return trueres;
            }

            var ienfro = from as IEnumerable;
            if (ienfro!=null)
                return  Convert(ienfro);

            var gres = new JsGenericObject(_Context, from);
            _Cacher.Cache(from, gres);

            MappNested(from ,gres);
            MappNested(iadditional, gres);

            return gres;
        }

Usage Example

コード例 #1
0
        internal async Task Init(object addicionalObject)
        {
            _Root = await _Context.EvaluateOnUIContextAsync(() => _JSObjectBuilder.InternalMap(_RootObject, addicionalObject));

            await RunInJavascriptContext(async() =>
            {
                _Context.InitOnJsContext();
                _sessionInjector = _Context.JavascriptSessionInjector;
                RegisterJavascriptHelper();
                _Root.ComputeJavascriptValue(_Context.WebView.Factory, _SessionCache);

                var res = await InjectInHTMLSession(_Root);

                await _sessionInjector.RegisterMainViewModel(res);

                if (ListenToCSharp)
                {
                    ListenToCSharpChanges();
                }
                _IsListening = true;
            });
        }