Example #1
0
        //actual constructor work, but hidden to not be used accidently in a stupid way
        private SessionState(SessionStateGlobal sessionStateGlobal, SessionState parent)
        {
            SessionStateGlobal = sessionStateGlobal;

            var parentAliasScope    = parent == null ? null : parent._aliasScope;
            var parentFunctionScope = parent == null ? null : parent._functionScope;
            var parentVariableScope = parent == null ? null : parent._variableScope;
            var parentDriveScope    = parent == null ? null : parent._driveScope;
            var parentModuleScope   = parent == null ? null : parent._moduleScope;
            var parentCmdletScope   = parent == null ? null : parent._cmdletScope;

            _aliasScope    = new SessionStateScope <AliasInfo>(this, parentAliasScope, SessionStateCategory.Alias);
            _functionScope = new SessionStateScope <FunctionInfo>(this, parentFunctionScope, SessionStateCategory.Function);
            _variableScope = new SessionStateScope <PSVariable>(this, parentVariableScope, SessionStateCategory.Variable);
            _driveScope    = new SessionStateScope <PSDriveInfo>(this, parentDriveScope, SessionStateCategory.Drive);
            _moduleScope   = new SessionStateScope <PSModuleInfo>(this, parentModuleScope, SessionStateCategory.Module);
            _cmdletScope   = new SessionStateScope <CmdletInfo>(this, parentCmdletScope, SessionStateCategory.Cmdlet);

            IsScriptScope = false;
            Function      = new FunctionIntrinsics(_functionScope);
            Alias         = new AliasIntrinsics(_aliasScope);

            Drive         = new DriveManagementIntrinsics(_driveScope);
            Path          = new PathIntrinsics(this);
            PSVariable    = new PSVariableIntrinsics(_variableScope);
            LoadedModules = new ModuleIntrinsics(_moduleScope);
            Cmdlet        = new CmdletIntrinsics(_cmdletScope);
        }
Example #2
0
        //actual constructor work, but hidden to not be used accidently in a stupid way
        private SessionState(SessionStateGlobal sessionStateGlobal, SessionStateScope <FunctionInfo> functions,
                             SessionStateScope <PSVariable> variables, SessionStateScope <PSDriveInfo> drives,
                             SessionStateScope <AliasInfo> aliases)
        {
            SessionStateGlobal = sessionStateGlobal;

            _aliasScope    = new SessionStateScope <AliasInfo>(aliases, SessionStateCategory.Alias);
            _functionScope = new SessionStateScope <FunctionInfo>(functions, SessionStateCategory.Function);
            _variableScope = new SessionStateScope <PSVariable>(variables, SessionStateCategory.Variable);
            _driveScope    = new SessionStateScope <PSDriveInfo>(drives, SessionStateCategory.Drive);

            IsScriptScope = false;
            Function      = new FunctionIntrinsics(this, _functionScope);
            Alias         = new AliasIntrinsics(this, _aliasScope);

            Drive      = new DriveManagementIntrinsics(this, _driveScope);
            Path       = new PathIntrinsics(SessionStateGlobal);
            Provider   = new CmdletProviderManagementIntrinsics(SessionStateGlobal);
            PSVariable = new PSVariableIntrinsics(this, _variableScope);
        }