3 class ModelGenerator(NamedGeneratorBase
):
4 [Property(Fields
)] _fields
as (string
)
5 [Property(Properties
)] _properties
as (string
)
6 [Option('no-migration', 'm', "Don't generate migration")]
10 _fields
= [arg
.ToVarName() for arg
in Argv
].ToArray(string
)
11 _properties
= [arg
.ToClassName() for arg
in Argv
].ToArray(string
)
14 Process('Model.cs', "${ModelsBasePath}/${ClassName}.cs")
15 MkDir(ModelsTestsBasePath
)
16 Process('Test.cs', "${ModelsTestsBasePath}/${ClassName}Test.cs")
19 MkDir(MigrationsBasePath
)
20 migrationVersion
= string
.Format("{0:000}", Version
)
22 Process('Migration.cs', "${MigrationsBasePath}/${migrationVersion}_Add${ClassName}Table.cs")
25 return 'ModelName [Property1, Property2, ...]'
28 return 'Generates an ActiveRecord model class'
32 return ModelsNamespace
36 return ModelsTestsNamespace
40 return Framework
== "net-2.0"
48 return 1 unless Directory
.Exists("${MigrationsBasePath}")
50 for file
in Directory
.GetFiles("${MigrationsBasePath}"):
52 if info
.Name
.Substring(3, 1) == '_':
53 v
= int
.Parse(info
.Name
.Substring(0, 3))
59 return MigrationsNamespace