(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / Novell.Directory.Ldap / Novell.Directory.Ldap.Asn1 / Asn1Object.cs
blob323f95ccefe1c2d9f0e720f6d907b85edef51537
1 /******************************************************************************
2 * The MIT License
3 * Copyright (c) 2003 Novell Inc. www.novell.com
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the Software), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 *******************************************************************************/
24 // Novell.Directory.Ldap.Asn1.Asn1Object.cs
26 // Author:
27 // Sunil Kumar (Sunilk@novell.com)
29 // (C) 2003 Novell, Inc (http://www.novell.com)
32 using System;
34 namespace Novell.Directory.Ldap.Asn1
37 /// <summary> This is the base class for all other Asn1 types.</summary>
38 [CLSCompliantAttribute(true)]
39 [Serializable]
40 public abstract class Asn1Object : System.Runtime.Serialization.ISerializable
43 private Asn1Identifier id;
45 public Asn1Object(Asn1Identifier id)
47 this.id = id;
48 return ;
51 public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
55 /// <summary> Abstract method that must be implemented by each child
56 /// class to encode itself ( an Asn1Object) directly intto
57 /// a output stream.
58 ///
59 /// </summary>
60 /// <param name="out">The output stream onto which the encoded
61 /// Asn1Object will be placed.
62 /// </param>
63 abstract public void encode(Asn1Encoder enc, System.IO.Stream out_Renamed);
65 /// <summary> Returns the identifier for this Asn1Object as an Asn1Identifier.
66 /// This Asn1Identifier object will include the CLASS, FORM and TAG
67 /// for this Asn1Object.
68 /// </summary>
69 public virtual Asn1Identifier getIdentifier()
71 return id;
74 /// <summary> Sets the identifier for this Asn1Object. This is helpful when
75 /// creating implicit Asn1Tagged types.
76 ///
77 /// </summary>
78 /// <param name="id">An Asn1Identifier object representing the CLASS,
79 /// FORM and TAG)
80 /// </param>
81 public virtual void setIdentifier(Asn1Identifier id)
83 this.id = id;
84 return ;
87 /// <summary> This method returns a byte array representing the encoded
88 /// Asn1Object. It in turn calls the encode method that is
89 /// defined in Asn1Object but will usually be implemented
90 /// in the child Asn1 classses.
91 /// </summary>
92 [CLSCompliantAttribute(false)]
93 public sbyte[] getEncoding(Asn1Encoder enc)
95 System.IO.MemoryStream out_Renamed = new System.IO.MemoryStream();
96 try
98 encode(enc, out_Renamed);
100 catch (System.IO.IOException e)
102 // Should never happen - the current Asn1Object does not have
103 // a encode method.
104 throw new System.SystemException("IOException while encoding to byte array: " + e.ToString());
106 return SupportClass.ToSByteArray(out_Renamed.ToArray());
109 /// <summary> Return a String representation of this Asn1Object.</summary>
110 [CLSCompliantAttribute(false)]
111 public override System.String ToString()
113 System.String[] classTypes = new System.String[]{"[UNIVERSAL ", "[APPLICATION ", "[", "[PRIVATE "};
115 System.Text.StringBuilder sb = new System.Text.StringBuilder();
116 Asn1Identifier id = getIdentifier(); // could be overridden.
118 sb.Append(classTypes[id.Asn1Class]).Append(id.Tag).Append("] ");
120 return sb.ToString();