ProfileAutoSaveEventHandler 代理人

定義

ProfileAutoSavingProfileModule イベントを処理するメソッドを表します。

public delegate void ProfileAutoSaveEventHandler(System::Object ^ sender, ProfileAutoSaveEventArgs ^ e);
public delegate void ProfileAutoSaveEventHandler(object sender, ProfileAutoSaveEventArgs e);
type ProfileAutoSaveEventHandler = delegate of obj * ProfileAutoSaveEventArgs -> unit
Public Delegate Sub ProfileAutoSaveEventHandler(sender As Object, e As ProfileAutoSaveEventArgs)

パラメーター

sender
Object

ProfileModule イベントの発生元の ProfileAutoSaving

e
ProfileAutoSaveEventArgs

イベント データを格納している ProfileAutoSaveEventArgs

次のコード例は、 ProfileAutoSaving ASP.NET アプリケーションの Global.asax ファイルに含まれるイベントを示しています。

public void Profile_ProfileAutoSaving(object sender, ProfileAutoSaveEventArgs args)
{
  if (Profile.Cart.HasChanged)
    args.ContinueWithProfileAutoSave = true;
  else
    args.ContinueWithProfileAutoSave = false;
}
Public Sub Profile_ProfileAutoSaving(sender As Object, args As ProfileAutoSaveEventArgs)
  If Profile.Cart.HasChanged Then
    args.ContinueWithProfileAutoSave = True
  Else
    args.ContinueWithProfileAutoSave = False
  End If
End Sub

注釈

デリゲートは ProfileAutoSaveEventHandler 、 クラスの イベントに対して ProfileAutoSaving 定義されます ProfileModule 。 このトピックのProfileAutoSavingProfileModule例に示すように、ASP.NET アプリケーションの Global.asax ファイル内の クラスのイベントにアクセスできます。 ProfileAutoSavingプロパティが の場合、ページの実行の最後にイベントがAutomaticSaveEnabledtrue発生します。

メソッドはSave、プリミティブ型、文字列、またはDateTimeオブジェクトで構成されるプロパティが変更されたかどうかを自動的に判断します。ユーザー プロファイル内のそれぞれのSettingsPropertyValueプロパティ値を確認IsDirtyします。 ただし、 メソッドは Save 、カスタム クラスが変更されたかどうかを明示的に判断できません。 イベントを ProfileAutoSaving 処理して、カスタム オブジェクトが変更されたかどうかを判断し、変更されたオブジェクトの自動保存を続行し、オブジェクトが変更されていない場合は自動保存を取り消すことができます。

プロファイルの自動保存操作を取り消すには、 イベントで ProfileAutoSaving プロパティを ContinueWithProfileAutoSavefalse設定します。それ以外の場合は、 プロパティを ContinueWithProfileAutoSavetrue設定します。

イベントに複数のサブスクライバーが ProfileAutoSaving 存在する可能性があります。 では ProfileModule 、 プロパティが設定されている最後の値が ContinueWithProfileAutoSave 使用されます。 その結果、以前のサブスクライバーによって設定された値を上書きする必要がある場合があるため、自動保存を取り消すか続行するかに関係なく、イベントで ProfileAutoSaving プロパティを明示的に設定ContinueWithProfileAutoSaveすることをお勧めします。

拡張メソッド

GetMethodInfo(Delegate)

指定したデリゲートによって表されるメソッドを表すオブジェクトを取得します。

適用対象

こちらもご覧ください