Exposes a IDictionary[string, object] as a dynamic object. Gets/sets/deletes turn into accesses on the underlying dictionary.
Inheritance: IDynamicMetaObjectProvider
Beispiel #1
0
        public override bool ScopeTryGetVariable(Scope scope, string name, out dynamic value)
        {
            var storage = scope.Storage as ScopeStorage;

            if (storage != null && storage.TryGetValue(name, false, out value))
            {
                return(true);
            }

            StringDictionaryExpando dictStorage = scope.Storage as StringDictionaryExpando;

            if (dictStorage != null && dictStorage.Dictionary.TryGetValue(name, out value))
            {
                return(true);
            }

            return(base.ScopeTryGetVariable(scope, name, out value));
        }
Beispiel #2
0
        public override dynamic ScopeGetVariable(Scope scope, string name)
        {
            var    storage = scope.Storage as ScopeStorage;
            object res;

            if (storage != null && storage.TryGetValue(name, false, out res))
            {
                return(res);
            }

            StringDictionaryExpando dictStorage = scope.Storage as StringDictionaryExpando;

            if (dictStorage != null && dictStorage.Dictionary.TryGetValue(name, out res))
            {
                return(res);
            }

            return(base.ScopeGetVariable(scope, name));
        }
Beispiel #3
0
        public override void ScopeSetVariable(Scope scope, string name, object value)
        {
            var storage = scope.Storage as ScopeStorage;

            if (storage != null)
            {
                storage.SetValue(name, false, value);
                return;
            }

            StringDictionaryExpando dictStorage = scope.Storage as StringDictionaryExpando;

            if (dictStorage != null)
            {
                dictStorage.Dictionary[name] = value;
                return;
            }

            base.ScopeSetVariable(scope, name, value);
        }