Willkommen bei dotnet-snippets.de! Snippet hinzufügen Login Registrieren
Snippets in der Datenbank: 1563 | Anzahl registrierter User: 1895 | Besucher online: 165
Hauptmenü
Home
Top Ten
Zufälliger Snippet
FAQs
.NET Community
dotnet-forum.de
dotnet-kicks.de
Social

RSS Feeds
Rss Alle Snippets
Rss C#
Rss VB.NET
Rss C++
Rss ASP.NET
Partner
Member of Microsoft Community Leader/Insider Program (CLIP)

Serializable TimeSpan


Autor: Gast
Sprache: C#
Bewertung:
noch nicht bewertet
Anzahl der Aufrufe: 6341
  
Kick it on dotnet-kicks.de  

Beschreibung:

Da TimeSpan nicht so einfach serialisierbar zu sein scheint, hab ich da mal was gebastelt.

inspiriert von http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework/topic18670.aspx


Abgelegt unter: Serializable, TimeSpan, Serialisierung, Serialize.



C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 [Serializable]
    public class SerializableTimeSpan
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="SerializableTimeSpan"/> class.
        /// </summary>
        public SerializableTimeSpan() { }

        /// <summary>
        /// Initializes a new instance of the <see cref="SerializableTimeSpan"/> class.
        /// </summary>
        /// <param name="dauer">The original timeSpan.</param>
        public SerializableTimeSpan(TimeSpan dauer)
        {
            this.Duration = dauer;
        }

        private TimeSpan duration;

        /// <summary>
        /// Gets or sets the duration.
        /// </summary>
        /// <value>The duration.</value>
        /// <remarks>Das echte Property</remarks>
        [XmlIgnore]
        public TimeSpan Duration
        {
            get { return duration; }
            set { duration = value; }
        }

        /// <summary>
        /// Gets or sets the duration of the XML.
        /// </summary>
        /// <value>The duration of the XML.</value>
        /// <remarks>Property für XML</remarks>
        [XmlElement("Duration")]
        public string XmlDuration
        {
            get { return Duration.ToString(); }
            set { Duration = TimeSpan.Parse(value); }
        }
    }
Sie haben Fragen zu diesem Snippet oder brauchen Hilfe bei der .NET Entwicklung?
Freundliche und kompetente Entwickler helfen Ihnen gern weiter im Forum für .NET Entwicklung.



Kommentare:
(Zum Schreiben von Kommentaren bitte anmelden.)



schlecht sehr gut
1 2 3 4 5 6 7 8 9 10
Nur angemeldete User können Snippets bewerten.