~ubuntu-branches/ubuntu/trusty/pdfmod/trusty

« back to all changes in this revision

Viewing changes to lib/PdfSharp/PdfSharp.Pdf/PdfInteger.cs

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2010-06-18 03:44:46 UTC
  • Revision ID: james.westby@ubuntu.com-20100618034446-bogifrsscpayp361
Tags: upstream-0.8.3
ImportĀ upstreamĀ versionĀ 0.8.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#region PDFsharp - A .NET library for processing PDF
 
2
//
 
3
// Authors:
 
4
//   Stefan Lange (mailto:Stefan.Lange@pdfsharp.com)
 
5
//
 
6
// Copyright (c) 2005-2008 empira Software GmbH, Cologne (Germany)
 
7
//
 
8
// http://www.pdfsharp.com
 
9
// http://sourceforge.net/projects/pdfsharp
 
10
//
 
11
// Permission is hereby granted, free of charge, to any person obtaining a
 
12
// copy of this software and associated documentation files (the "Software"),
 
13
// to deal in the Software without restriction, including without limitation
 
14
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
 
15
// and/or sell copies of the Software, and to permit persons to whom the
 
16
// Software is furnished to do so, subject to the following conditions:
 
17
//
 
18
// The above copyright notice and this permission notice shall be included
 
19
// in all copies or substantial portions of the Software.
 
20
//
 
21
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
22
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
23
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 
24
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
25
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 
26
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
 
27
// DEALINGS IN THE SOFTWARE.
 
28
#endregion
 
29
 
 
30
using System;
 
31
using System.Diagnostics;
 
32
using System.Globalization;
 
33
using System.Collections;
 
34
using System.Text;
 
35
using System.IO;
 
36
using PdfSharp.Internal;
 
37
using PdfSharp.Pdf.IO;
 
38
 
 
39
namespace PdfSharp.Pdf
 
40
{
 
41
  /// <summary>
 
42
  /// Represents a direct integer value.
 
43
  /// </summary>
 
44
  [DebuggerDisplay("({Value})")]
 
45
  public sealed class PdfInteger : PdfNumber, IConvertible
 
46
  {
 
47
    /// <summary>
 
48
    /// Initializes a new instance of the <see cref="PdfInteger"/> class.
 
49
    /// </summary>
 
50
    public PdfInteger()
 
51
    { }
 
52
 
 
53
    /// <summary>
 
54
    /// Initializes a new instance of the <see cref="PdfInteger"/> class.
 
55
    /// </summary>
 
56
    /// <param name="value">The value.</param>
 
57
    public PdfInteger(int value)
 
58
    {
 
59
      this.value = value;
 
60
    }
 
61
 
 
62
    /// <summary>
 
63
    /// Gets the value as integer
 
64
    /// </summary>
 
65
    public int Value
 
66
    {
 
67
      // This class must behave like a value type. Therefore it cannot be changed (like System.String).
 
68
      get { return this.value; }
 
69
    }
 
70
    int value;
 
71
 
 
72
    /// <summary>
 
73
    /// Returns the integer as string.
 
74
    /// </summary>
 
75
    public override string ToString()
 
76
    {
 
77
      return this.value.ToString();
 
78
    }
 
79
 
 
80
    /// <summary>
 
81
    /// Writes the integer as string.
 
82
    /// </summary>
 
83
    internal override void WriteObject(PdfWriter writer)
 
84
    {
 
85
      writer.Write(this);
 
86
    }
 
87
 
 
88
    #region IConvertible Members
 
89
 
 
90
    ulong IConvertible.ToUInt64(IFormatProvider provider)
 
91
    {
 
92
      return Convert.ToUInt64(this.value);
 
93
    }
 
94
 
 
95
    sbyte IConvertible.ToSByte(IFormatProvider provider)
 
96
    {
 
97
      throw new InvalidCastException();
 
98
    }
 
99
 
 
100
    double IConvertible.ToDouble(IFormatProvider provider)
 
101
    {
 
102
      return value;
 
103
    }
 
104
 
 
105
    DateTime IConvertible.ToDateTime(IFormatProvider provider)
 
106
    {
 
107
      // TODO:  Add PdfInteger.ToDateTime implementation
 
108
      return new DateTime();
 
109
    }
 
110
 
 
111
    float IConvertible.ToSingle(IFormatProvider provider)
 
112
    {
 
113
      return value;
 
114
    }
 
115
 
 
116
    bool IConvertible.ToBoolean(IFormatProvider provider)
 
117
    {
 
118
      return Convert.ToBoolean(this.value);
 
119
    }
 
120
 
 
121
    int IConvertible.ToInt32(IFormatProvider provider)
 
122
    {
 
123
      return value;
 
124
    }
 
125
 
 
126
    ushort IConvertible.ToUInt16(IFormatProvider provider)
 
127
    {
 
128
      return Convert.ToUInt16(this.value);
 
129
    }
 
130
 
 
131
    short IConvertible.ToInt16(IFormatProvider provider)
 
132
    {
 
133
      return Convert.ToInt16(this.value);
 
134
    }
 
135
 
 
136
    string IConvertible.ToString(IFormatProvider provider)
 
137
    {
 
138
      return value.ToString(provider);
 
139
    }
 
140
 
 
141
    byte IConvertible.ToByte(IFormatProvider provider)
 
142
    {
 
143
      return Convert.ToByte(this.value);
 
144
    }
 
145
 
 
146
    char IConvertible.ToChar(IFormatProvider provider)
 
147
    {
 
148
      return Convert.ToChar(this.value);
 
149
    }
 
150
 
 
151
    long IConvertible.ToInt64(IFormatProvider provider)
 
152
    {
 
153
      return value;
 
154
    }
 
155
 
 
156
    /// <summary>
 
157
    /// Returns TypeCode for 32-bit integers.
 
158
    /// </summary>
 
159
    public TypeCode GetTypeCode()
 
160
    {
 
161
      return TypeCode.Int32;
 
162
    }
 
163
 
 
164
    decimal IConvertible.ToDecimal(IFormatProvider provider)
 
165
    {
 
166
      return value;
 
167
    }
 
168
 
 
169
    object IConvertible.ToType(Type conversionType, IFormatProvider provider)
 
170
    {
 
171
      // TODO:  Add PdfInteger.ToType implementation
 
172
      return null;
 
173
    }
 
174
 
 
175
    uint IConvertible.ToUInt32(IFormatProvider provider)
 
176
    {
 
177
      return Convert.ToUInt32(this.value);
 
178
    }
 
179
 
 
180
    #endregion
 
181
  }
 
182
}
 
 
b'\\ No newline at end of file'