2 // Copyright (c) 2004, Rodrigo B. de Oliveira (rbo@acm.org)
3 // All rights reserved.
5 // Redistribution and use in source and binary forms, with or without modification,
6 // are permitted provided that the following conditions are met:
8 // * Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright notice,
11 // this list of conditions and the following disclaimer in the documentation
12 // and/or other materials provided with the distribution.
13 // * Neither the name of Rodrigo B. de Oliveira nor the names of its
14 // contributors may be used to endorse or promote products derived from this
15 // software without specific prior written permission.
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
21 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 using System
.Collections
.Generic
;
34 public class QuackFuMember
: IQuackFuMember
42 if (string.IsNullOrEmpty(value)) throw new ArgumentNullException("value");
46 protected string name
;
48 public QuackFuMemberKind Kind
53 protected QuackFuMemberKind kind
;
55 public Type ReturnType
57 get { return returnType; }
58 set { returnType = value; }
60 protected Type returnType
;
62 public string[] ArgumentNames
64 get { return argumentNames; }
65 set { argumentNames = value; }
67 protected string[] argumentNames
;
69 public Type
[] ArgumentTypes
71 get { return argumentTypes; }
72 set { argumentTypes = value; }
74 protected Type
[] argumentTypes
;
81 protected string info
;
83 public override string ToString()
85 System
.Text
.StringBuilder sb
= new System
.Text
.StringBuilder();
87 if (QuackFuMemberKind
.Method
== Kind
) {
89 if (null != ArgumentNames
)
91 for (int i
= 0; i
< ArgumentNames
.Length
; i
++)
93 string argName
= ArgumentNames
[i
];
94 if (i
> 0) sb
.Append(", ");
96 if (null != ArgumentTypes
&& ArgumentTypes
.Length
> i
)
98 Type argType
= ArgumentTypes
[i
];
99 AppendTypeInformation(sb
, argType
);
105 AppendTypeInformation(sb
, ReturnType
);
106 return sb
.ToString();
109 private static void AppendTypeInformation(System
.Text
.StringBuilder sb
, Type type
)
114 sb
.Append(GetBooTypeName(type
));
118 private static string GetBooTypeName(Type type
)
120 if (null == type
) throw new ArgumentNullException("type");
121 else if (type
== typeof(int)) return "int";
122 else if (type
== typeof(string)) return "string";
124 return type
.FullName
;