Bagikan melalui


Catch<TException> Kelas

Definisi

Berisi tindakan yang akan dijalankan setelah pengecualian dimunculkan di blok Coba aktivitas yang Finally sesuai.

generic <typename TException>
 where TException : Exceptionpublic ref class Catch sealed : System::Activities::Statements::Catch
[System.Windows.Markup.ContentProperty("Action")]
public sealed class Catch<TException> : System.Activities.Statements.Catch where TException : Exception
[<System.Windows.Markup.ContentProperty("Action")>]
type Catch<'Exception (requires 'Exception :> Exception)> = class
    inherit Catch
Public NotInheritable Class Catch(Of TException)
Inherits Catch

Jenis parameter

TException

Jenis pengecualian yang ditangani Catch<TException> blok tersebut.

Warisan
Catch<TException>
Atribut

Contoh

Sampel kode berikut menunjukkan pembuatan Catch<TException> aktivitas. Contoh ini berasal dari Penanganan Kesalahan dalam Aktivitas Bagan Alur Menggunakan sampel TryCatch .

FlowStep mwkStep = new FlowStep
{
    Action = new TryCatch
    {
        DisplayName = "Try/Catch for Divide By Zero Exception",
        Try = new Assign
        {
            DisplayName = "discount = 15 + (1 - 1/numberOfKids)*10",
            To = new OutArgument<double>(discount),
            Value = new InArgument<double>((ctx) => (15 + (1 - 1 / numberOfKids.Get(ctx)) * 10))
        },
        Catches =
        {
             new Catch<System.DivideByZeroException>
             {
                 Action = new ActivityAction<System.DivideByZeroException>
                 {
                     Argument = ex,
                     DisplayName = "ActivityAction - DivideByZeroException",
                     Handler =
                         new Sequence
                         {
                             DisplayName = "Divide by Zero Exception Workflow",
                             Activities =
                             {
                                new WriteLine()
                                {
                                    DisplayName = "WriteLine: DivideByZeroException",
                                    Text = "DivideByZeroException: Promo code is MWK - but number of kids = 0"
                                },
                                new Assign<double>
                                {
                                    DisplayName = "Exception - discount = 0",
                                    To = discount,
                                    Value = new InArgument<double>(0)
                                }
                             }
                         }
                 }
             }
        }
    },
    Next = flowDecision
};

Keterangan

Setelah ditempatkan di perancang, Catch aktivitas tidak dapat diurutkan ulang dalam perancang. Untuk menyusun ulang kumpulan Catch aktivitas, hapus dan tambahkan kembali dalam urutan yang benar, atau gunakan tampilan xaml (kode) untuk alur kerja.

Konstruktor

Catch<TException>()

Membuat instans Catch<TException> baru kelas.

Properti

Action

Handler untuk pengecualian yang tertangkap.

ExceptionType

Jenis pengecualian yang ditangani Catch blok tersebut.

Metode

Equals(Object)

Menentukan apakah objek yang ditentukan sama dengan objek saat ini.

(Diperoleh dari Object)
GetHashCode()

Berfungsi sebagai fungsi hash default.

(Diperoleh dari Object)
GetType()

Mendapatkan instans Type saat ini.

(Diperoleh dari Object)
MemberwiseClone()

Membuat salinan dangkal dari yang saat ini Object.

(Diperoleh dari Object)
ToString()

Mengembalikan string yang mewakili objek saat ini.

(Diperoleh dari Object)

Berlaku untuk