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

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

SoapAttributes.SoapEnum プロパティ

XmlSerializer が SOAP 列挙体をシリアル化する方法指定するオブジェクト取得または指定します

名前空間: System.Xml.Serialization
アセンブリ: System.Xml (system.xml.dll 内)
構文構文

Public Property SoapEnum As
 SoapEnumAttribute
Dim instance As SoapAttributes
Dim value As SoapEnumAttribute

value = instance.SoapEnum

instance.SoapEnum = value
public SoapEnumAttribute SoapEnum { get; set;
 }
public:
property SoapEnumAttribute^ SoapEnum {
    SoapEnumAttribute^ get ();
    void set (SoapEnumAttribute^ value);
}
/** @property */
public SoapEnumAttribute get_SoapEnum ()

/** @property */
public void set_SoapEnum (SoapEnumAttribute
 value)
public function get SoapEnum
 () : SoapEnumAttribute

public function set SoapEnum
 (value : SoapEnumAttribute)

プロパティ
SoapEnumAttribute。

解説解説

SoapEnumAttribute は、列挙メンバシリアル化制御するために使用しますそのようなメンバシリアル化オーバーライドするには、SoapEnum プロパティ新しSoapEnumAttribute設定します

詳細については、SoapAttributeOverrides クラス概要参照してください

使用例使用例

FoodFoodType という名前の 2 つクラスシリアル化する例を次に示しますFoodType クラスには、オーバーライド対象列挙体が 2 つ含まれており、この例は、それぞれの列挙体について SoapEnumAttribute作成し、それらを SoapAttributes の SoapEnum プロパティ割り当ててます。その後、この SoapAttributesSoapAttributeOverrides追加し、これを使用して XmlSerializer作成します

Imports System
Imports System.IO
Imports System.Xml
Imports System.Xml.Serialization

Public Class Group
   Public GroupName As String
 
   Public Grouptype As GroupType 
End Class

Public enum GroupType
' Use the SoapEnumAttribute to instruct the XmlSerializer
' to generate Small and Large instead of A and B.
   <SoapEnum("Small")> _
   A
   <SoapEnum("Large")> _
   B
End enum
 
Public Class Run
   Public Shared Sub Main()
      Dim test As Run = new
 Run()
      test.SerializeObject("SoapEnum.xml")
      test.SerializeOverride("SoapOverride.xml")
      Console.WriteLine("Fininished writing two files")
   End Sub

   Private Shared Sub SerializeObject(filename
 As string)
      ' Create an instance of the XmlSerializer Class.
      Dim mapp  As XmlTypeMapping = _
      (New SoapReflectionImporter()).ImportTypeMapping(GetType(Group))
      Dim mySerializer As XmlSerializer = 
 New XmlSerializer(mapp)

      ' Writing the file requires a TextWriter.
      Dim writer As TextWriter = New
 StreamWriter(filename)

      ' Create an instance of the Class that will be serialized.
      Dim myGroup As Group = New
 Group()

      ' Set the object properties.
      myGroup.GroupName = ".NET"
      myGroup.Grouptype= GroupType.A

      ' Serialize the Class, and close the TextWriter.
      mySerializer.Serialize(writer, myGroup)
       writer.Close()
   End Sub

   Private  Sub SerializeOverride(fileName
 As String)
      Dim soapOver As SoapAttributeOverrides
 = new SoapAttributeOverrides()
      Dim SoapAtts As SoapAttributes = new
 SoapAttributes()

      ' Add a SoapEnumAttribute for the GroupType.A enumerator. Instead
      ' of 'A' it will be "West".
      Dim soapEnum As SoapEnumAttribute = new
 SoapEnumAttribute("West")
      ' Override the "A" enumerator.
      SoapAtts.SoapEnum = soapEnum
      soapOver.Add(GetType(GroupType), "A",
 SoapAtts)

      ' Add another SoapEnumAttribute for the GroupType.B enumerator.
      ' Instead of 'B' it will be "East".
      SoapAtts= New SoapAttributes()
      soapEnum = new SoapEnumAttribute()
      soapEnum.Name = "East"
      SoapAtts.SoapEnum = soapEnum
      soapOver.Add(GetType(GroupType), "B",
 SoapAtts)

      ' Create an XmlSerializer used for overriding.
      Dim map As XmlTypeMapping = New
 SoapReflectionImporter _
      (soapOver).ImportTypeMapping(GetType(Group))
      Dim ser As XmlSerializer = New
 XmlSerializer(map)
      Dim myGroup As Group = New
 Group()
      myGroup.GroupName = ".NET"
      myGroup.Grouptype = GroupType.B
      ' Writing the file requires a TextWriter.
      Dim writer As TextWriter = New
 StreamWriter(fileName)
      ser.Serialize(writer, myGroup)
      writer.Close

   End Sub
End Class
using System;
using System.IO;
using System.Xml;
using System.Xml.Serialization;

public class Group{
   public string GroupName;
   public GroupType Grouptype;
}

public enum GroupType{
   // Use the SoapEnumAttribute to instruct the XmlSerializer
   // to generate Small and Large instead of A and B.
   [SoapEnum("Small")]
   A,
   [SoapEnum("Large")]
   B
}
 
public class Run {
   static void Main(){
      Run test= new Run();
      test.SerializeObject("SoapEnum.xml");
      test.SerializeOverride("SoapOverride.xml");
      Console.WriteLine("Fininished writing two files");
   }

