MimeTextMatch 類別

定義

表示要用來搜尋 HTTP 傳輸的文字模式。 此類別無法獲得繼承。

public ref class MimeTextMatch sealed
public sealed class MimeTextMatch
type MimeTextMatch = class
Public NotInheritable Class MimeTextMatch
繼承
MimeTextMatch

範例

下列範例示範如何使用 類別所 MimeTextMatch 公開的屬性和方法。

#using <System.Xml.dll>
#using <System.Web.Services.dll>
#using <System.dll>

using namespace System;
using namespace System::Web::Services::Description;
using namespace System::Collections;
using namespace System::Xml;

int main()
{
   try
   {
      ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MimeText_Binding_Match_8_Input_CPP.wsdl" );

      // Create a Binding.
      Binding^ myBinding = gcnew Binding;

      // Initialize the Name property of the Binding.
      myBinding->Name = "MimeText_Binding_MatchServiceHttpPost";
      XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "s0:MimeText_Binding_MatchServiceHttpPost" );
      myBinding->Type = myXmlQualifiedName;

      // Create an HttpBinding.
      HttpBinding^ myHttpBinding = gcnew HttpBinding;
      myHttpBinding->Verb = "POST";

      // Add the HttpBinding to the Binding.
      myBinding->Extensions->Add( myHttpBinding );

      // Create an OperationBinding.
      OperationBinding^ myOperationBinding = gcnew OperationBinding;
      myOperationBinding->Name = "AddNumbers";
      HttpOperationBinding^ myHttpOperationBinding = gcnew HttpOperationBinding;
      myHttpOperationBinding->Location = "/AddNumbers";

      // Add the HttpOperationBinding to the OperationBinding.
      myOperationBinding->Extensions->Add( myHttpOperationBinding );

      // Create an InputBinding.
      InputBinding^ myInputBinding = gcnew InputBinding;
      MimeContentBinding^ postMimeContentbinding = gcnew MimeContentBinding;
      postMimeContentbinding->Type = "application/x-www-form-urlencoded";
      myInputBinding->Extensions->Add( postMimeContentbinding );

      // Add the InputBinding to the OperationBinding.
      myOperationBinding->Input = myInputBinding;

      // Create an OutputBinding.
      OutputBinding^ myOutputBinding = gcnew OutputBinding;

      // Create a MimeTextBinding.
      MimeTextBinding^ myMimeTextBinding = gcnew MimeTextBinding;

      // Create a MimeTextMatch.
      MimeTextMatch^ myMimeTextMatch = gcnew MimeTextMatch;
      MimeTextMatchCollection^ myMimeTextMatchCollection;

      // Initialize properties of the MimeTextMatch.
      myMimeTextMatch->Name = "Title";
      myMimeTextMatch->Type = "*/*";
      myMimeTextMatch->Pattern = "'TITLE>(.*?)<";
      myMimeTextMatch->IgnoreCase = true;

      // Initialize a MimeTextMatchCollection.
      myMimeTextMatchCollection = myMimeTextBinding->Matches;

      // Add the MimeTextMatch to the MimeTextMatchCollection.
      myMimeTextMatchCollection->Add( myMimeTextMatch );
      myOutputBinding->Extensions->Add( myMimeTextBinding );

      // Add the OutputBinding to the OperationBinding.
      myOperationBinding->Output = myOutputBinding;

      // Add the OutputBinding to the OperationBinding.
      myOperationBinding->Output = myOutputBinding;

      // Add the OperationBinding to the Binding.
      myBinding->Operations->Add( myOperationBinding );

      // Add the Binding to the BindingCollection of the ServiceDescription.
      myServiceDescription->Bindings->Add( myBinding );

      // Write the ServiceDescription as a WSDL file.
      myServiceDescription->Write( "MimeText_Binding_Match_8_Output_CPP.wsdl" );
      Console::WriteLine( "WSDL file named 'MimeText_Binding_Match_8_Output_CPP.wsdl' was"
      " created successfully." );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Exception: {0}", e->Message );
   }
}
using System;
using System.Web.Services.Description;
using System.Collections;
using System.Xml;

