Ejemplo n.º 1
0
        public PowerShellDataSource()
        {
            _allRecords = new ObservableCollection <object>();
            _specs      = new List <DynamicMemberSpecification>();
            _scales     = new ScaleDescriptorAssignmentCollection();
            _scales.CollectionChanged += OnScaleDescriptorAssignmentCollectionChanged;

            _dataCollectionMaxSize = 20;
            _data            = new ObservableCollection <object>();
            _progressRecords = new ObservableCollection <ProgressRecord>();
            _dynamicMembers  = new List <PSMemberInfo>();

            _powerShell = System.Management.Automation.PowerShell.Create();
            var runspace = RunspaceFactory.CreateRunspace();

            runspace.Open();
            runspace.SessionStateProxy.SetVariable("seeShellDataSource", this);
            var tmp = System.Management.Automation.PowerShell.Create();

            tmp.Runspace = runspace;
            tmp.AddScript("function start-seeShellDataSet { $seeShellDataSource.StartDataSet(); }")
            .AddScript("function commit-seeShellDataSet { $seeShellDataSource.CommitDataSet(); }")
            .AddScript("function undo-seeShellDataSet { $seeShellDataSource.RollbackDataSet(); }");
            tmp.Invoke();

            _powerShell.Runspace = runspace;
            _powerShell.InvocationStateChanged     += InvocationStateChanged;
            _powerShell.Streams.Debug.DataAdded    += DebugRecordAdded;
            _powerShell.Streams.Verbose.DataAdded  += VerboseRecordAdded;
            _powerShell.Streams.Progress.DataAdded += ProgressRecordAdded;
            _powerShell.Streams.Error.DataAdded    += ErrorRecordAdded;
            _powerShell.Streams.Warning.DataAdded  += WarningRecordAdded;
        }
Ejemplo n.º 2
0
 public NullPowerShellDataSource()
 {
     Data            = new ObservableCollection <object>();
     ErrorRecords    = new ObservableCollection <ErrorRecord>();
     WarningRecords  = new ObservableCollection <WarningRecord>();
     DebugRecords    = new ObservableCollection <DebugRecord>();
     VerboseRecords  = new ObservableCollection <VerboseRecord>();
     ProgressRecords = new ObservableCollection <ProgressRecord>();
     Scales          = new ScaleDescriptorAssignmentCollection();
     AllRecords      = new ObservableCollection <object>();
 }