Compare commits
No commits in common. "bf104f717d7f3499fdb9f1f95d922be467fc9a18" and "4593ebfcac877ea41b616510d068017723e23a63" have entirely different histories.
bf104f717d
...
4593ebfcac
5 changed files with 39 additions and 31 deletions
2
cscz.sln
2
cscz.sln
|
@ -27,6 +27,6 @@ Global
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(MonoDevelopProperties) = preSolution
|
GlobalSection(MonoDevelopProperties) = preSolution
|
||||||
description = The C# Class Generator.
|
description = The C# Class Generator.
|
||||||
version = 0.5
|
version = 0.4
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|
|
@ -48,6 +48,21 @@ namespace cscz
|
||||||
|
|
||||||
public GenerationMode GenerationMode = GenerationMode.PublicVariables;
|
public GenerationMode GenerationMode = GenerationMode.PublicVariables;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether to make data members private and create public properties for them instead of making the
|
||||||
|
/// data members public.
|
||||||
|
/// This is read only. Please refer to GenerationMode in order to change this field.
|
||||||
|
/// </summary>
|
||||||
|
public bool CreateProperties
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (GenerationMode == GenerationMode.PrivateVariablesWithProperties)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ClassGenerator ()
|
public ClassGenerator ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -119,32 +134,26 @@ namespace cscz
|
||||||
|
|
||||||
constructorSignature.AppendFormat("{0} in{1}, ", datatypeName, publicDataMemberName);
|
constructorSignature.AppendFormat("{0} in{1}, ", datatypeName, publicDataMemberName);
|
||||||
|
|
||||||
switch(GenerationMode)
|
if (CreateProperties)
|
||||||
{
|
{
|
||||||
case GenerationMode.PrivateVariablesWithProperties:
|
// Private data member
|
||||||
// Private data member
|
classCode.WriteLine("\tprivate {0} {1};", datatypeName, privateDataMemberName);
|
||||||
classCode.WriteLine("\tprivate {0} {1};", datatypeName, privateDataMemberName);
|
|
||||||
|
|
||||||
// Public property associated with above private data member
|
// Public property associated with above private data member
|
||||||
properties.WriteLine("\tpublic {0} {1}", datatypeName, publicDataMemberName);
|
properties.WriteLine("\tpublic {0} {1}", datatypeName, publicDataMemberName);
|
||||||
properties.WriteLine("\t{");
|
properties.WriteLine("\t{");
|
||||||
properties.WriteLine("\t\tget {{ return {0}; }}", privateDataMemberName);
|
properties.WriteLine("\t\tget {{ return {0}; }}", privateDataMemberName);
|
||||||
properties.WriteLine("\t\tset {{ {0} = value; }}", privateDataMemberName);
|
properties.WriteLine("\t\tset {{ {0} = value; }}", privateDataMemberName);
|
||||||
properties.WriteLine("\t}");
|
properties.WriteLine("\t}");
|
||||||
|
|
||||||
// Constructor body
|
// Constructor body
|
||||||
constructorBody.WriteLine("\t\t{0} = in{0};", publicDataMemberName);
|
constructorBody.WriteLine("\t\t{0} = in{0};", publicDataMemberName);
|
||||||
break;
|
}
|
||||||
case GenerationMode.PublicAutoProperties:
|
else
|
||||||
properties.WriteLine("\tpublic {0} {1} {{ get; set; }}", datatypeName, publicDataMemberName);
|
{
|
||||||
|
// Constuctor body
|
||||||
constructorBody.WriteLine("\t\t{0} = in{0};", publicDataMemberName);
|
classCode.WriteLine("\tpublic {0} {1};", datatypeName, publicDataMemberName);
|
||||||
break;
|
constructorBody.WriteLine("\t\t{0} = in{0};", publicDataMemberName);
|
||||||
case GenerationMode.PublicVariables:
|
|
||||||
// Constuctor body
|
|
||||||
classCode.WriteLine("\tpublic {0} {1};", datatypeName, publicDataMemberName);
|
|
||||||
constructorBody.WriteLine("\t\t{0} = in{0};", publicDataMemberName);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,10 @@ Usage:
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
|
||||||
Argument Meaning
|
Argument Meaning
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
--public Generates public data members for the class fields. This is the default.
|
--public Causes the parameters of the class to be defined as public data members. This is the default.
|
||||||
--private Generates private data members with public accessors for the class fields.
|
--private Causes the parameters of the class to be defined as private data members with public accessors.
|
||||||
--public-auto Generates public auto properties for the class fields.
|
|
||||||
|
|
||||||
Note that arguments specified later always override arguments specified earlier.
|
Note that arguments specified later always override arguments specified earlier.
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ using System.Runtime.CompilerServices;
|
||||||
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
|
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
|
||||||
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
|
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
|
||||||
|
|
||||||
[assembly: AssemblyVersion("0.5.*")]
|
[assembly: AssemblyVersion("0.4.*")]
|
||||||
|
|
||||||
// The following attributes are used to specify the signing key for the assembly,
|
// The following attributes are used to specify the signing key for the assembly,
|
||||||
// if desired. See the Mono documentation for more information about signing.
|
// if desired. See the Mono documentation for more information about signing.
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<AssemblyName>cscz</AssemblyName>
|
<AssemblyName>cscz</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
<Description>The C# Class Generator.</Description>
|
<Description>The C# Class Generator.</Description>
|
||||||
<ReleaseVersion>0.5</ReleaseVersion>
|
<ReleaseVersion>0.4</ReleaseVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
|
Loading…
Reference in a new issue