예제 #1
0
        protected IJsCsGlue Convert(IGlueFactory factory, object @object, IGenericPropertyAcessor propertyAcessor)
        {
            var result = factory.Build(@object, propertyAcessor);

            result.SetAttributes(MapNested(@object, propertyAcessor));
            return(result);
        }
예제 #2
0
        public IJsCsGlue Convert(IGlueFactory factory, object @object)
        {
            var result = factory.Build(@object, _PropertyAccessor);

            result.SetAttributes(MapNested(@object));
            return(result);
        }
예제 #3
0
 private static IJsCsGlue BuildResultCommandWithTarg <TArg, TRes>(IGlueFactory factory, object @object) => factory.Build((IResultCommand <TArg, TRes>)@object);
예제 #4
0
 private static IJsCsGlue BuildCommandWithoutParameter(IGlueFactory factory, object @object) => factory.Build((ICommandWithoutParameter)@object);
예제 #5
0
 private static IJsCsGlue BuildGenericCommand <T>(IGlueFactory factory, object @object) => factory.Build((ICommand <T>)@object);
예제 #6
0
 private static IJsCsGlue BuildSimpleCommand(IGlueFactory factory, object @object) => factory.Build((ISimpleCommand)@object);
 private static IJsCsGlue BuildResultCommand(IGlueFactory factory, object @object) => factory.Build((IResultCommand)@object);
        public IJSCSGlue Map(object from, object additional = null)
        {
            if (from == null)
            {
                return(_Null ?? (_Null = new JSBasicObject(null)));
            }

            var res = _Cacher.GetCached(from);

            if (res != null)
            {
                return(res);
            }

            var type = from.GetType();

            if (_Context.IsTypeBasic(type))
            {
                res = new JSBasicObject(from);
                _Cacher.CacheFromCSharpValue(from, res);
                return(res);
            }

            var command = from as ICommand;

            if (command != null)
            {
                return(_GlueFactory.Build(command));
            }

            var simpleCommand = from as ISimpleCommand;

            if (simpleCommand != null)
            {
                return(_GlueFactory.Build(simpleCommand));
            }

            var resultCommand = from as IResultCommand;

            if (resultCommand != null)
            {
                return(_GlueFactory.Build(resultCommand));
            }

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

            var ienfro = from as IEnumerable;

            if (ienfro != null)
            {
                return(Convert(ienfro));
            }

            var propertyInfos           = @from.GetType().GetReadProperties();
            var additionalPropertyInfos = additional?.GetType().GetReadProperties();

            var gres = _GlueFactory.Build(from, propertyInfos.Count + (additionalPropertyInfos?.Count ?? 0));

            _Cacher.CacheFromCSharpValue(from, gres);

            MappNested(gres, @from, propertyInfos);
            MappNested(gres, additional, additionalPropertyInfos);
            return(gres);
        }