LogicalMethodInfo.CustomAttributeProvider プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > LogicalMethodInfo.CustomAttributeProvider プロパティの意味・解説 

LogicalMethodInfo.CustomAttributeProvider プロパティ

メソッド適用されるカスタム属性取得します

名前空間: System.Web.Services.Protocols
アセンブリ: System.Web.Services (system.web.services.dll 内)
構文構文

Public ReadOnly Property
 CustomAttributeProvider As ICustomAttributeProvider
Dim instance As LogicalMethodInfo
Dim value As ICustomAttributeProvider

value = instance.CustomAttributeProvider
public ICustomAttributeProvider CustomAttributeProvider { get;
 }
public:
property ICustomAttributeProvider^ CustomAttributeProvider {
    ICustomAttributeProvider^ get ();
}
/** @property */
public ICustomAttributeProvider get_CustomAttributeProvider ()
public function get CustomAttributeProvider
 () : ICustomAttributeProvider

プロパティ
メソッドカスタム属性を表す ICustomAttributeProvider。

使用例使用例
Imports System
Imports System.Reflection
Imports System.Web.Services.Protocols
Imports MicroSoft.VisualBasic

' Define a custom attribute with one named parameter.
<AttributeUsage(AttributeTargets.Method Or AttributeTargets.ReturnValue,
 AllowMultiple := True)>  _
Public Class MyAttribute
   Inherits Attribute

   Private myName As String
   
   Public Sub New(name As
 String)
      myName = name
   End Sub 'New
   
   Public ReadOnly Property
 Name() As String
      Get
         Return myName
      End Get
   End Property
End Class 'MyAttribute

Public Class MyService
   