     private void SerializeObject(string
 filename){
      // Create an instance of the XmlSerializer Class.
      XmlTypeMapping mapp  =
      (new SoapReflectionImporter()).ImportTypeMapping(typeof(Group));
      XmlSerializer mySerializer =  new XmlSerializer(mapp);

      // Writing the file requires a TextWriter.
      TextWriter writer = new StreamWriter(filename);

      // Create an instance of the Class that will be serialized.
      Group myGroup = new Group();

      // Set the object properties.
      myGroup.GroupName = ".NET";
      myGroup.Grouptype= GroupType.A;

      // Serialize the Class, and close the TextWriter.
      mySerializer.Serialize(writer, myGroup);
       writer.Close();
   }

   private void SerializeOverride(string
 fileName){
      SoapAttributeOverrides soapOver = new SoapAttributeOverrides();
      SoapAttributes SoapAtts = new SoapAttributes();

      // Add a SoapEnumAttribute for the GroupType.A enumerator.   
    
      // Instead of 'A'  it will be "West".
      SoapEnumAttribute soapEnum = new SoapEnumAttribute("West");
      // Override the "A" enumerator.
      SoapAtts.SoapEnum = soapEnum;
      soapOver.Add(typeof(GroupType), "A", SoapAtts);

      // Add another SoapEnumAttribute for the GroupType.B enumerator.
      // Instead of //B// it will be "East".
      SoapAtts= new SoapAttributes();
      soapEnum = new SoapEnumAttribute();
      soapEnum.Name = "East";
      SoapAtts.SoapEnum = soapEnum;
      soapOver.Add(typeof(GroupType), "B", SoapAtts);

      // Create an XmlSerializer used for overriding.
      XmlTypeMapping map = 
      new SoapReflectionImporter(soapOver).
      ImportTypeMapping(typeof(Group));
      XmlSerializer ser = new XmlSerializer(map);
      Group myGroup = new Group();
      myGroup.GroupName = ".NET";
      myGroup.Grouptype = GroupType.B;
      // Writing the file requires a TextWriter.
      TextWriter writer = new StreamWriter(fileName);
      ser.Serialize(writer, myGroup);
      writer.Close();
       }
}
import System.*;
import System.IO.*;
import System.Xml.*;
import System.Xml.Serialization.*;

public class Group
{
    public String groupName;
    public GroupType groupType;
} //Group

public class GroupType
{
    // Use the SoapEnumAttribute to instruct the XmlSerializer
    // to generate Small and Large instead of a and b.
    public int member;

    public GroupType()
    {
        member = 0;
    } //GroupType

    public GroupType(int n)
    {
        member = n;
    } //GroupType

    /** @attribute SoapEnum("Small")
     */
    public static int a
 = 0;

    /** @attribute SoapEnum("Large")
     */
    public static int b
 = 1;
} //GroupType

public class Run
{
    public static void main(String[]
 args)
    {
        Run test = new Run();
        test.SerializeObject("SoapEnum.xml");
        test.SerializeOverride("SoapOverride.xml");
        Console.WriteLine("Fininished writing two files");
    } //main

    private void SerializeObject(String fileName)
    {
        // Writing the file requires a TextWriter.
        TextWriter writer = new StreamWriter(fileName);
        // Create an instance of the Class that will be serialized.
        Group myGroup = new Group();
        // Set the object properties.
        myGroup.groupName = ".NET";
        myGroup.groupType = new GroupType(GroupType.a);
        // Create an instance of the XmlSerializer Class.
        XmlSerializer mySerializer = new XmlSerializer(myGroup.GetType());
        // Serialize the Class, and close the TextWriter.
        mySerializer.Serialize(writer, myGroup);
        writer.Close();
    } //SerializeObject

    private void SerializeOverride(String fileName)
    {
        SoapAttributeOverrides soapOver = new SoapAttributeOverrides();
        SoapAttributes SoapAtts = new SoapAttributes();
        // Add a SoapEnumAttribute for the GroupType.a enumerator. 
      
        // Instead of 'a'  it will be "West".
        SoapEnumAttribute soapEnum = new SoapEnumAttribute("West");
        // Override the "a" enumerator.
        SoapAtts.set_SoapEnum(soapEnum);
        soapOver.Add(GroupType.class.ToType(), "a",
 SoapAtts);
        // Add another SoapEnumAttribute for the GroupType.b enumerator.
        // Instead of b it will be "East".
        SoapAtts = new SoapAttributes();
        soapEnum = new SoapEnumAttribute();
        soapEnum.set_Name("East");
        SoapAtts.set_SoapEnum(soapEnum);
        soapOver.Add(GroupType.class.ToType(), "b",
 SoapAtts);
        // Create an XmlSerializer used for overriding.
        Group myGroup = new Group();
        myGroup.groupName = ".NET";
        myGroup.groupType = new GroupType(GroupType.b);
        // Writing the file requires a TextWriter.
        TextWriter writer = new StreamWriter(fileName);
        XmlSerializer ser = new XmlSerializer(myGroup.GetType());
        ser.Serialize(writer, myGroup);
        writer.Close();
    } //SerializeOverride
} //Run
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

「SoapAttributes.SoapEnum プロパティ」の関連用語

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

   

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



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

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

©2024 GRAS Group, Inc.RSS