You've already forked linux-packaging-mono
acceptance-tests
data
docs
external
ikvm-native
libgc
llvm
m4
man
mcs
build
class
Accessibility
Commons.Xml.Relaxng
Cscompmgd
CustomMarshalers
Facades
I18N
IBM.Data.DB2
ICSharpCode.SharpZipLib
Microsoft.Build
Microsoft.Build.Engine
Microsoft.Build.Framework
Microsoft.Build.Tasks
Microsoft.Build.Utilities
Microsoft.CSharp
Microsoft.NuGet.Build.Tasks
Microsoft.VisualC
Microsoft.Web.Infrastructure
MicrosoftAjaxLibrary
Mono.Btls.Interface
Mono.C5
Mono.CSharp
Mono.Cairo
Mono.Cecil
Mono.Cecil.Mdb
Mono.CodeContracts
Mono.CompilerServices.SymbolWriter
Mono.Data.Sqlite
Mono.Data.Tds
Mono.Debugger.Soft
Mono.Http
Mono.Management
Mono.Messaging
Mono.Messaging.RabbitMQ
Mono.Options
Mono.Parallel
Mono.Posix
Mono.Profiler.Log
Mono.Runtime.Tests
Mono.Security
Mono.Security.Win32
Mono.Simd
Mono.Tasklets
Mono.WebBrowser
Mono.XBuild.Tasks
Novell.Directory.Ldap
PEAPI
RabbitMQ.Client
SMDiagnostics
System
System.ComponentModel.Composition.4.5
System.ComponentModel.DataAnnotations
System.Configuration
System.Configuration.Install
System.Core
System.Data
System.Data.DataSetExtensions
System.Data.Entity
System.Data.Linq
System.Data.OracleClient
System.Data.Services
System.Data.Services.Client
System.Deployment
System.Design
System.DirectoryServices
System.DirectoryServices.Protocols
System.Drawing
System.Drawing.Design
System.Dynamic
System.EnterpriseServices
System.IO.Compression
System.IO.Compression.FileSystem
System.IdentityModel
System.IdentityModel.Selectors
System.Json
System.Json.Microsoft
System.Management
System.Messaging
System.Net
System.Net.Http
System.Net.Http.Formatting
System.Net.Http.WebRequest
System.Net.Http.WinHttpHandler
System.Numerics
System.Numerics.Vectors
System.Reactive.Core
System.Reactive.Debugger
System.Reactive.Experimental
System.Reactive.Interfaces
System.Reactive.Linq
System.Reactive.Observable.Aliases
System.Reactive.PlatformServices
System.Reactive.Providers
System.Reactive.Runtime.Remoting
System.Reactive.Windows.Forms
System.Reactive.Windows.Threading
System.Reflection.Context
System.Runtime.Caching
System.Runtime.CompilerServices.Unsafe
System.Runtime.DurableInstancing
System.Runtime.Remoting
System.Runtime.Serialization
System.Runtime.Serialization.Formatters.Soap
System.Security
System.ServiceModel
Assembly
Documentation
Mono.CodeGeneration
CodeAdd.cs
CodeAnd.cs
CodeArgument.cs
CodeArgumentReference.cs
CodeArithmeticOperation.cs
CodeArrayItem.cs
CodeArrayLength.cs
CodeAssignment.cs
CodeBinaryComparison.cs
CodeBinaryOperation.cs
CodeBlock.cs
CodeBuilder.cs
CodeCast.cs
CodeClass.cs
CodeCustomAttribute.cs
CodeDecrement.cs
CodeEquals.cs
CodeExpression.cs
CodeFieldReference.cs
CodeFor.cs
CodeForeach.cs
CodeGenerationHelper.cs
CodeIf.cs
CodeIncrement.cs
CodeIs.cs
CodeItem.cs
CodeLiteral.cs
CodeMethod.cs
CodeMethodCall.cs
CodeModule.cs
CodeNew.cs
CodeNewArray.cs
CodeNotEquals.cs
CodeOr.cs
CodeProperty.cs
CodePropertyReference.cs
CodeReturn.cs
CodeSelect.cs
CodeSelfIncrement.cs
CodeTryBlock.cs
CodeUnaryOperation.cs
CodeValueReference.cs
CodeVariableDeclaration.cs
CodeVariableReference.cs
CodeWhen.cs
CodeWhile.cs
CodeWriter.cs
Exp.cs
Mono.Security.Protocol.Ntlm
Mono.Xml.XPath
ReferenceSources
System.ServiceModel
System.ServiceModel.Activation
System.ServiceModel.Channels
System.ServiceModel.Channels.Http
System.ServiceModel.Channels.NetTcp
System.ServiceModel.Channels.Security
System.ServiceModel.ComIntegration
System.ServiceModel.Configuration
System.ServiceModel.Description
System.ServiceModel.Diagnostics
System.ServiceModel.Dispatcher
System.ServiceModel.MsmqIntegration
System.ServiceModel.PeerResolvers
System.ServiceModel.Security
System.ServiceModel.Security.Tokens
Test
corefx
resources
Dummy_2_1.cs
Dummy_XM_4_5.cs
Makefile
System.ServiceModel.dll.sources
System.ServiceModel_test.dll.sources
mobile_System.ServiceModel.dll.sources
monodroid_System.ServiceModel.dll.sources
monodroid_System.ServiceModel_test.dll.exclude.sources
monotouch_System.ServiceModel.dll.sources
monotouch_tv_System.ServiceModel.dll.sources
monotouch_watch_System.ServiceModel.dll.sources
orbis_System.ServiceModel.dll.sources
testing_aot_full_System.ServiceModel.dll.exclude.sources
testing_aot_full_System.ServiceModel.dll.sources
testing_aot_full_System.ServiceModel_test.dll.exclude.sources
testing_aot_full_System.ServiceModel_test.dll.sources
testing_aot_full_interp_System.ServiceModel.dll.exclude.sources
testing_aot_full_interp_System.ServiceModel.dll.sources
testing_aot_hybrid_System.ServiceModel.dll.exclude.sources
testing_aot_hybrid_System.ServiceModel.dll.sources
testing_aot_hybrid_System.ServiceModel_test.dll.exclude.sources
testing_winaot_interp_System.ServiceModel.dll.exclude.sources
testing_winaot_interp_System.ServiceModel.dll.sources
unreal_System.ServiceModel.dll.sources
wasm_System.ServiceModel.dll.exclude.sources
wasm_System.ServiceModel.dll.sources
win32_monodroid_System.ServiceModel_test.dll.exclude.sources
winaot_System.ServiceModel.dll.sources
xammac_System.ServiceModel.dll.sources
xammac_net_4_5_System.ServiceModel.dll.sources
System.ServiceModel.Activation
System.ServiceModel.Discovery
System.ServiceModel.Internals
System.ServiceModel.Routing
System.ServiceModel.Web
System.ServiceProcess
System.Threading.Tasks.Dataflow
System.Transactions
System.Web
System.Web.Abstractions
System.Web.ApplicationServices
System.Web.DynamicData
System.Web.Extensions
System.Web.Extensions.Design
System.Web.Http
System.Web.Http.SelfHost
System.Web.Http.WebHost
System.Web.Mobile
System.Web.Mvc3
System.Web.Razor
System.Web.RegularExpressions
System.Web.Routing
System.Web.Services
System.Web.WebPages
System.Web.WebPages.Deployment
System.Web.WebPages.Razor
System.Windows
System.Windows.Forms
System.Windows.Forms.DataVisualization
System.Workflow.Activities
System.Workflow.ComponentModel
System.Workflow.Runtime
System.XML
System.Xaml
System.Xml.Linq
System.Xml.Serialization
SystemWebTestShim
WebMatrix.Data
WindowsBase
aot-compiler
corlib
dlr
doc
legacy
lib
monodoc
notes
reference-assemblies
referencesource
test-helpers
LICENSE
Makefile
Open.snk
README
ecma.pub
mono.pub
mono.snk
msfinal.pub
reactive.pub
silverlight.pub
winfx.pub
winfx3.pub
docs
errors
ilasm
jay
mcs
packages
tests
tools
AUTHORS
COPYING
INSTALL.txt
Makefile
MonoIcon.png
README
ScalableMonoIcon.svg
mkinstalldirs
mk
mono
msvc
netcore
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
351 lines
11 KiB
C#
351 lines
11 KiB
C#
![]() |
//
|
||
|
// Permission is hereby granted, free of charge, to any person obtaining
|
||
|
// a copy of this software and associated documentation files (the
|
||
|
// "Software"), to deal in the Software without restriction, including
|
||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||
|
// distribute, sublicense, and/or sell copies of the Software, and to
|
||
|
// permit persons to whom the Software is furnished to do so, subject to
|
||
|
// the following conditions:
|
||
|
//
|
||
|
// The above copyright notice and this permission notice shall be
|
||
|
// included in all copies or substantial portions of the Software.
|
||
|
//
|
||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||
|
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||
|
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||
|
//
|
||
|
// Copyright (C) Lluis Sanchez Gual, 2004
|
||
|
//
|
||
|
|
||
|
#if !FULL_AOT_RUNTIME
|
||
|
using System;
|
||
|
using System.IO;
|
||
|
using System.Collections;
|
||
|
using System.Reflection;
|
||
|
using System.Reflection.Emit;
|
||
|
|
||
|
namespace Mono.CodeGeneration
|
||
|
{
|
||
|
public class CodeClass
|
||
|
{
|
||
|
TypeBuilder typeBuilder;
|
||
|
ArrayList customAttributes = new ArrayList ();
|
||
|
ArrayList methods = new ArrayList ();
|
||
|
ArrayList properties = new ArrayList ();
|
||
|
ArrayList fields = new ArrayList ();
|
||
|
Hashtable fieldAttributes = new Hashtable ();
|
||
|
Type baseType;
|
||
|
Type[] interfaces;
|
||
|
CodeMethod ctor;
|
||
|
CodeMethod cctor;
|
||
|
CodeBuilder instanceInit;
|
||
|
CodeBuilder classInit;
|
||
|
int varId;
|
||
|
|
||
|
public CodeClass (ModuleBuilder mb, string name)
|
||
|
: this (mb, name, TypeAttributes.Public, typeof(object))
|
||
|
{
|
||
|
}
|
||
|
|
||
|
public CodeClass (ModuleBuilder mb, string name, Type baseType, params Type[] interfaces)
|
||
|
: this (mb, name, TypeAttributes.Public, baseType, interfaces)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
public CodeClass (ModuleBuilder mb, string name, TypeAttributes attr, Type baseType, params Type[] interfaces)
|
||
|
{
|
||
|
typeBuilder = mb.DefineType (name, attr, baseType, interfaces);
|
||
|
this.baseType = baseType;
|
||
|
this.interfaces = interfaces;
|
||
|
}
|
||
|
|
||
|
public CodeCustomAttribute CreateCustomAttribute (Type attributeType)
|
||
|
{
|
||
|
return CreateCustomAttribute (attributeType,
|
||
|
Type.EmptyTypes, new object [0], new string [0], new object [0]);
|
||
|
}
|
||
|
|
||
|
public CodeCustomAttribute CreateCustomAttribute (Type attributeType, Type [] ctorArgTypes, object [] ctorArgs, string [] namedArgFieldNames, object [] namedArgValues)
|
||
|
{
|
||
|
CodeCustomAttribute cca = CodeCustomAttribute.Create (
|
||
|
attributeType, ctorArgTypes, ctorArgs, namedArgFieldNames, namedArgValues);
|
||
|
|
||
|
typeBuilder.SetCustomAttribute (cca.Builder);
|
||
|
customAttributes.Add (cca);
|
||
|
return cca;
|
||
|
}
|
||
|
|
||
|
public CodeCustomAttribute CreateCustomAttribute (Type attributeType, Type [] ctorArgTypes, CodeLiteral [] ctorArgs, FieldInfo [] fields, CodeLiteral [] fieldValues)
|
||
|
{
|
||
|
CodeCustomAttribute cca = CodeCustomAttribute.Create (
|
||
|
attributeType, ctorArgTypes, ctorArgs, fields, fieldValues);
|
||
|
|
||
|
typeBuilder.SetCustomAttribute (cca.Builder);
|
||
|
customAttributes.Add (cca);
|
||
|
return cca;
|
||
|
}
|
||
|
|
||
|
public CodeProperty CreateProperty (string name, Type returnType, params Type [] parameterTypes)
|
||
|
{
|
||
|
return CreateProperty (name, returnType, MethodAttributes.Private, parameterTypes);
|
||
|
}
|
||
|
|
||
|
public CodeProperty CreateProperty (string name, Type returnType, MethodAttributes methodAttributes, params Type [] parameterTypes)
|
||
|
{
|
||
|
CodeProperty prop = new CodeProperty (this, GetPropertyName (name), PropertyAttributes.None, methodAttributes, returnType, parameterTypes);
|
||
|
properties.Add (prop);
|
||
|
return prop;
|
||
|
}
|
||
|
|
||
|
public CodeMethod CreateMethod (string name, Type returnType, params Type[] parameterTypes)
|
||
|
{
|
||
|
CodeMethod met = new CodeMethod (this, GetMethodName (name), MethodAttributes.Public, returnType, parameterTypes);
|
||
|
methods.Add (met);
|
||
|
return met;
|
||
|
}
|
||
|
|
||
|
public CodeMethod CreateVirtualMethod (string name, Type returnType, params Type[] parameterTypes)
|
||
|
{
|
||
|
CodeMethod met = new CodeMethod (this, GetMethodName (name), MethodAttributes.Public | MethodAttributes.Virtual, returnType, parameterTypes);
|
||
|
methods.Add (met);
|
||
|
return met;
|
||
|
}
|
||
|
|
||
|
public CodeMethod CreateStaticMethod (string name, Type returnType, params Type[] parameterTypes)
|
||
|
{
|
||
|
CodeMethod met = new CodeMethod (this, GetMethodName (name), MethodAttributes.Public | MethodAttributes.Static, returnType, parameterTypes);
|
||
|
methods.Add (met);
|
||
|
return met;
|
||
|
}
|
||
|
|
||
|
public CodeMethod CreateMethod (string name, MethodAttributes attributes, Type returnType, params Type[] parameterTypes)
|
||
|
{
|
||
|
CodeMethod met = new CodeMethod (this, GetMethodName (name), attributes, returnType, parameterTypes);
|
||
|
methods.Add (met);
|
||
|
return met;
|
||
|
}
|
||
|
|
||
|
public CodeMethod GetDefaultConstructor ()
|
||
|
{
|
||
|
if (ctor != null) return ctor;
|
||
|
ctor = CreateConstructor (MethodAttributes.Public, Type.EmptyTypes);
|
||
|
return ctor;
|
||
|
}
|
||
|
|
||
|
public CodeMethod CreateConstructor (params Type[] parameters)
|
||
|
{
|
||
|
return CreateConstructor (MethodAttributes.Private, parameters);
|
||
|
}
|
||
|
|
||
|
public CodeMethod CreateConstructor (MethodAttributes attributes, params Type[] parameters)
|
||
|
{
|
||
|
if (ctor != null) return ctor;
|
||
|
ctor = CodeMethod.DefineConstructor (this, attributes, parameters);
|
||
|
methods.Add (ctor);
|
||
|
CodeBuilder cb = GetInstanceInitBuilder ();
|
||
|
ctor.CodeBuilder.CurrentBlock.Add (cb.CurrentBlock);
|
||
|
return ctor;
|
||
|
}
|
||
|
|
||
|
public CodeMethod GetStaticConstructor ()
|
||
|
{
|
||
|
if (cctor != null) return cctor;
|
||
|
cctor = CodeMethod.DefineConstructor (this, MethodAttributes.Public | MethodAttributes.Static, Type.EmptyTypes);
|
||
|
methods.Add (cctor);
|
||
|
CodeBuilder cb = GetClassInitBuilder ();
|
||
|
cctor.CodeBuilder.CurrentBlock.Add (cb.CurrentBlock);
|
||
|
return cctor;
|
||
|
}
|
||
|
|
||
|
public CodeMethod ImplementMethod (Type baseType, string methodName)
|
||
|
{
|
||
|
MethodInfo basem = baseType.GetMethod (methodName);
|
||
|
return ImplementMethod (baseType, basem);
|
||
|
}
|
||
|
|
||
|
public CodeMethod ImplementMethod (MethodInfo basem)
|
||
|
{
|
||
|
return ImplementMethod (basem.DeclaringType, basem);
|
||
|
}
|
||
|
|
||
|
public CodeMethod ImplementMethod (Type baseType, MethodInfo basem)
|
||
|
{
|
||
|
ParameterInfo[] pinfos = basem.GetParameters ();
|
||
|
Type[] pars = new Type[pinfos.Length];
|
||
|
for (int n=0; n<pinfos.Length; n++)
|
||
|
pars[n] = pinfos[n].ParameterType;
|
||
|
|
||
|
CodeMethod met = CodeMethod.DefineMethod (this, basem.Name, MethodAttributes.Public | MethodAttributes.Virtual, basem.ReturnType, pars);
|
||
|
typeBuilder.DefineMethodOverride (met.MethodInfo, basem);
|
||
|
methods.Add (met);
|
||
|
return met;
|
||
|
}
|
||
|
|
||
|
public CodeFieldReference DefineField (string name, Type type, params CodeCustomAttribute [] customAttributes)
|
||
|
{
|
||
|
return DefineField (GetFieldName (name), type, FieldAttributes.Public, null, customAttributes);
|
||
|
}
|
||
|
|
||
|
public CodeFieldReference DefineStaticField (CodeExpression initialValue, params CodeCustomAttribute [] customAttributes)
|
||
|
{
|
||
|
return DefineField (GetFieldName (null), initialValue.GetResultType(), FieldAttributes.Public | FieldAttributes.Static, initialValue, customAttributes);
|
||
|
}
|
||
|
|
||
|
public CodeFieldReference DefineStaticField (string name, Type type, CodeExpression initialValue, params CodeCustomAttribute [] customAttributes)
|
||
|
{
|
||
|
return DefineField (GetFieldName (name), type, FieldAttributes.Public | FieldAttributes.Static, initialValue, customAttributes);
|
||
|
}
|
||
|
|
||
|
public CodeFieldReference DefineField (string name, Type type, FieldAttributes attrs, CodeExpression initialValue, params CodeCustomAttribute [] customAttributes)
|
||
|
{
|
||
|
FieldBuilder fb = typeBuilder.DefineField (GetFieldName (name), type, attrs);
|
||
|
foreach (CodeCustomAttribute a in customAttributes)
|
||
|
fb.SetCustomAttribute (a.Builder);
|
||
|
fieldAttributes [fb] = new ArrayList (customAttributes);
|
||
|
fields.Add (fb);
|
||
|
CodeFieldReference fr;
|
||
|
if ((attrs & FieldAttributes.Static) != 0)
|
||
|
fr = new CodeFieldReference (fb);
|
||
|
else
|
||
|
fr = new CodeFieldReference (new CodeArgumentReference (TypeBuilder, 0, "this"), fb);
|
||
|
|
||
|
if (null != (object) initialValue) {
|
||
|
CodeBuilder cb = (attrs & FieldAttributes.Static) == 0 ? GetInstanceInitBuilder () : GetClassInitBuilder ();
|
||
|
cb.Assign (fr, initialValue);
|
||
|
}
|
||
|
return fr;
|
||
|
}
|
||
|
|
||
|
public TypeBuilder TypeBuilder
|
||
|
{
|
||
|
get { return typeBuilder; }
|
||
|
}
|
||
|
|
||
|
private CodeBuilder GetInstanceInitBuilder ()
|
||
|
{
|
||
|
if (instanceInit != null) return instanceInit;
|
||
|
instanceInit = new CodeBuilder (this);
|
||
|
return instanceInit;
|
||
|
}
|
||
|
|
||
|
private CodeBuilder GetClassInitBuilder ()
|
||
|
{
|
||
|
if (classInit != null) return classInit;
|
||
|
classInit = new CodeBuilder (this);
|
||
|
return classInit;
|
||
|
}
|
||
|
|
||
|
private string GetFieldName (string name)
|
||
|
{
|
||
|
if (name == null) return "__field_" + (varId++);
|
||
|
else return name;
|
||
|
}
|
||
|
|
||
|
private string GetMethodName (string name)
|
||
|
{
|
||
|
if (name == null) return "__Method_" + (varId++);
|
||
|
else return name;
|
||
|
}
|
||
|
|
||
|
private string GetPropertyName (string name)
|
||
|
{
|
||
|
if (name == null) return "__Property_" + (varId++);
|
||
|
else return name;
|
||
|
}
|
||
|
|
||
|
public string PrintCode ()
|
||
|
{
|
||
|
StringWriter sw = new StringWriter ();
|
||
|
CodeWriter cw = new CodeWriter (sw);
|
||
|
PrintCode (cw);
|
||
|
return sw.ToString ();
|
||
|
}
|
||
|
|
||
|
public void PrintCode (CodeWriter cw)
|
||
|
{
|
||
|
for (int n=0; n<customAttributes.Count; n++) {
|
||
|
CodeCustomAttribute cca = customAttributes [n] as CodeCustomAttribute;
|
||
|
if (n > 0) cw.WriteLine ("");
|
||
|
cca.PrintCode (cw);
|
||
|
}
|
||
|
|
||
|
/* if ((typeBuilder.Attributes & TypeAttributes.Abstract) != 0) cw.Write ("abstract ");
|
||
|
if ((typeBuilder.Attributes & TypeAttributes.NestedAssembly) != 0) cw.Write ("internal ");
|
||
|
if ((typeBuilder.Attributes & TypeAttributes.NestedPrivate) != 0) cw.Write ("private ");
|
||
|
*/ if ((typeBuilder.Attributes & TypeAttributes.Public) != 0) cw.Write ("public ");
|
||
|
cw.Write ("class ").Write (typeBuilder.Name);
|
||
|
|
||
|
bool dots = false;
|
||
|
if (baseType != null && baseType != typeof(object)) {
|
||
|
cw.Write (" : " + baseType);
|
||
|
dots = true;
|
||
|
}
|
||
|
|
||
|
if (interfaces != null && interfaces.Length > 0) {
|
||
|
if (!dots) cw.Write (" : ");
|
||
|
else cw.Write (", ");
|
||
|
for (int n=0; n<interfaces.Length; n++) {
|
||
|
if (n > 0) cw.Write (", ");
|
||
|
cw.Write (interfaces[n].ToString ());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
cw.EndLine ().WriteLineInd ("{");
|
||
|
|
||
|
foreach (FieldInfo f in fields) {
|
||
|
cw.BeginLine ();
|
||
|
ArrayList atts = (ArrayList) fieldAttributes [f];
|
||
|
foreach (CodeCustomAttribute a in atts)
|
||
|
a.PrintCode (cw);
|
||
|
if ((f.Attributes & FieldAttributes.Static) != 0)
|
||
|
cw.Write ("static ");
|
||
|
cw.Write (f.FieldType.Name + " ");
|
||
|
cw.Write (f.Name + ";");
|
||
|
cw.EndLine ();
|
||
|
cw.WriteLine ("");
|
||
|
}
|
||
|
|
||
|
for (int n=0; n<properties.Count; n++) {
|
||
|
CodeProperty prop = properties [n] as CodeProperty;
|
||
|
if (n > 0) cw.WriteLine ("");
|
||
|
prop.PrintCode (cw);
|
||
|
}
|
||
|
|
||
|
for (int n=0; n<methods.Count; n++) {
|
||
|
CodeMethod met = methods[n] as CodeMethod;
|
||
|
if (n > 0) cw.WriteLine ("");
|
||
|
met.PrintCode (cw);
|
||
|
}
|
||
|
cw.WriteLineUnind ("}");
|
||
|
}
|
||
|
|
||
|
public Type CreateType ()
|
||
|
{
|
||
|
if (ctor == null)
|
||
|
ctor = GetDefaultConstructor ();
|
||
|
|
||
|
foreach (CodeProperty prop in properties)
|
||
|
prop.Generate ();
|
||
|
|
||
|
foreach (CodeMethod met in methods)
|
||
|
met.Generate ();
|
||
|
|
||
|
Type t = typeBuilder.CreateType ();
|
||
|
|
||
|
foreach (CodeMethod met in methods)
|
||
|
met.UpdateMethodBase (t);
|
||
|
|
||
|
foreach (CodeProperty prop in properties)
|
||
|
prop.UpdatePropertyInfo (t);
|
||
|
|
||
|
return t;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endif
|