Пример #1
0
        public static KumaBoxedInstance Box(object obj, KumaScope scope = null)
        {
            if (obj == null)
            {
                return(null);
            }
            if (_boxCache.ContainsKey(obj))
            {
                _boxCache[obj].BoxedScope.MergeWithScope(scope ?? new KumaScope());
                return(_boxCache[obj]);
            }
            var boxed = new KumaBoxedInstance(obj, scope ?? new KumaScope());

            _boxCache[obj] = boxed;
            if (scope != null)
            {
                string name;
                var    _scope = scope.SearchForObject(obj, out name);
                if (_scope != null)
                {
                    _scope[name] = boxed;
                }
            }
            return(boxed);
        }
Пример #2
0
        public static KumaBoxedInstance BoxNoCache(object obj, KumaScope scope = null)
        {
            if (obj == null)
            {
                return(null);
            }
            var boxed = new KumaBoxedInstance(obj, scope ?? new KumaScope());

            if (scope != null)
            {
                string name;
                var    _scope = scope.SearchForObject(obj, out name);
                if (_scope != null)
                {
                    _scope[name] = boxed;
                }
            }
            return(boxed);
        }