Condividi tramite


SoapDuration Classe

Definizione

Fornisce metodi statici per la serializzazione e la deserializzazione dell'oggetto TimeSpan a una stringa formattata come tipo duration XSD.

public ref class SoapDuration sealed
public sealed class SoapDuration
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class SoapDuration
type SoapDuration = class
[<System.Runtime.InteropServices.ComVisible(true)>]
type SoapDuration = class
Public NotInheritable Class SoapDuration
Ereditarietà
SoapDuration
Attributi

Esempio

Nell'esempio di codice seguente viene illustrato come utilizzare i metodi della classe per eseguire la SoapDuration conversione tra un TimeSpan oggetto e una stringa XSD duration .

#using <System.dll>
#using <System.Runtime.Remoting.dll>
using namespace System;
using namespace System::Runtime::Remoting::Metadata::W3cXsd2001;

int main()
{
   // Parse an XSD duration to create a TimeSpan object.
   // This is a duration of 2 years, 3 months, 9 days, 12 hours,
   // 35 minutes, 20 seconds, and 10 milliseconds.
   String^ xsdDuration = L"P2Y3M9DT12H35M20.0100000S";
   TimeSpan timeSpan = SoapDuration::Parse( xsdDuration );
   Console::WriteLine( L"The time span contains {0} days.",
      timeSpan.Days );
   Console::WriteLine( L"The time span contains {0} hours.",
      timeSpan.Hours );
   Console::WriteLine( L"The time span contains {0} minutes.",
      timeSpan.Minutes );
   Console::WriteLine( L"The time span contains {0} seconds.",
      timeSpan.Seconds );

   // Serialize a TimeSpan object as an XSD duration string.
   // This object represents a time span of 399 days, 12 hours,
   // 35 minutes, 20 seconds, and 10 milliseconds.
   TimeSpan duration = TimeSpan(399,12,35,20,10);
   Console::WriteLine( L"The duration in XSD format is {0}.",
      SoapDuration::ToString( duration ) );

   // Print the XSD type string of the SoapDuration class.
   Console::WriteLine( L"The XSD type of SoapDuration is {0}.",
      SoapDuration::XsdType );
}
using System;
using System.Runtime.Remoting.Metadata.W3cXsd2001;

public class Demo
{
    public static void Main(string[] args)
    {
        // Parse an XSD duration to create a TimeSpan object.
        // This is a duration of 2 years, 3 months, 9 days, 12 hours,
        // 35 minutes, 20 seconds, and 10 milliseconds.
        string xsdDuration = "P2Y3M9DT12H35M20.0100000S";
        TimeSpan timeSpan = SoapDuration.Parse(xsdDuration);
        Console.WriteLine("The time span contains {0} days.",
            timeSpan.Days);
        Console.WriteLine("The time span contains {0} hours.",
            timeSpan.Hours);
        Console.WriteLine("The time span contains {0} minutes.",
            timeSpan.Minutes);
        Console.WriteLine("The time span contains {0} seconds.",
            timeSpan.Seconds);

        // Serialize a TimeSpan object as an XSD duration string.
        // This object represents a time span of 399 days, 12 hours,
        // 35 minutes, 20 seconds, and 10 milliseconds.
        TimeSpan duration = new TimeSpan(399, 12, 35, 20, 10);
        Console.WriteLine("The duration in XSD format is {0}.",
            SoapDuration.ToString(duration));

        // Print the XSD type string of the SoapDuration class.
        Console.WriteLine("The XSD type of SoapDuration is {0}.",
            SoapDuration.XsdType);
    }
}

Commenti

Per altre informazioni sui tipi di dati XSD, vedere Informazioni di riferimento sui tipi di dati XML.

Costruttori

SoapDuration()

Crea un'istanza di SoapDuration.

Proprietà

XsdType

Ottiene il linguaggio XSD (XML Schema Definition) del tipo SOAP corrente.

Metodi

Equals(Object)

Determina se l'oggetto specificato è uguale all'oggetto corrente.

(Ereditato da Object)
GetHashCode()

Funge da funzione hash predefinita.

(Ereditato da Object)
GetType()

Ottiene l'oggetto Type dell'istanza corrente.

(Ereditato da Object)
MemberwiseClone()

Crea una copia superficiale dell'oggetto Object corrente.

(Ereditato da Object)
Parse(String)

Converte l'oggetto String specificato in un oggetto TimeSpan.

ToString()

Restituisce una stringa che rappresenta l'oggetto corrente.

(Ereditato da Object)
ToString(TimeSpan)

Restituisce l'oggetto TimeSpan specificato come String.

Si applica a