DisposeResponse() static private method

static private DisposeResponse ( WebResponse wr, bool bGetStream ) : void
wr System.Net.WebResponse
bGetStream bool
return void
コード例 #1
0
ファイル: IOConnection.cs プロジェクト: andrxs/KeePass2.x
        public override void Close()
        {
            base.Close();
#endif
            if (MonoWorkarounds.IsRequired(10163) && m_bWrite)
            {
                try
                {
                    Stream s = this.BaseStream;
                    Type   t = s.GetType();
                    if (t.Name == "WebConnectionStream")
                    {
                        PropertyInfo pi = t.GetProperty("Request",
                                                        BindingFlags.Instance | BindingFlags.NonPublic);
                        if (pi != null)
                        {
                            WebRequest wr = (pi.GetValue(s, null) as WebRequest);
                            if (wr != null)
                            {
                                IOConnection.DisposeResponse(wr.GetResponse(), false);
                            }
                            else
                            {
                                Debug.Assert(false);
                            }
                        }
                        else
                        {
                            Debug.Assert(false);
                        }
                    }
                }
                catch (Exception) { Debug.Assert(false); }
            }
        }
コード例 #2
0
ファイル: IOConnection.cs プロジェクト: mauron85/KeePassLib
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (disposing && MonoWorkarounds.IsRequired(10163) && m_bWrite &&
                !m_bDisposed)
            {
                try
                {
                    Stream s = this.BaseStream;
                    Type   t = s.GetType();
                    if (t.Name == "WebConnectionStream")
                    {
                        PropertyInfo pi = t.GetProperty("Request",
                                                        BindingFlags.Instance | BindingFlags.NonPublic);
                        if (pi != null)
                        {
                            WebRequest wr = (pi.GetValue(s, null) as WebRequest);
                            if (wr != null)
#if KeePassUWP
                            {
                                var task = wr.GetResponseAsync();
                                task.RunSynchronously();
                                var response = task.Result;
                                IOConnection.DisposeResponse(response, false);
                            }
#else
                            { IOConnection.DisposeResponse(wr.GetResponse(), false); }
#endif
                            else
                            {
                                Debug.Assert(false);
                            }
                        }
                        else
                        {
                            Debug.Assert(false);
                        }
                    }
                }