class MyTextBinding
{
   public static void Main()
   {
      try
      {
         ServiceDescription myServiceDescription =
            ServiceDescription.Read("MimeText_Binding_Match_8_Input_CS.wsdl");

         // Create a Binding.
         Binding myBinding = new Binding();

         // Initialize the Name property of the Binding.
         myBinding.Name = "MimeText_Binding_MatchServiceHttpPost";
         XmlQualifiedName myXmlQualifiedName =
            new XmlQualifiedName("s0:MimeText_Binding_MatchServiceHttpPost");
         myBinding.Type = myXmlQualifiedName;

         // Create an HttpBinding.
         HttpBinding myHttpBinding = new HttpBinding();
         myHttpBinding.Verb="POST";

         // Add the HttpBinding to the Binding.
         myBinding.Extensions.Add(myHttpBinding);

         // Create an OperationBinding.
         OperationBinding myOperationBinding = new OperationBinding();
         myOperationBinding.Name = "AddNumbers";

         HttpOperationBinding myHttpOperationBinding =
            new HttpOperationBinding();
         myHttpOperationBinding.Location="/AddNumbers";

         // Add the HttpOperationBinding to the OperationBinding.
         myOperationBinding.Extensions.Add(myHttpOperationBinding);

         // Create an InputBinding.
         InputBinding myInputBinding = new InputBinding();
         MimeContentBinding postMimeContentbinding = new MimeContentBinding();
         postMimeContentbinding.Type = "application/x-www-form-urlencoded";
         myInputBinding.Extensions.Add(postMimeContentbinding);

         // Add the InputBinding to the OperationBinding.
         myOperationBinding.Input = myInputBinding;
               // Create an OutputBinding.
               OutputBinding myOutputBinding = new OutputBinding();

               // Create a MimeTextBinding.
               MimeTextBinding myMimeTextBinding = new MimeTextBinding();

               // Create a MimeTextMatch.
               MimeTextMatch myMimeTextMatch = new MimeTextMatch();
               MimeTextMatchCollection myMimeTextMatchCollection ;

               // Initialize properties of the MimeTextMatch.
               myMimeTextMatch.Name = "Title";
               myMimeTextMatch.Type = "*/*";
               myMimeTextMatch.Pattern = "'TITLE>(.*?)<";
               myMimeTextMatch.IgnoreCase = true;

               // Initialize a MimeTextMatchCollection.
               myMimeTextMatchCollection = myMimeTextBinding.Matches;

               // Add the MimeTextMatch to the MimeTextMatchCollection.
               myMimeTextMatchCollection.Add( myMimeTextMatch );
               myOutputBinding.Extensions.Add( myMimeTextBinding );

               // Add the OutputBinding to the OperationBinding.
               myOperationBinding.Output = myOutputBinding;
         // Add the OutputBinding to the OperationBinding.
         myOperationBinding.Output = myOutputBinding;

         // Add the OperationBinding to the Binding.
         myBinding.Operations.Add(myOperationBinding);

         // Add the Binding to the BindingCollection of the ServiceDescription.
         myServiceDescription.Bindings.Add(myBinding);

         // Write the ServiceDescription as a WSDL file.
         myServiceDescription.Write("MimeText_Binding_Match_8_Output_CS.wsdl");
         Console.WriteLine(
            "WSDL file named 'MimeText_Binding_Match_8_Output_CS.wsdl' was"
            + " created successfully.");
      }
      catch(Exception e)
      {
         Console.WriteLine( "Exception: {0}", e.Message );
      }
    }
}
Imports System.Web.Services.Description
Imports System.Collections
Imports System.Xml

