C# と VB.NET の質問掲示板

ASP.NET、C++/CLI、Java 何でもどうぞ

ログ内検索
  • キーワードを複数指定する場合は 半角スペース で区切ってください。
  • 検索条件は、(AND)=[A かつ B] (OR)=[A または B] となっています。
  • [返信]をクリックすると返信ページへ移動します。
キーワード/ 検索条件 /
検索範囲/ 強調表示/ ON (自動リンクOFF)
結果表示件数/ 記事No検索/ ON
大文字と小文字を区別する

No.91525 の関連記事表示

<< 0 >>
■91525  Re[4]: メモリリークに関して
□投稿者/ 魔界の仮面弁士 -(2019/07/03(Wed) 17:07:14)
    No91519 (WebSurfer さん) に返信
    > Form コントロールの場合、Dispose(), Dispose(bool) の実装は Control toha違うようです。
    > 下のリンクをクリックして画像を見てください。
    > http://surferonwww.info/BlogEngine/image.axd?picture=2019%2f7%2fFormDispose0.jpg

    Dispose の実装は、Label と Form で差異が無さそうに見えます。
    少なくとも .NET Compact Framework においては。


    手元の VS2008 環境で、Form1 の継承関係をたどってみました。
    CE 機が無いので、エミュレーターでの動作ですけれども。


     × は Dispose(boolean) が実装されていないクラス
     ※ は Dispose(boolean) が派生元にあるが、実装しなおしてないクラス
     ☆ は Sub Overrides Dispose(boolean) として実装しなおされているクラス
     ★ は Sub Overridable Dispose(boolean) として最初に実装されているクラス


    .NET Compact Framework の場合

    × Object
    └× MarshalByRefObject
     └★ Component
      └☆ Control
       └※ ScrollableControl
        └※ ContainerControl
         └※ Form
          └☆ Form1


    .NET Framework の場合

    × Object
    └× MarshalByRefObject
     └★ Component
      └☆ Control
       └☆ ScrollableControl
        └☆ ContainerControl
         └☆ Form
          └☆ Form1



    Imports System.Reflection

    Public Class Form1
      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ListBox1.DataSource = New Type(-1) {}
        ListBox1.DisplayMember = "Name"
        ListBox2.DataSource = New Type(-1) {}
        ListBox2.DisplayMember = "Name"
        ComboBox1.DataSource = New Type() { _
          GetType(Form1), _
          GetType(Form), _
          GetType(Label), _
          GetType(Panel), _
          GetType(Control) _
        }
        ComboBox1.DisplayMember = "FullName"
        TextBox1.Text = "Dispose"
        CheckBox1.Checked = True
      End Sub

      Private Sub Analyze(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged, CheckBox1.CheckStateChanged, TextBox1.TextChanged
        Analyze()
      End Sub

      Private Sub Analyze()
        Dim selType As Type = DirectCast(ComboBox1.SelectedItem, Type)
        Dim methodName As String = TextBox1.Text
        Dim declaredOnly As Boolean = CheckBox1.Checked
        CheckBox1.Enabled = Not String.IsNullOrEmpty(methodName)

        'Sub Dispose() の実装
        ListBox1.DataSource = EnumrateMethodImpl(selType, declaredOnly, methodName)

        'Sub Dispose(Boolean) の実装
        ListBox2.DataSource = EnumrateMethodImpl(selType, declaredOnly, methodName, GetType(Boolean))
      End Sub

      Public Shared Function EnumrateMethodImpl(ByVal t As Type, ByVal declaredOnly As Boolean, ByVal methodName As String, ByVal ParamArray params As Type()) As Type()
        Dim bf As BindingFlags = BindingFlags.NonPublic Or BindingFlags.Public Or BindingFlags.Instance
        If declaredOnly Then
          bf = bf Or BindingFlags.DeclaredOnly
        End If
        Dim targetType As Type = t
        Dim types As New List(Of Type)()
        Dim bt As Type = targetType
        Do
          If String.IsNullOrEmpty(methodName) Then
            types.Add(bt)
          ElseIf bt.GetMethod(methodName, bf, Type.DefaultBinder, params, Nothing) IsNot Nothing Then
            types.Add(bt)
          End If
          bt = bt.BaseType
        Loop Until bt Is Nothing
        Dim result As Type() = types.ToArray()
        Array.Reverse(result)
        Return result
      End Function
    End Class
記事No.91509 のレス /過去ログ158より / 関連記事表示
削除チェック/



<< 0 >>

パスワード/

- Child Tree -