Exemplo n.º 1
0
        public override void Init(object initData)
        {
            base.Init(initData);
            var x = initData as Tuple <Video, Familiar, Image>;

            Familiar      = new Familiar();
            Video         = new Video();
            oHorario      = new PageModelHelper();
            VideoTeste    = new StreamVideoSource();
            VideoPaciente = new StreamImageSource();
            if (x == null)
            {
                return;
            }
            Familiar      = x.Item2;
            Video         = x.Item1;
            VideoPaciente = x.Item3.Source;
            VideoTeste    = VideoSource.FromStream(() => new MemoryStream(Video.VidDados), "mp4");
        }
Exemplo n.º 2
0
            public void MoveNext()
            {
                string str;
                int    num = this._state;

                try
                {
                    ConfiguredTaskAwaitable <Stream> .ConfiguredTaskAwaiter awaiter;
                    switch (num)
                    {
                    case 0:
                        break;

                    case 1:
                        goto Label_00C3;

                    default:
                        this._path = null;
                        this._streamVideoSource = this.source as StreamVideoSource;
                        if (this._streamVideoSource?.Stream == null)
                        {
                            goto Label_01FB;
                        }
                        awaiter = this._streamVideoSource.GetStreamAsync(this.cancellationToken).ConfigureAwait(false).GetAwaiter();
                        if (awaiter.IsCompleted)
                        {
                            goto Label_00AC;
                        }
                        this._state             = num = 0;
                        this._configuredAwaiter = awaiter;
                        this._builder.AwaitUnsafeOnCompleted(ref awaiter, ref this);
                        return;
                    }
                    awaiter = this._configuredAwaiter;
                    this._configuredAwaiter = new ConfiguredTaskAwaitable <Stream> .ConfiguredTaskAwaiter();

                    this._state = num = -1;
Label_00AC:
                    Stream introduced9 = awaiter.GetResult();
                    awaiter            = new ConfiguredTaskAwaitable <Stream> .ConfiguredTaskAwaiter();

                    Stream stream = introduced9;
                    this._stream = stream;
                    Label_00C3 :;
                    try
                    {
                        if (num != 1)
                        {
                            if (this._stream == null)
                            {
                                goto Label_01F4;
                            }
                            string fileName = this._this.GetFileName(this._stream, this._streamVideoSource.Format);
                            string str3     = Path.Combine(Path.GetTempPath(), "MediaCache");
                            this._path = Path.Combine(str3, fileName);
                            if (File.Exists(this._path))
                            {
                                goto Label_01F4;
                            }
                            if (!Directory.Exists(str3))
                            {
                                Directory.CreateDirectory(str3);
                            }
                            this._tempFile = File.Create(this._path);
                        }
                        try
                        {
                            TaskAwaiter awaiter2;
                            if (num != 1)
                            {
                                awaiter2 = this._stream.CopyToAsync(this._tempFile).GetAwaiter();
                                if (!awaiter2.IsCompleted)
                                {
                                    this._state   = num = 1;
                                    this._awaiter = awaiter2;
                                    this._builder.AwaitUnsafeOnCompleted(ref awaiter2, ref this);
                                    return;
                                }
                            }
                            else
                            {
                                awaiter2      = this._awaiter;
                                this._awaiter = new TaskAwaiter();
                                this._state   = num = -1;
                            }
                            awaiter2.GetResult();
                            awaiter2 = new TaskAwaiter();
                        }
                        finally
                        {
                            if ((num < 0) && (this._tempFile != null))
                            {
                                this._tempFile.Dispose();
                            }
                        }
                        this._tempFile = null;
                    }
                    finally
                    {
                        if ((num < 0) && (this._stream != null))
                        {
                            this._stream.Dispose();
                        }
                    }
Label_01F4:
                    this._stream = null;
Label_01FB:
                    str = this._path;
                }
                catch (Exception exception)
                {
                    this._state = -2;
                    this._builder.SetException(exception);
                    return;
                }
                this._state = -2;
                this._builder.SetResult(str);
            }