Class MyTextBinding
   Public Shared Sub Main()
      Try
         Dim myServiceDescription As ServiceDescription = _
               ServiceDescription.Read("MimeText_Binding_Match_8_Input_vb.wsdl")

         ' Create a Binding.
         Dim myBinding As New Binding()

         ' Initialize the Name property of the Binding.
         myBinding.Name = "MimeText_Binding_MatchServiceHttpPost"
         Dim myXmlQualifiedName As _
               New XmlQualifiedName("s0:MimeText_Binding_MatchServiceHttpPost")
         myBinding.Type = myXmlQualifiedName

         ' Create an HttpBinding.
         Dim myHttpBinding As New HttpBinding()
         myHttpBinding.Verb = "POST"

         ' Add the HttpBinding to the Binding.
         myBinding.Extensions.Add(myHttpBinding)

         ' Create an OperationBinding.
         Dim myOperationBinding As New OperationBinding()
         myOperationBinding.Name = "AddNumbers"

         Dim myHttpOperationBinding As New HttpOperationBinding()
         myHttpOperationBinding.Location = "/AddNumbers"

         ' Add the HttpOperationBinding to the OperationBinding.
         myOperationBinding.Extensions.Add(myHttpOperationBinding)

         ' Create an InputBinding.
         Dim myInputBinding As New InputBinding()
         Dim postMimeContentbinding As New MimeContentBinding()
         postMimeContentbinding.Type = "application/x-www-form-urlencoded"
         myInputBinding.Extensions.Add(postMimeContentbinding)

         ' Add the InputBinding to the OperationBinding.
         myOperationBinding.Input = myInputBinding
         ' Create an OutputBinding.
         Dim myOutputBinding As New OutputBinding()

         ' Create a MimeTextBinding.
         Dim myMimeTextBinding As New MimeTextBinding()

         ' Create a MimeTextMatch.
         Dim myMimeTextMatch As New MimeTextMatch()
         Dim myMimeTextMatchCollection As MimeTextMatchCollection

         ' Initialize properties of the MimeTextMatch.
         myMimeTextMatch.Name = "Title"
         myMimeTextMatch.Type = "*/*"
         myMimeTextMatch.Pattern = "'TITLE>(.*?)<"
         myMimeTextMatch.IgnoreCase = True

         ' Initialize a MimeTextMatchCollection.
         myMimeTextMatchCollection = myMimeTextBinding.Matches

         ' Add the MimeTextMatch to the MimeTextMatchCollection.
         myMimeTextMatchCollection.Add(myMimeTextMatch)
         myOutputBinding.Extensions.Add(myMimeTextBinding)

         ' Add the OutputBinding to the OperationBinding.
         myOperationBinding.Output = myOutputBinding
         ' Add the OutputBinding to the OperationBinding.
         myOperationBinding.Output = myOutputBinding

         ' Add the OperationBinding to the Binding.
         myBinding.Operations.Add(myOperationBinding)

         ' Add the Binding to the BindingCollection of the ServiceDescription.
         myServiceDescription.Bindings.Add(myBinding)

         ' Write the ServiceDescription as a WSDL file.
         myServiceDescription.Write("MimeText_Binding_Match_8_Output_vb.wsdl")
         Console.WriteLine("WSDL file named " & _
            "'MimeText_Binding_Match_8_Output_vb.wsdl' was" & _
            " created successfully.")
      Catch e As Exception
         Console.WriteLine("Exception: {0}", e.Message)
      End Try
   End Sub
End Class

備註

如需指定 XML Web 服務的通訊協定的詳細資訊,請參閱 使用 ASP.NET 的 XML Web 服務。 如需 Web 服務描述語言 (WSDL) 的詳細資訊,請參閱 WSDL 規格。

建構函式

MimeTextMatch()

初始化 MimeTextMatch 類別的新執行個體。

屬性

Capture

取得或設定值,指出群組中的 MimeTextMatch 以零起始的索引。

Group

取得或設定值,指出要在其中取代文字搜尋結果的群組數目。

IgnoreCase

取得或設定值,指出搜尋是否應該忽略要搜尋的文字的大小寫。

Matches

取得搜尋到的文字模式比對的集合。

Name

取得或設定 MimeTextMatch 的名稱。

Pattern

取得或設定搜尋的文字模式。

Repeats

取得或設定值,指出搜尋的執行次數。

RepeatsString

取得或設定值,指出搜尋的執行次數。

Type

取得或設定值,指出要搜尋的文字的 MIME 格式。

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於