SetExtension() public method

Sets the ScopeExtension to the provided value for the given ContextId. The extension can only be set once. The returned value is either the new ScopeExtension if no value was previously set or the previous value.
public SetExtension ( ContextId languageContextId, Microsoft.Scripting.Runtime.ScopeExtension extension ) : Microsoft.Scripting.Runtime.ScopeExtension
languageContextId ContextId
extension Microsoft.Scripting.Runtime.ScopeExtension
return Microsoft.Scripting.Runtime.ScopeExtension
コード例 #1
0
ファイル: ModuleContext.cs プロジェクト: andreakn/ironruby
        /// <summary>
        /// Creates a new ModuleContext which is backed by the specified dictionary.
        /// </summary>
        public ModuleContext(PythonDictionary/*!*/ globals, PythonContext/*!*/ creatingContext) {
            ContractUtils.RequiresNotNull(globals, "globals");
            ContractUtils.RequiresNotNull(creatingContext, "creatingContext");

            _globals = globals;
            _pyContext = creatingContext;
            _globalScope = new Scope(globals);
            _globalContext = new CodeContext(globals, this);
            _module = new PythonModule(globals, _globalScope);
            _globalScope.SetExtension(_pyContext.ContextId, new PythonScopeExtension(_pyContext, _module, this));
        }
コード例 #2
0
ファイル: LanguageContext.cs プロジェクト: rudimk/dlr-dotnet
        // TODO: remove
        public ScopeExtension EnsureScopeExtension(Scope scope)
        {
            ContractUtils.RequiresNotNull(scope, "scope");
            ScopeExtension extension = scope.GetExtension(ContextId);

            if (extension == null)
            {
                extension = CreateScopeExtension(scope);
                if (extension == null)
                {
                    throw Error.MustReturnScopeExtension();
                }
                return(scope.SetExtension(ContextId, extension));
            }

            return(extension);
        }
コード例 #3
0
ファイル: CodeContext.cs プロジェクト: Alxandr/IronTotem
 private Scope CreateScope()
 {
     Scope ret = new Scope(new ObjectDictionaryExpando(_dict));
     ret.SetExtension(_context.ContextId, new TotemScopeExtension(_context, ret));
     return ret;
 }