2
// PersistentGenericParamater.cs: A utility class that handles serialization of
6
// Matej Urbas (matej.urbas@gmail.com)
8
// (C) 2006 Matej Urbas
11
// This source code is licenced under The MIT License:
13
// Permission is hereby granted, free of charge, to any person obtaining
14
// a copy of this software and associated documentation files (the
15
// "Software"), to deal in the Software without restriction, including
16
// without limitation the rights to use, copy, modify, merge, publish,
17
// distribute, sublicense, and/or sell copies of the Software, and to
18
// permit persons to whom the Software is furnished to do so, subject to
19
// the following conditions:
21
// The above copyright notice and this permission notice shall be
22
// included in all copies or substantial portions of the Software.
24
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35
using System.Reflection;
37
namespace MonoDevelop.Projects.Parser
39
internal sealed class PersistentGenericParamater
41
private PersistentGenericParamater()
45
public static GenericParameter Resolve(GenericParameter gp,
46
ITypeResolver typeResolver)
48
GenericParameter tmp = new GenericParameter();
50
tmp.SpecialConstraints = gp.SpecialConstraints;
51
if (gp.BaseTypes != null && gp.BaseTypes.Count > 0) {
52
tmp.BaseTypes = new ReturnTypeList();
53
foreach (IReturnType rt in gp.BaseTypes) {
54
tmp.BaseTypes.Add(PersistentReturnType.Resolve(rt, typeResolver));
61
public static GenericParameter Read (BinaryReader reader, INameDecoder nameTable)
63
GenericParameter gp = new GenericParameter();
64
gp.Name = PersistentHelper.ReadString(reader, nameTable);
65
gp.SpecialConstraints = (GenericParameterAttributes) reader.ReadInt16();
66
uint count = reader.ReadUInt32();
68
gp.BaseTypes = new ReturnTypeList();
69
for (uint j = 0; j < count; ++j) {
70
gp.BaseTypes.Add(PersistentReturnType.Read(reader, nameTable));
76
public static void WriteTo (GenericParameter gp, BinaryWriter writer, INameEncoder nameTable)
78
PersistentHelper.WriteString(gp.Name, writer, nameTable);
79
writer.Write((short)gp.SpecialConstraints);
80
if (gp.BaseTypes == null)
81
writer.Write((uint)0);
83
writer.Write((uint)gp.BaseTypes.Count);
84
foreach (IReturnType rt in gp.BaseTypes) {
85
PersistentReturnType.WriteTo(rt, writer, nameTable);