<MyAttribute("This is the first sample attribute"),
 MyAttribute("This is the second sample attribute")>
  _
   Public Function Add(xValue As
 Integer, yValue As Integer)
  _
                 As<MyAttribute("This is
 the return sample attribute")> Integer
      Return xValue + yValue
   End Function 'Add
End Class 'MyService


Public Class LogicalMethodInfo_GetCustomAttribute
   
   Public Shared Sub Main()
      Dim myType As Type = GetType(MyService)
      Dim myMethodInfo As MethodInfo = myType.GetMethod("Add")
      ' Create a synchronous 'LogicalMethodInfo' instance.
      Dim myLogicalMethodInfo As LogicalMethodInfo
 = _
                 LogicalMethodInfo.Create(New MethodInfo() {myMethodInfo},
 LogicalMethodTypes.Sync)(0)
      ' Display the method for which the attributes are being displayed.
      Console.WriteLine(ControlChars.NewLine + "Displaying the
 attributes for the method : {0}" + _
                 ControlChars.NewLine, myLogicalMethodInfo.MethodInfo.ToString())
      
      ' Displaying a custom attribute of type 'MyAttribute'
      Console.WriteLine(ControlChars.NewLine + "Displaying attribute of
 type 'MyAttribute'" + _
                 ControlChars.NewLine)
      Dim attribute As Object
 = myLogicalMethodInfo.GetCustomAttribute(GetType(MyAttribute))
      Console.WriteLine(CType(attribute, MyAttribute).Name)
      
      ' Display all custom attribute of type 'MyAttribute'.
      Console.WriteLine(ControlChars.NewLine + "Displaying all attributes of
 type 'MyAttribute'" + _
                 ControlChars.NewLine)
      Dim attributes As Object()
 = myLogicalMethodInfo.GetCustomAttributes(GetType(MyAttribute))
      Dim i As Integer
      For i = 0 To attributes.Length - 1
         Console.WriteLine(CType(attributes(i), MyAttribute).Name)
      Next i 
      ' Display all return attributes of type 'MyAttribute'.
      Console.WriteLine(ControlChars.NewLine + "Displaying all return
 attributes of type 'MyAttribute'" + _
                 ControlChars.NewLine)
      Dim myCustomAttributeProvider As ICustomAttributeProvider
 = _
                 myLogicalMethodInfo.ReturnTypeCustomAttributeProvider
      If myCustomAttributeProvider.IsDefined(GetType(MyAttribute),
 True) Then
         attributes = myCustomAttributeProvider.GetCustomAttributes(True)

         For i = 0 To attributes.Length - 1
            If attributes(i).GetType().Equals(GetType(MyAttribute))
 Then
               Console.WriteLine(CType(attributes(i), MyAttribute).Name)
            End If
         Next i 
      End If ' Display all the
 custom attributes of type 'MyAttribute'.
      Console.WriteLine(ControlChars.NewLine + "Displaying all attributes of
 type 'MyAttribute'" + _
                 ControlChars.NewLine)
      myCustomAttributeProvider = myLogicalMethodInfo.CustomAttributeProvider
      If myCustomAttributeProvider.IsDefined(GetType(MyAttribute),
 True) Then
         attributes = myCustomAttributeProvider.GetCustomAttributes(True)

         For i = 0 To attributes.Length - 1
            If attributes(i).GetType().Equals(GetType(MyAttribute))
 Then
               Console.WriteLine(CType(attributes(i), MyAttribute).Name)
            End If
         Next i
      End If
   End Sub 'Main 
End Class 'LogicalMethodInfo_GetCustomAttribute
using System;
using System.Reflection;
using System.Web.Services.Protocols;

// Define a custom attribute with one named parameter.
[AttributeUsage(AttributeTargets.Method | AttributeTargets.ReturnValue, AllowMultiple=true)]
public class MyAttribute : Attribute
{
   private string myName;
   public MyAttribute(string name)
   {
      myName = name;
   }
   public string Name 
   {
      get 
      {
         return myName;
      }
   }
}

public class MyService 
{
   [MyAttribute("This is the first sample attribute")]
   [MyAttribute("This is the second sample attribute")]
   [return: MyAttribute("This is the return
 sample attribute")]
   public int Add(int xValue,
 int yValue)
   {
      return (xValue + yValue);
   }
}

public class LogicalMethodInfo_GetCustomAttribute
{
   public static void Main()
   {
      Type myType = typeof(MyService);
      MethodInfo myMethodInfo = myType.GetMethod("Add");
      // Create a synchronous 'LogicalMethodInfo' instance.
      LogicalMethodInfo myLogicalMethodInfo = 
         (LogicalMethodInfo.Create(new MethodInfo[] {myMethodInfo},
 
                                   LogicalMethodTypes.Sync))[0];
      // Display the method for which the attributes are being displayed.
      Console.WriteLine("\nDisplaying the attributes for
 the method : {0}\n",
                           myLogicalMethodInfo.MethodInfo);

      // Displaying a custom attribute of type 'MyAttribute'
      Console.WriteLine("\nDisplaying attribute of type 'MyAttribute'\n");
      object attribute = myLogicalMethodInfo.GetCustomAttribute(typeof(MyAttribute));
      Console.WriteLine(((MyAttribute)attribute).Name);

      // Display all custom attribute of type 'MyAttribute'.
      Console.WriteLine("\nDisplaying all attributes of type 'MyAttribute'\n");
      object[] attributes = myLogicalMethodInfo.GetCustomAttributes(typeof(MyAttribute));
      for(int i = 0; i < attributes.Length;
 i++)
         Console.WriteLine(((MyAttribute)attributes[i]).Name);

      // Display all return attributes of type 'MyAttribute'.
      Console.WriteLine("\nDisplaying all return attributes
 of type 'MyAttribute'\n");
      ICustomAttributeProvider myCustomAttributeProvider = 
                  myLogicalMethodInfo.ReturnTypeCustomAttributeProvider;
      if(myCustomAttributeProvider.IsDefined(typeof(MyAttribute),
 true))
      {
         attributes = myCustomAttributeProvider.GetCustomAttributes(true);
         for(int i = 0; i < attributes.Length;
 i++)
            if(attributes[i].GetType().Equals(typeof(MyAttribute)))
               Console.WriteLine(((MyAttribute)attributes[i]).Name);
      }

      // Display all the custom attributes of type 'MyAttribute'.
      Console.WriteLine("\nDisplaying all attributes of type 'MyAttribute'\n");
      myCustomAttributeProvider = myLogicalMethodInfo.CustomAttributeProvider;
      if(myCustomAttributeProvider.IsDefined(typeof(MyAttribute),
 true))
      {
         attributes = myCustomAttributeProvider.GetCustomAttributes(true);
         for(int i = 0; i < attributes.Length;
 i++)
            if(attributes[i].GetType().Equals(typeof(MyAttribute)))
               Console.WriteLine(((MyAttribute)attributes[i]).Name);
      }
   }
}
#using <System.Web.Services.dll>

using namespace System;
using namespace System::Reflection;
using namespace System::Web::Services::Protocols;

// Define a custom attribute with one named parameter.

[AttributeUsage(AttributeTargets::Method|AttributeTargets::ReturnValue,
AllowMultiple=true)]
public ref class MyAttribute: public
 Attribute
{
private:
   String^ myName;

public:
   MyAttribute( String^ name )
   {
      myName = name;
   }

   property String^ Name 
   {
      String^ get()
      {
         return myName;
      }
   }
};

public ref class MyService
{
public:

   [MyAttribute("This is the first sample attribute")]
   [MyAttribute("This is the second sample attribute")]
   [returnvalue:MyAttribute("This is the return sample attribute")]
   int Add( int xValue, int
 yValue )
   {
      return (xValue + yValue);
   }
};

int main()
{
   Type^ myType = MyService::typeid;
   MethodInfo^ myMethodInfo = myType->GetMethod( "Add" );

   // Create a synchronous 'LogicalMethodInfo' instance.
   array<MethodInfo^>^temparray = {myMethodInfo};
   LogicalMethodInfo^ myLogicalMethodInfo = (LogicalMethodInfo::Create( temparray,
 LogicalMethodTypes::Sync ))[ 0 ];

   // Display the method for which the attributes are being displayed.
   Console::WriteLine( "\nDisplaying the attributes for the
 method : {0}\n", myLogicalMethodInfo->MethodInfo );

   // Displaying a custom attribute of type 'MyAttribute'
   Console::WriteLine( "\nDisplaying attribute of type 'MyAttribute'\n"
 );
   Object^ attribute = myLogicalMethodInfo->GetCustomAttribute( MyAttribute::typeid
 );
   Console::WriteLine( (dynamic_cast<MyAttribute^>(attribute))->Name );

   // Display all custom attribute of type 'MyAttribute'.
   Console::WriteLine( "\nDisplaying all attributes of type 'MyAttribute'\n"
 );
   array<Object^>^attributes = myLogicalMethodInfo->GetCustomAttributes(
 MyAttribute::typeid );
   for ( int i = 0; i < attributes->Length;
 i++ )
      Console::WriteLine( (dynamic_cast<MyAttribute^>(attributes[ i ]))->Name
 );

   // Display all return attributes of type 'MyAttribute'.
   Console::WriteLine( "\nDisplaying all return attributes
 of type 'MyAttribute'\n" );
   ICustomAttributeProvider^ myCustomAttributeProvider = myLogicalMethodInfo->ReturnTypeCustomAttributeProvider;
   if ( myCustomAttributeProvider->IsDefined( MyAttribute::typeid,
 true ) )
   {
      attributes = myCustomAttributeProvider->GetCustomAttributes( true
 );
      for ( int i = 0; i < attributes->Length;
 i++ )
         if ( attributes[ i ]->GetType()->Equals( MyAttribute::typeid
 ) )
                  Console::WriteLine( (dynamic_cast<MyAttribute^>(attributes[ i ]))->Name
 );
   }

   // Display all the custom attributes of type 'MyAttribute'.
   Console::WriteLine( "\nDisplaying all attributes of type 'MyAttribute'\n"
 );
   myCustomAttributeProvider = myLogicalMethodInfo->CustomAttributeProvider;
   if ( myCustomAttributeProvider->IsDefined( MyAttribute::typeid,
 true ) )
   {
      attributes = myCustomAttributeProvider->GetCustomAttributes( true
 );
      for ( int i = 0; i < attributes->Length;
 i++ )
         if ( attributes[ i ]->GetType()->Equals( MyAttribute::typeid
 ) )
                  Console::WriteLine( (dynamic_cast<MyAttribute^>(attributes[ i ]))->Name
 );
   }
}
import System.*;
import System.Reflection.*;
import System.Web.Services.Protocols.*;

// Define a custom attribute with one named parameter.
/** @attribute AttributeUsage(AttributeTargets.Method 
    | AttributeTargets.ReturnValue, AllowMultiple = true)
 */
public class MyAttribute extends Attribute
{
    private String myName;

    public MyAttribute(String name)
    {
        myName = name;
    } //MyAttribute

    /** @property 
     */
    public String get_Name()
    {
        return myName;
    } //get_Name
} //MyAttribute

public class MyService
{
    /** @attribute MyAttribute("This is the first sample attribute")
     */
    /** @attribute MyAttribute("This is the second sample attribute")
     */
    /** @attribute.return MyAttribute("This is the return
 sample attribute")
     */
    public int Add(int xValue,
 int yValue)
    {
        return xValue + yValue;
    } //Add
} //MyService

public class LogicalMethodInfo_GetCustomAttribute
{
    public static void main(String[]
 args)
    {
        Type myType = MyService.class.ToType();
        MethodInfo myMethodInfo = myType.GetMethod("Add");

        // Create a synchronous 'LogicalMethodInfo' instance.
        LogicalMethodInfo myLogicalMethodInfo = 
            (LogicalMethodInfo)LogicalMethodInfo.Create(new MethodInfo[]
 
            { myMethodInfo }, LogicalMethodTypes.Sync).get_Item(0);

        // Display the method for which the attributes are being displayed.
        Console.WriteLine("\nDisplaying the attributes for
 the method : {0}\n",
            myLogicalMethodInfo.get_MethodInfo());

        // Displaying a custom attribute of type 'MyAttribute'
        Console.WriteLine("\nDisplaying attribute of type 'MyAttribute'\n");
        Object attribute = myLogicalMethodInfo.GetCustomAttribute(
            MyAttribute.class.ToType());
        Console.WriteLine(((MyAttribute)attribute).get_Name());

        // Display all custom attribute of type 'MyAttribute'.
        Console.WriteLine("\nDisplaying all attributes of type "
            + "'MyAttribute'\n");
        Object attributes[] = 
            myLogicalMethodInfo.GetCustomAttributes(MyAttribute.class.ToType());
        for (int i = 0; i < attributes.length;
 i++) {
            Console.WriteLine(((MyAttribute)attributes.get_Item(i)).get_Name());
        }
        // Display all return attributes of type 'MyAttribute'.
        Console.WriteLine("\nDisplaying all return attributes
 "
            + "of type 'MyAttribute'\n");
        ICustomAttributeProvider myCustomAttributeProvider = 
            myLogicalMethodInfo.get_ReturnTypeCustomAttributeProvider();
        if (myCustomAttributeProvider.IsDefined(MyAttribute.class.ToType(),
 
            true)) {
            attributes = myCustomAttributeProvider.GetCustomAttributes(true);
            for (int i = 0; i < attributes.length;
 i++) {
                if (attributes.get_Item(i).GetType().
                    Equals(MyAttribute.class.ToType())) {
                    Console.WriteLine(((MyAttribute)(attributes.get_Item(i))).
                        get_Name());
                }
            }
        }

        // Display all the custom attributes of type 'MyAttribute'.
        Console.WriteLine("\nDisplaying all attributes of type 'MyAttribute'\n");
        myCustomAttributeProvider = 
            myLogicalMethodInfo.get_CustomAttributeProvider();
        if (myCustomAttributeProvider.IsDefined(MyAttribute.class.ToType(),
 
            true)) {
            attributes = myCustomAttributeProvider.GetCustomAttributes(true);
            for (int i = 0; i < attributes.length;
 i++) {
                if (attributes.get_Item(i).GetType().
                    Equals(MyAttribute.class.ToType())) {
                    Console.WriteLine(((MyAttribute)attributes.get_Item(i)).
                        get_Name());
                }
            }
        }
    } //main
} //LogicalMethodInfo_GetCustomAttribute
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
LogicalMethodInfo クラス
LogicalMethodInfo メンバ
System.Web.Services.Protocols 名前空間


このページでは「.NET Framework クラス ライブラリ リファレンス」からLogicalMethodInfo.CustomAttributeProvider プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からLogicalMethodInfo.CustomAttributeProvider プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からLogicalMethodInfo.CustomAttributeProvider プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

LogicalMethodInfo.CustomAttributeProvider プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



LogicalMethodInfo.CustomAttributeProvider プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS