XmlIncludeAttribute クラスとは? わかりやすく解説

XmlIncludeAttribute クラス

XmlSerializer がオブジェクトシリアル化または逆シリアル化するときに、型を認識できるようにします。

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

<AttributeUsageAttribute(AttributeTargets.Class Or AttributeTargets.Struct
 Or AttributeTargets.Method Or AttributeTargets.Interface,
 AllowMultiple:=True)> _
Public Class XmlIncludeAttribute
    Inherits Attribute
Dim instance As XmlIncludeAttribute
[AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Method|AttributeTargets.Interface,
 AllowMultiple=true)] 
public class XmlIncludeAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class|AttributeTargets::Struct|AttributeTargets::Method|AttributeTargets::Interface,
 AllowMultiple=true)] 
public ref class XmlIncludeAttribute : public
 Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Method|AttributeTargets.Interface,
 AllowMultiple=true) */ 
public class XmlIncludeAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Method|AttributeTargets.Interface,
 AllowMultiple=true) 
public class XmlIncludeAttribute extends
 Attribute
解説解説
使用例使用例

次の例では 3 つのクラスがあり、そのうち 2 つ3 番目のクラスから継承したクラスです。この例では、1 つ派生クラスインスタンス返すメソッドXmlIncludeAttribute適用します。

<%@ WebService Language="C#" Class="Test" %>
 
using System;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Services.Description;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using System.Data;
 
public class Test : WebService {
   [WebMethod()]
   [return:XmlElement("MyTime", DataType="time")]
   public DateTime EchoString([XmlElement(DataType="string")]
 
   string strval) {
        return DateTime.Now;
   }
 
   [WebMethod()]
   [XmlInclude(typeof(Car)), XmlInclude(typeof(Bike))]
   public Vehicle Vehicle(string licenseNumber)
 {
      if (licenseNumber == "0") {
         Vehicle v = new Car();
         v.licenseNumber = licenseNumber;
         return v;
      }
      else if (licenseNumber == "1")
 {
          Vehicle v = new Bike();
          v.licenseNumber = licenseNumber;
          return v;
      }
      else {
         return null;
      }
   }
}
[XmlRoot("NewVehicle")] 
public abstract class Vehicle {
    public string licenseNumber;
    public DateTime make;
}
 
public class Car : Vehicle {
}
 
public class Bike : Vehicle {
}
   
継承階層継承階層
System.Object
   System.Attribute
    System.Xml.Serialization.XmlIncludeAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

「XmlIncludeAttribute クラス」の関連用語

XmlIncludeAttribute クラスのお隣キーワード
検索ランキング

   

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



XmlIncludeAttribute クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS