DataObject クラス
アセンブリ: System.Security (system.security.dll 内)


DataObject クラスを使用して、情報またはメタデータを直接 XML 署名に格納します。たとえば、署名の生成日または署名者の ID を格納できます。DataObject クラスは、XML 署名によってカバーされる場合もあればカバーされない場合もあります。
このクラスは、XML 署名に関する W3C (World Wide Web Consortium) 仕様の <Object> 要素に対応しています。W3C 仕様の詳細については、http://www.w3.org/TR/xmldsig-core/ を参照してください。

エンベロープの XML 署名を生成する方法を次のコード例に示します。
Imports System Imports System.IO Imports System.Security.Cryptography Imports System.Security.Cryptography.Xml Imports System.Xml _ Public Class XMLdsigsample1 Shared Sub Main(args() As [String]) ' Create example data to sign. Dim document As New XmlDocument() Dim node As XmlNode = document.CreateNode(XmlNodeType.Element, "", "MyElement", "samples") node.InnerText = "This is some text" document.AppendChild(node) Console.Error.WriteLine("Data to sign:") Console.Error.WriteLine() Console.Error.WriteLine(document.OuterXml) Console.Error.WriteLine() ' Create the SignedXml message. Dim signedXml As New SignedXml() Dim key As RSA = RSA.Create() signedXml.SigningKey = key ' Create a data object to hold the data to sign. Dim dataObject As New DataObject() dataObject.Data = document.ChildNodes dataObject.Id = "MyObjectId" ' Add the data object to the signature. signedXml.AddObject(dataObject) ' Create a reference to be able to package everything into the ' message. Dim reference As New Reference() reference.Uri = "#MyObjectId" ' Add it to the message. signedXml.AddReference(reference) ' Add a KeyInfo. Dim keyInfo As New KeyInfo() keyInfo.AddClause(New RSAKeyValue(key)) signedXml.KeyInfo = keyInfo ' Compute the signature. signedXml.ComputeSignature() ' Get the XML representation of the signature. Dim xmlSignature As XmlElement = signedXml.GetXml() Console.WriteLine(xmlSignature.OuterXml) End Sub 'Main End Class 'XMLdsigsample1
using System; using System.IO; using System.Security.Cryptography; using System.Security.Cryptography.Xml; using System.Xml; public class XMLdsigsample1 { static void Main(String[] args) { // Create example data to sign. XmlDocument document = new XmlDocument(); XmlNode node = document.CreateNode(XmlNodeType.Element, "", "MyElement", "samples"); node.InnerText = "This is some text"; document.AppendChild(node); Console.Error.WriteLine("Data to sign:\n" + document.OuterXml + "\n"); // Create the SignedXml message. SignedXml signedXml = new SignedXml(); RSA key = RSA.Create(); signedXml.SigningKey = key; // Create a data object to hold the data to sign. DataObject dataObject = new DataObject(); dataObject.Data = document.ChildNodes; dataObject.Id = "MyObjectId"; // Add the data object to the signature. signedXml.AddObject(dataObject); // Create a reference to be able to package everything into the // message. Reference reference = new Reference(); reference.Uri = "#MyObjectId"; // Add it to the message. signedXml.AddReference(reference); // Add a KeyInfo. KeyInfo keyInfo = new KeyInfo(); keyInfo.AddClause(new RSAKeyValue(key)); signedXml.KeyInfo = keyInfo; // Compute the signature. signedXml.ComputeSignature(); // Get the XML representation of the signature. XmlElement xmlSignature = signedXml.GetXml(); Console.WriteLine(xmlSignature.OuterXml); } }
#using <System.dll> #using <System.Xml.dll> #using <System.Security.dll> using namespace System; using namespace System::IO; using namespace System::Security::Cryptography; using namespace System::Security::Cryptography::Xml; using namespace System::Xml; int main() { // Create example data to sign. XmlDocument^ document = gcnew XmlDocument; XmlNode^ node = document->CreateNode( XmlNodeType::Element, "", "MyElement", "samples" ); node->InnerText = "This is some text"; document->AppendChild( node ); Console::Error->WriteLine( "Data to sign:\n{0}\n", document->OuterXml ); // Create the SignedXml message. SignedXml^ signedXml = gcnew SignedXml; RSA^ key = RSA::Create(); signedXml->SigningKey = key; // Create a data object to hold the data to sign. DataObject^ dataObject = gcnew DataObject; dataObject->Data = document->ChildNodes; dataObject->Id = "MyObjectId"; // Add the data object to the signature. signedXml->AddObject( dataObject ); // Create a reference to be able to package everything into the // message. Reference^ reference = gcnew Reference; reference->Uri = "#MyObjectId"; // Add it to the message. signedXml->AddReference( reference ); // Add a KeyInfo. KeyInfo^ keyInfo = gcnew KeyInfo; keyInfo->AddClause( gcnew RSAKeyValue( key ) ); signedXml->KeyInfo = keyInfo; // Compute the signature. signedXml->ComputeSignature(); // Get the XML representation of the signature. XmlElement^ xmlSignature = signedXml->GetXml(); Console::WriteLine( xmlSignature->OuterXml ); }
import System.*; import System.IO.*; import System.Security.Cryptography.*; import System.Security.Cryptography.Xml.*; import System.Xml.*; public class XmlDsigSample1 { public static void main(String[] args) { // Create example data to sign. XmlDocument document = new XmlDocument(); XmlNode node = document.CreateNode(XmlNodeType.Element, "", "MyElement", "samples"); node.set_InnerText("This is some text"); document.AppendChild(node); Console.get_Error().WriteLine("Data to sign:\n" + document.get_OuterXml() + "\n"); // Create the SignedXml message. SignedXml signedXml = new SignedXml(); RSA key = RSA.Create(); signedXml.set_SigningKey(key); // Create a data object to hold the data to sign. DataObject dataObject = new DataObject(); dataObject.set_Data(document.get_ChildNodes()); dataObject.set_Id("MyObjectId"); // Add the data object to the signature. signedXml.AddObject(dataObject); // Create a reference to be able to Reference reference = new Reference(); reference.set_Uri("#MyObjectId"); // Add it to the message. signedXml.AddReference(reference); // Add a KeyInfo. KeyInfo keyInfo = new KeyInfo(); keyInfo.AddClause(new RSAKeyValue(key)); signedXml.set_KeyInfo(keyInfo); // Compute the signature. signedXml.ComputeSignature(); // Get the XML representation of the signature. XmlElement xmlSignature = signedXml.GetXml(); Console.WriteLine(xmlSignature.get_OuterXml()); } //main } //XmlDsigSample1
Imports System Imports System.Security.Cryptography Imports System.Security.Cryptography.Xml Imports System.IO Imports System.Xml _ Public Class Verify Public Shared Sub Main(args() As [String]) Console.WriteLine(("Verifying " + args(0) + "...")) ' Create a SignedXml. Dim signedXml As New SignedXml() ' Load the XML. Dim xmlDocument As New XmlDocument() xmlDocument.PreserveWhitespace = True xmlDocument.Load(New XmlTextReader(args(0))) Dim nodeList As XmlNodeList = xmlDocument.GetElementsByTagName("Signature") signedXml.LoadXml(CType(nodeList(0), XmlElement)) If signedXml.CheckSignature() Then Console.WriteLine("Signature check OK") Else Console.WriteLine("Signature check FAILED") End If End Sub 'Main End Class 'Verify
using System; using System.Security.Cryptography; using System.Security.Cryptography.Xml; using System.IO; using System.Xml; public class Verify { public static void Main(String[] args) { Console.WriteLine("Verifying " + args[0] + "..."); // Create a SignedXml. SignedXml signedXml = new SignedXml(); // Load the XML. XmlDocument xmlDocument = new XmlDocument(); xmlDocument.PreserveWhitespace = true; xmlDocument.Load(new XmlTextReader(args[0])); XmlNodeList nodeList = xmlDocument.GetElementsByTagName("Signature"); signedXml.LoadXml((XmlElement)nodeList[0]); if (signedXml.CheckSignature()) { Console.WriteLine("Signature check OK"); } else { Console.WriteLine("Signature check FAILED"); } } }
#using <System.dll> #using <System.Security.dll> #using <System.Xml.dll> using namespace System; using namespace System::Security::Cryptography; using namespace System::Security::Cryptography::Xml; using namespace System::IO; using namespace System::Xml; int main() { array<String^>^args = System::Environment::GetCommandLineArgs(); Console::WriteLine( "Verifying {0}...", args[ 1 ] ); // Create a SignedXml. SignedXml^ signedXml = gcnew SignedXml; // Load the XML. XmlDocument^ xmlDocument = gcnew XmlDocument; xmlDocument->PreserveWhitespace = true; xmlDocument->Load( gcnew XmlTextReader( args[ 1 ] ) ); XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" ); signedXml->LoadXml( safe_cast<XmlElement^>(nodeList[ 0 ]) ); if ( signedXml->CheckSignature() ) { Console::WriteLine( "Signature check OK" ); } else { Console::WriteLine( "Signature check FAILED" ); } }

System.Security.Cryptography.Xml.DataObject


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


DataObject クラス
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

<ClassInterfaceAttribute(ClassInterfaceType.None)> _ Public Class DataObject Implements IDataObject, IDataObject
[ClassInterfaceAttribute(ClassInterfaceType.None)] public class DataObject : IDataObject, IDataObject
[ClassInterfaceAttribute(ClassInterfaceType::None)] public ref class DataObject : IDataObject, IDataObject

DataObject は IDataObject インターフェイスを実装し、そのメソッドは形式に依存しないデータ転送のための機構を提供します。
DataObject は、通常 Clipboard と共に使用されたり、ドラッグ アンド ドロップ操作で使用されたりします。DataObject クラスは、IDataObject インターフェイスの推奨される実装を提供します。独自に IDataObject を実装するのではなく、DataObject クラスを使用することをお勧めします。
異なった形式の複数のデータを DataObject に格納できます。データは、そのデータに関連付けられている形式によって、DataObject から取得されます。データを取り出す側のアプリケーションの形式が不明なので、DataObject のデータを複数の形式にしておくと、アプリケーションのデータが適切な形式になる可能性が高くなります。定義済みの形式については、DataFormats のトピックを参照してください。DataFormats.Format クラスのインスタンスを作成することにより、独自の形式を実装できます。
DataObject にデータを格納するには、データをコンストラクタに渡すか、SetData を呼び出します。同じ DataObject に複数の形式でデータを追加できます。追加するデータがネイティブ形式だけで取得されるようにする場合は、autoConvertパラメータを false に設定して SetData(String,Boolean,Object) を呼び出します。
データは GetData と互換性のある任意の形式で DataObject から取得できます。たとえば、テキストは Unicode に変換できます。データが格納されている形式でデータを取得するには、autoConvert パラメータを false に設定して GetData を呼び出します。
データがどの形式で格納されているかを判断するには、GetFormats を呼び出します。形式を使用できるかどうかを判断するには、目的の形式で GetDataPresent を呼び出します。
Microsoft .NET Framework version 2.0 では、DataObject クラスに、共通の形式のデータを簡単に処理できるようにする追加メソッドが用意されています。特定の形式のデータを DataObject に追加するには、SetText などの適切な SetFormat メソッドを呼び出します。DataObject から特定の形式のデータを取得するには、まず適切な ContainsFormat メソッド (ContainsText など) を呼び出して DataObject にその形式のデータが含まれているかどうかを確認します。DataObject にそのデータが含まれている場合は、次に適切な GetFormat メソッド (GetText など) を呼び出してデータを取得します。
![]() |
---|
クリップボードでメタファイル形式を使用する場合には、特別な配慮が必要な場合があります。DataObject クラスの現在の実装における制限により、.NET Framework で使用されるメタファイル形式は、旧メタファイル形式を使用するアプリケーションでは認識されない場合があります。この場合は、Win32 クリップボード アプリケーション プログラミング インターフェイス (API: Application Programming Interface) で相互運用する必要があります。詳細については、http://support.microsoft.com にある Microsoft サポート技術情報の文書 323530 (「Metafiles on Clipboard Are Not Visible to All Applications」) を参照してください。 クリップボードに格納するには、オブジェクトはシリアル化可能である必要があります。シリアル化の詳細については、「シリアル化」を参照してください。対象のアプリケーションが、非常に限定されたデータ形式を必要とする場合は、シリアル化プロセスでデータにヘッダーを追加すると、アプリケーションがデータを認識できない場合があります。データ形式を維持するには、データを Byte 配列として MemoryStream に追加し、その MemoryStream を SetData メソッドに渡します。 |

DataObject にデータを追加するコード例を次に示します。まず、新しい DataObject が作成されて、その中にコンポーネントが格納されます。次に、DataObject に適切な種類のデータが存在するかどうかを調べます。結果はテキスト ボックスに表示されます。このコードでは、textBox1 が作成されていることが必要です。
Private Sub AddMyData3() ' Creates a component to store in the data object. Dim myComponent As New Component() ' Creates a new data object. Dim myDataObject As New DataObject() ' Adds the component to the DataObject. myDataObject.SetData(myComponent) ' Prints whether data of the specified type is in the DataObject. Dim myType As Type = myComponent.GetType() If myDataObject.GetDataPresent(myType) Then textBox1.Text = "Data of type " & myType.ToString() & _ " is present in the DataObject" Else textBox1.Text = "Data of type " & myType.ToString() & _ " is not present in the DataObject" End If End Sub 'AddMyData3
private void AddMyData3() { // Creates a component to store in the data object. Component myComponent = new Component(); // Creates a new data object. DataObject myDataObject = new DataObject(); // Adds the component to the DataObject. myDataObject.SetData(myComponent); // Prints whether data of the specified type is in the DataObject. Type myType = myComponent.GetType(); if(myDataObject.GetDataPresent(myType)) textBox1.Text = "Data of type " + myType.ToString() + " is present in the DataObject"; else textBox1.Text = "Data of type " + myType.ToString() + " is not present in the DataObject"; }
private: void AddMyData3() { // Creates a component to store in the data object. Component^ myComponent = gcnew Component; // Creates a new data object. DataObject^ myDataObject = gcnew DataObject; // Adds the component to the DataObject. myDataObject->SetData( myComponent ); // Prints whether data of the specified type is in the DataObject. Type^ myType = myComponent->GetType(); if ( myDataObject->GetDataPresent( myType ) ) { textBox1->Text = String::Concat( "Data of type ", myType, " is present in the DataObject" ); } else { textBox1->Text = String::Concat( "Data of type ", myType, " is not present in the DataObject" ); } }
private void AddMyData3() { // Creates a component to store in the data object. Component myComponent = new Component(); // Creates a new data object. DataObject myDataObject = new DataObject(); // Adds the component to the DataObject. myDataObject.SetData(myComponent); // Prints whether data of the specified type is in the DataObject. Type myType = myComponent.GetType(); if (myDataObject.GetDataPresent(myType)) { textBox1.set_Text("Data of type " + myType.ToString() + " is present in the DataObject"); } else { textBox1.set_Text("Data of type " + myType.ToString() + " is not present in the DataObject"); } } //AddMyData3
DataObject に格納されているデータを取得する例を次に示します。まず、テキスト データを含む新しい DataObject が作成されます。次に、そのデータが取得され、形式が文字列に指定されてテキスト ボックスに表示されます。データ形式は自動的にテキストから文字列に変換されます。このコードでは、textBox1 が作成されていることが必要です。
Private Sub GetMyData2() ' Creates a new data object using a string and the text format. Dim myDataObject As New DataObject(DataFormats.Text, "Text to Store") ' Prints the string in a text box. textBox1.Text = myDataObject.GetData("System.String").ToString() End Sub 'GetMyData2
private void GetMyData2() { // Creates a new data object using a string and the text format. DataObject myDataObject = new DataObject(DataFormats.Text, "Text to Store"); // Prints the string in a text box. textBox1.Text = myDataObject.GetData("System.String").ToString(); }

System.Windows.Forms.DataObject


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


DataObject コンストラクタ ()
アセンブリ: System.Security (system.security.dll 内)



エンベロープの XML 署名を生成する方法を次のコード例に示します。
Imports System Imports System.IO Imports System.Security.Cryptography Imports System.Security.Cryptography.Xml Imports System.Xml _ Public Class XMLdsigsample1 Shared Sub Main(args() As [String]) ' Create example data to sign. Dim document As New XmlDocument() Dim node As XmlNode = document.CreateNode(XmlNodeType.Element, "", "MyElement", "samples") node.InnerText = "This is some text" document.AppendChild(node) Console.Error.WriteLine("Data to sign:") Console.Error.WriteLine() Console.Error.WriteLine(document.OuterXml) Console.Error.WriteLine() ' Create the SignedXml message. Dim signedXml As New SignedXml() Dim key As RSA = RSA.Create() signedXml.SigningKey = key ' Create a data object to hold the data to sign. Dim dataObject As New DataObject() dataObject.Data = document.ChildNodes dataObject.Id = "MyObjectId" ' Add the data object to the signature. signedXml.AddObject(dataObject) ' Create a reference to be able to package everything into the ' message. Dim reference As New Reference() reference.Uri = "#MyObjectId" ' Add it to the message. signedXml.AddReference(reference) ' Add a KeyInfo. Dim keyInfo As New KeyInfo() keyInfo.AddClause(New RSAKeyValue(key)) signedXml.KeyInfo = keyInfo ' Compute the signature. signedXml.ComputeSignature() ' Get the XML representation of the signature. Dim xmlSignature As XmlElement = signedXml.GetXml() Console.WriteLine(xmlSignature.OuterXml) End Sub 'Main End Class 'XMLdsigsample1
using System; using System.IO; using System.Security.Cryptography; using System.Security.Cryptography.Xml; using System.Xml; public class XMLdsigsample1 { static void Main(String[] args) { // Create example data to sign. XmlDocument document = new XmlDocument(); XmlNode node = document.CreateNode(XmlNodeType.Element, "", "MyElement", "samples"); node.InnerText = "This is some text"; document.AppendChild(node); Console.Error.WriteLine("Data to sign:\n" + document.OuterXml + "\n"); // Create the SignedXml message. SignedXml signedXml = new SignedXml(); RSA key = RSA.Create(); signedXml.SigningKey = key; // Create a data object to hold the data to sign. DataObject dataObject = new DataObject(); dataObject.Data = document.ChildNodes; dataObject.Id = "MyObjectId"; // Add the data object to the signature. signedXml.AddObject(dataObject); // Create a reference to be able to package everything into the // message. Reference reference = new Reference(); reference.Uri = "#MyObjectId"; // Add it to the message. signedXml.AddReference(reference); // Add a KeyInfo. KeyInfo keyInfo = new KeyInfo(); keyInfo.AddClause(new RSAKeyValue(key)); signedXml.KeyInfo = keyInfo; // Compute the signature. signedXml.ComputeSignature(); // Get the XML representation of the signature. XmlElement xmlSignature = signedXml.GetXml(); Console.WriteLine(xmlSignature.OuterXml); } }
#using <System.dll> #using <System.Xml.dll> #using <System.Security.dll> using namespace System; using namespace System::IO; using namespace System::Security::Cryptography; using namespace System::Security::Cryptography::Xml; using namespace System::Xml; int main() { // Create example data to sign. XmlDocument^ document = gcnew XmlDocument; XmlNode^ node = document->CreateNode( XmlNodeType::Element, "", "MyElement", "samples" ); node->InnerText = "This is some text"; document->AppendChild( node ); Console::Error->WriteLine( "Data to sign:\n{0}\n", document->OuterXml ); // Create the SignedXml message. SignedXml^ signedXml = gcnew SignedXml; RSA^ key = RSA::Create(); signedXml->SigningKey = key; // Create a data object to hold the data to sign. DataObject^ dataObject = gcnew DataObject; dataObject->Data = document->ChildNodes; dataObject->Id = "MyObjectId"; // Add the data object to the signature. signedXml->AddObject( dataObject ); // Create a reference to be able to package everything into the // message. Reference^ reference = gcnew Reference; reference->Uri = "#MyObjectId"; // Add it to the message. signedXml->AddReference( reference ); // Add a KeyInfo. KeyInfo^ keyInfo = gcnew KeyInfo; keyInfo->AddClause( gcnew RSAKeyValue( key ) ); signedXml->KeyInfo = keyInfo; // Compute the signature. signedXml->ComputeSignature(); // Get the XML representation of the signature. XmlElement^ xmlSignature = signedXml->GetXml(); Console::WriteLine( xmlSignature->OuterXml ); }
import System.*; import System.IO.*; import System.Security.Cryptography.*; import System.Security.Cryptography.Xml.*; import System.Xml.*; public class XmlDsigSample1 { public static void main(String[] args) { // Create example data to sign. XmlDocument document = new XmlDocument(); XmlNode node = document.CreateNode(XmlNodeType.Element, "", "MyElement", "samples"); node.set_InnerText("This is some text"); document.AppendChild(node); Console.get_Error().WriteLine("Data to sign:\n" + document.get_OuterXml() + "\n"); // Create the SignedXml message. SignedXml signedXml = new SignedXml(); RSA key = RSA.Create(); signedXml.set_SigningKey(key); // Create a data object to hold the data to sign. DataObject dataObject = new DataObject(); dataObject.set_Data(document.get_ChildNodes()); dataObject.set_Id("MyObjectId"); // Add the data object to the signature. signedXml.AddObject(dataObject); // Create a reference to be able to Reference reference = new Reference(); reference.set_Uri("#MyObjectId"); // Add it to the message. signedXml.AddReference(reference); // Add a KeyInfo. KeyInfo keyInfo = new KeyInfo(); keyInfo.AddClause(new RSAKeyValue(key)); signedXml.set_KeyInfo(keyInfo); // Compute the signature. signedXml.ComputeSignature(); // Get the XML representation of the signature. XmlElement xmlSignature = signedXml.GetXml(); Console.WriteLine(xmlSignature.get_OuterXml()); } //main } //XmlDsigSample1
Imports System Imports System.Security.Cryptography Imports System.Security.Cryptography.Xml Imports System.IO Imports System.Xml _ Public Class Verify Public Shared Sub Main(args() As [String]) Console.WriteLine(("Verifying " + args(0) + "...")) ' Create a SignedXml. Dim signedXml As New SignedXml() ' Load the XML. Dim xmlDocument As New XmlDocument() xmlDocument.PreserveWhitespace = True xmlDocument.Load(New XmlTextReader(args(0))) Dim nodeList As XmlNodeList = xmlDocument.GetElementsByTagName("Signature") signedXml.LoadXml(CType(nodeList(0), XmlElement)) If signedXml.CheckSignature() Then Console.WriteLine("Signature check OK") Else Console.WriteLine("Signature check FAILED") End If End Sub 'Main End Class 'Verify
using System; using System.Security.Cryptography; using System.Security.Cryptography.Xml; using System.IO; using System.Xml; public class Verify { public static void Main(String[] args) { Console.WriteLine("Verifying " + args[0] + "..."); // Create a SignedXml. SignedXml signedXml = new SignedXml(); // Load the XML. XmlDocument xmlDocument = new XmlDocument(); xmlDocument.PreserveWhitespace = true; xmlDocument.Load(new XmlTextReader(args[0])); XmlNodeList nodeList = xmlDocument.GetElementsByTagName("Signature"); signedXml.LoadXml((XmlElement)nodeList[0]); if (signedXml.CheckSignature()) { Console.WriteLine("Signature check OK"); } else { Console.WriteLine("Signature check FAILED"); } } }
#using <System.dll> #using <System.Security.dll> #using <System.Xml.dll> using namespace System; using namespace System::Security::Cryptography; using namespace System::Security::Cryptography::Xml; using namespace System::IO; using namespace System::Xml; int main() { array<String^>^args = System::Environment::GetCommandLineArgs(); Console::WriteLine( "Verifying {0}...", args[ 1 ] ); // Create a SignedXml. SignedXml^ signedXml = gcnew SignedXml; // Load the XML. XmlDocument^ xmlDocument = gcnew XmlDocument; xmlDocument->PreserveWhitespace = true; xmlDocument->Load( gcnew XmlTextReader( args[ 1 ] ) ); XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" ); signedXml->LoadXml( safe_cast<XmlElement^>(nodeList[ 0 ]) ); if ( signedXml->CheckSignature() ) { Console::WriteLine( "Signature check OK" ); } else { Console::WriteLine( "Signature check FAILED" ); } }

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


DataObject コンストラクタ ()
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)


DataObject を作成し、データを追加するコード例を次に示します。この例では、次に、データを取得して表示します。このコードでは、textBox1 が作成されていることが必要です。
Private Sub CreateDefaultDataObject() ' Creates a data object. Dim myDataObject As DataObject ' Assigns the string to the data object. Dim myString As String = "My text string" myDataObject = New DataObject(myString) ' Prints the string in a text box. textBox1.Text = myDataObject.GetData(DataFormats.Text).ToString() End Sub 'CreateDefaultDataObject
private void CreateDefaultDataObject() { // Creates a data object. DataObject myDataObject; // Assigns the string to the data object. string myString = "My text string"; myDataObject = new DataObject(myString); // Prints the string in a text box. textBox1.Text = myDataObject.GetData(DataFormats.Text).ToString(); }
private: void CreateDefaultDataObject() { // Creates a data object. DataObject^ myDataObject; // Assigns the string to the data object. String^ myString = "My text string"; myDataObject = gcnew DataObject( myString ); // Prints the string in a text box. textBox1->Text = myDataObject->GetData( DataFormats::Text )->ToString(); }
private void CreateDefaultDataObject() { // Creates a data object. DataObject myDataObject; // Assigns the string to the data object. String myString = "My text string"; myDataObject = new DataObject(myString); // Prints the string in a text box. textBox1.set_Text(myDataObject.GetData(DataFormats.Text).ToString()); } //CreateDefaultDataObject

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


DataObject コンストラクタ (String, Object)
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)


文字列型として指定された文字列を使用して DataObject クラスを作成するコード例を次に示します。データは、データの形式をテキストに指定すると、DataObject から取得されます。結果はテキスト ボックスに表示されます。このコードでは、textBox1 が作成されていることが必要です。
Private Sub CreateTextDataObject2() ' Creates a new data object using a string. Dim myString As String = "My next text string" Dim myDataObject As New DataObject("System.String", myString) ' Prints the string in a text box. textBox1.Text = myDataObject.GetData(DataFormats.Text).ToString() End Sub 'CreateTextDataObject2
private void CreateTextDataObject2() { // Creates a new data object using a string. string myString = "My next text string"; DataObject myDataObject = new DataObject("System.String", myString); // Prints the string in a text box. textBox1.Text = myDataObject.GetData(DataFormats.Text).ToString(); }
private: void CreateTextDataObject2() { // Creates a new data object using a string. String^ myString = "My next text string"; DataObject^ myDataObject = gcnew DataObject( "System.String",myString ); // Prints the string in a text box. textBox1->Text = myDataObject->GetData( DataFormats::Text )->ToString(); }
private void CreateTextDataObject2() { // Creates a new data object using a string. String myString = "My next text string"; DataObject myDataObject = new DataObject("String", myString); // Prints the string in a text box. textBox1.set_Text(myDataObject.GetData(DataFormats.Text).ToString()); } //CreateTextDataObject2

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


DataObject コンストラクタ (String, String, String, XmlElement)
アセンブリ: System.Security (system.security.dll 内)

Public Sub New ( _ id As String, _ mimeType As String, _ encoding As String, _ data As XmlElement _ )
Dim id As String Dim mimeType As String Dim encoding As String Dim data As XmlElement Dim instance As New DataObject(id, mimeType, encoding, data)


DataObject クラスは、XML 署名と一緒に使用します。id パラメータは、使用するデータを含む要素の名前を参照します。data パラメータは、id パラメータ要素を含む XML ノード リストを参照します。

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


DataObject コンストラクタ (Object)
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)


このコンストラクタを使用すると、データを任意の形式で DataObject に追加できます。または、データを IDataObject として追加すると、一度に複数の形式を指定できます。COM プログラミングに慣れていれば、COM IDataObject インターフェイスを実装するデータ オブジェクトを追加することもできます。詳細については、MSDN ライブラリ (http://msdn.microsoft.com/library/ja) で IDataObject のトピックを参照してください。

文字列を含んだ DataObject を作成するコード例を次に示します。データは、そのデータ形式を使用して取得されます。結果はテキスト ボックスに表示されます。このコードでは、textBox1 が作成されていることが必要です。
Private Sub CreateTextDataObject() ' Creates a new data object using a string. Dim myString As String = "My text string" Dim myDataObject As New DataObject(myString) ' Prints the string in a text box. textBox1.Text = myDataObject.GetData(DataFormats.Text).ToString() End Sub 'CreateTextDataObject
private void CreateTextDataObject() { // Creates a new data object using a string. string myString = "My text string"; DataObject myDataObject = new DataObject(myString); // Prints the string in a text box. textBox1.Text = myDataObject.GetData(DataFormats.Text).ToString(); }
private: void CreateTextDataObject() { // Creates a new data object using a string. String^ myString = "My text string"; DataObject^ myDataObject = gcnew DataObject( myString ); // Prints the string in a text box. textBox1->Text = myDataObject->GetData( DataFormats::Text )->ToString(); }
private void CreateTextDataObject() { // Creates a new data object using a string. String myString = "My text string"; DataObject myDataObject = new DataObject(myString); // Prints the string in a text box. textBox1.set_Text(myDataObject.GetData(DataFormats.Text).ToString()); } //CreateTextDataObject

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


DataObject コンストラクタ

名前 | 説明 |
---|---|
DataObject () | DataObject クラスの新しいインスタンスを初期化します。 |
DataObject (String, String, String, XmlElement) | 指定した ID、MIME 型、エンコーディング、およびデータを使用して、DataObject クラスの新しいインスタンスを初期化します。 |

DataObject コンストラクタ

名前 | 説明 |
---|---|
DataObject () | DataObject クラスの新しいインスタンスを初期化します。 .NET Compact Framework によってサポートされています。 |
DataObject (Object) | DataObject クラスの新しいインスタンスを初期化し、指定したオブジェクトを追加します。 .NET Compact Framework によってサポートされています。 |
DataObject (String, Object) | DataObject クラスの新しいインスタンスを初期化し、指定したオブジェクトを指定した形式で追加します。 .NET Compact Framework によってサポートされています。 |

DataObject プロパティ

名前 | 説明 | |
---|---|---|
![]() | Data | 現在の DataObject オブジェクトのデータ値を取得または設定します。 |
![]() | Encoding | 現在の DataObject オブジェクトのエンコーディングを取得または設定します。 |
![]() | Id | 現在の DataObject オブジェクトの ID を取得または設定します。 |
![]() | MimeType | 現在の DataObject オブジェクトの MIME 型を取得または設定します。 |

DataObject メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | GetXml | DataObject オブジェクトの XML 表現を返します。 |
![]() | LoadXml | XML 要素から DataObject の状態を読み込みます。 |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

DataObject メソッド


名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | System.Runtime.InteropServices.ComTypes.IDataObject.DAdvise | このメンバの説明については、IDataObject.DAdvise のトピックを参照してください。 |
![]() | System.Runtime.InteropServices.ComTypes.IDataObject.DUnadvise | このメンバの説明については、IDataObject.DUnadvise のトピックを参照してください。 |
![]() | System.Runtime.InteropServices.ComTypes.IDataObject.EnumDAdvise | このメンバの説明については、IDataObject.EnumDAdvise のトピックを参照してください。 |
![]() | System.Runtime.InteropServices.ComTypes.IDataObject.EnumFormatEtc | このメンバの説明については、IDataObject.EnumFormatEtc のトピックを参照してください。 |
![]() | System.Runtime.InteropServices.ComTypes.IDataObject.GetCanonicalFormatEtc | このメンバの説明については、IDataObject.GetCanonicalFormatEtc のトピックを参照してください。 |
![]() | System.Runtime.InteropServices.ComTypes.IDataObject.GetData | このメンバの説明については、IDataObject.GetData のトピックを参照してください。 |
![]() | System.Runtime.InteropServices.ComTypes.IDataObject.GetDataHere | このメンバの説明については、IDataObject.GetDataHere のトピックを参照してください。 |
![]() | System.Runtime.InteropServices.ComTypes.IDataObject.QueryGetData | このメンバの説明については、IDataObject.QueryGetData のトピックを参照してください。 |
![]() | System.Runtime.InteropServices.ComTypes.IDataObject.SetData | このメンバの説明については、IDataObject.SetData のトピックを参照してください。 |

DataObject メンバ
署名されているデータを保持する、XML 署名のオブジェクト要素を表します。
DataObject データ型で公開されるメンバを以下の表に示します。


名前 | 説明 | |
---|---|---|
![]() | Data | 現在の DataObject オブジェクトのデータ値を取得または設定します。 |
![]() | Encoding | 現在の DataObject オブジェクトのエンコーディングを取得または設定します。 |
![]() | Id | 現在の DataObject オブジェクトの ID を取得または設定します。 |
![]() | MimeType | 現在の DataObject オブジェクトの MIME 型を取得または設定します。 |

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | GetXml | DataObject オブジェクトの XML 表現を返します。 |
![]() | LoadXml | XML 要素から DataObject の状態を読み込みます。 |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

DataObject メンバ
DataObject データ型で公開されるメンバを以下の表に示します。



名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | System.Runtime.InteropServices.ComTypes.IDataObject.DAdvise | このメンバの説明については、IDataObject.DAdvise のトピックを参照してください。 |
![]() | System.Runtime.InteropServices.ComTypes.IDataObject.DUnadvise | このメンバの説明については、IDataObject.DUnadvise のトピックを参照してください。 |
![]() | System.Runtime.InteropServices.ComTypes.IDataObject.EnumDAdvise | このメンバの説明については、IDataObject.EnumDAdvise のトピックを参照してください。 |
![]() | System.Runtime.InteropServices.ComTypes.IDataObject.EnumFormatEtc | このメンバの説明については、IDataObject.EnumFormatEtc のトピックを参照してください。 |
![]() | System.Runtime.InteropServices.ComTypes.IDataObject.GetCanonicalFormatEtc | このメンバの説明については、IDataObject.GetCanonicalFormatEtc のトピックを参照してください。 |
![]() | System.Runtime.InteropServices.ComTypes.IDataObject.GetData | このメンバの説明については、IDataObject.GetData のトピックを参照してください。 |
![]() | System.Runtime.InteropServices.ComTypes.IDataObject.GetDataHere | このメンバの説明については、IDataObject.GetDataHere のトピックを参照してください。 |
![]() | System.Runtime.InteropServices.ComTypes.IDataObject.QueryGetData | このメンバの説明については、IDataObject.QueryGetData のトピックを参照してください。 |
![]() | System.Runtime.InteropServices.ComTypes.IDataObject.SetData | このメンバの説明については、IDataObject.SetData のトピックを参照してください。 |

- DataObjectのページへのリンク