internal static NetFxToWinRtStreamAdapter Create(Stream stream)
        {
            if (stream == null)
                throw new ArgumentNullException(nameof(stream));

            StreamReadOperationOptimization readOptimization = StreamReadOperationOptimization.AbstractStream;
            if (stream.CanRead)
                readOptimization = DetermineStreamReadOptimization(stream);

            NetFxToWinRtStreamAdapter adapter;

            if (stream.CanSeek)
                adapter = new RandomAccessStream(stream, readOptimization);

            else if (stream.CanRead && stream.CanWrite)
                adapter = new InputOutputStream(stream, readOptimization);

            else if (stream.CanRead)
                adapter = new InputStream(stream, readOptimization);

            else if (stream.CanWrite)
                adapter = new OutputStream(stream, readOptimization);

            else
                throw new ArgumentException(global::Windows.Storage.Streams.SR.Argument_NotSufficientCapabilitiesToConvertToWinRtStream);

            return adapter;
        }
예제 #2
0
 public MainWindowViewModel()
     : base()
 {
     _stdOutStream    = new InputOutputStream();
     _programExecutor = new ProgramExecutor(_stdOutStream);
     ExecuteCommand   = new DelegateCommand(DoExecute);
     Task.Factory.StartNew(OutputReader);
 }
예제 #3
0
 public ProgramExecutor(InputOutputStream stdout)
 {
     _stdout                = stdout;
     _scheduler             = new Scheduler();
     _interpreter           = new Interpreter(_scheduler);
     _nativeResourceManager = new NativeResourceManager();
     _nativeResourceManager.RegisterProvider <INativeFileProvider>(new DefaultFileProvider());
     _nativeResourceManager.RegisterProvider <INativeStdioProvider>(new DefaultNativeStdioProvider(null, stdout));
     _nativeResourceManager.RegisterBuiltins(_interpreter);
     _scheduler.SetInterpreter(_interpreter);
 }
예제 #4
0
        public virtual void Dispose()
        {
            lock (this)
            {
                timer.Dispose();
                Cancel(new TftpErrorPacket(0, "ITftpTransfer has been disposed."));

                if (InputOutputStream != null)
                {
                    InputOutputStream.Close();
                    InputOutputStream = null;
                }

                connection.Dispose();
            }
        }
예제 #5
0
        internal static NetFxToWinRtStreamAdapter Create(Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            StreamReadOperationOptimization readOptimization = StreamReadOperationOptimization.AbstractStream;

            if (stream.CanRead)
            {
                readOptimization = DetermineStreamReadOptimization(stream);
            }

            NetFxToWinRtStreamAdapter adapter;

            if (stream.CanSeek)
            {
                adapter = new RandomAccessStream(stream, readOptimization);
            }

            else if (stream.CanRead && stream.CanWrite)
            {
                adapter = new InputOutputStream(stream, readOptimization);
            }

            else if (stream.CanRead)
            {
                adapter = new InputStream(stream, readOptimization);
            }

            else if (stream.CanWrite)
            {
                adapter = new OutputStream(stream, readOptimization);
            }

            else
            {
                throw new ArgumentException(SR.Argument_NotSufficientCapabilitiesToConvertToWinRtStream);
            }

            return(adapter);
        }
예제 #6
0
        internal static NetFxToWinRtStreamAdapter Create(Stream stream)
        {
            if (stream == null)
                throw new ArgumentNullException("stream");

            StreamReadOperationOptimization readOptimization = StreamReadOperationOptimization.AbstractStream;
            if (stream.CanRead)
                readOptimization = DetermineStreamReadOptimization(stream);

            NetFxToWinRtStreamAdapter adapter;

            if (stream.CanSeek)
                adapter = new RandomAccessStream(stream, readOptimization);

            else if (stream.CanRead && stream.CanWrite)
                adapter = new InputOutputStream(stream, readOptimization);

            else if (stream.CanRead)
                adapter = new InputStream(stream, readOptimization);

            else if (stream.CanWrite)
                adapter = new OutputStream(stream, readOptimization);

            else
                throw new ArgumentException(SR.Argument_NotSufficientCapabilitiesToConvertToWinRtStream);

            return adapter;
        }