Fixing an issue with output parameters that are of type IntPtr
[castle.git] / Experiments / Attic / Generator / Castle.ActiveRecord.Generator.Components / Project.cs
blobd5e41e7155f73d51234e59ce21c68259947415e5
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.ActiveRecord.Generator.Components
17 using System;
18 using System.Collections;
20 using Castle.ActiveRecord.Generator.Components.Database;
21 using Castle.ActiveRecord.Generator.Components.CodeGenerator;
24 [Serializable]
25 public class Project
27 private String _name;
28 private IList _databases = new ArrayList();
29 private IList _descriptors = new ArrayList();
30 private IDictionary _dbDef2ArBase = new Hashtable();
31 private String _Namespace;
32 private String _LastOutDir;
33 private bool _OverwriteFiles;
34 private CodeProviderInfo _info;
36 public Project(String name)
38 _name = name;
41 public Project() : this("not named yet")
45 public String Name
47 get { return _name; }
48 set { _name = value; }
51 public void AddActiveRecordDescriptor( IActiveRecordDescriptor descriptor )
53 if (descriptor == null) throw new ArgumentNullException("descriptor");
54 if (_descriptors.Contains(descriptor)) throw new ArgumentException("Already exists");
56 _descriptors.Add(descriptor);
59 public void AddDatabaseDefinition(DatabaseDefinition dbDef)
61 if (dbDef == null) throw new ArgumentNullException("dbDef");
63 ActiveRecordBaseDescriptor baseDesc;
65 if (_dbDef2ArBase.Count == 0)
67 baseDesc = new ActiveRecordBaseDescriptor("ActiveRecordBase");
69 else
71 String name = dbDef.Alias.Replace(" ","") + "Base";
72 baseDesc = new ActiveRecordBaseDescriptor(name);
75 dbDef.ActiveRecordBaseDescriptor = baseDesc;
76 AddActiveRecordDescriptor(baseDesc);
78 _databases.Add(dbDef);
80 // Just an optimization for later
81 _dbDef2ArBase[dbDef] = baseDesc;
84 public IList Databases
86 get { return ArrayList.ReadOnly(_databases); }
89 public IList Descriptors
91 get { return ArrayList.ReadOnly(_descriptors); }
94 public IDictionary BaseClasses
96 get { return _dbDef2ArBase; }
99 public String Namespace
101 get { return _Namespace; }
102 set { _Namespace = value; }
105 public String LastOutDir
107 get { return _LastOutDir; }
108 set { _LastOutDir = value; }
111 public bool OverwriteFiles
113 get { return _OverwriteFiles; }
114 set { _OverwriteFiles = value; }
117 public CodeProviderInfo CodeInfo
119 get { return _info; }
120 set { _info = value; }
123 public bool RemoveDescriptor(IActiveRecordDescriptor descriptor)
125 if (descriptor is ActiveRecordDescriptorSubClass ||
126 descriptor is ActiveRecordDescriptorJoinedSubClass)
128 _descriptors.Remove(descriptor);
130 return true;
133 return false;