Added moar comments and fixed #4.

This commit is contained in:
Starbeamrainbowlabs 2016-07-25 19:22:22 +01:00
parent 6418f52bf8
commit 1fe1b54174

View file

@ -96,47 +96,56 @@ namespace cscz
public override string ToString()
{
StringBuilder result = new StringBuilder();
// Using statements
foreach(string usingStatement in UsingStatements)
result.AppendLine(string.Format("using {0};", expandUsingShortcut(usingStatement)));
result.AppendLine();
// Class name
result.AppendLine(string.Format("class {0} ", ClassName));
result.AppendLine("{");
// Class body parts declaration
StringBuilder properties = new StringBuilder();
StringBuilder constructorSignature = new StringBuilder(string.Format("\tpublic {0}(", ClassName));
StringBuilder constructorBody = new StringBuilder();
// Data member signature handling
foreach (string signature in Signatures)
{
string[] parts = Regex.Split(signature, @"\s+");
string datatypeName = parts[0];
string privateDataMemberName = LowercaseFirstLetter(parts[1]);
string publicDataMemberName = UppercaseFirstLetter(parts[1]);
string[] signatureParts = Regex.Split(signature, @"\s+");
string datatypeName = signatureParts[0];
string privateDataMemberName = LowercaseFirstLetter(signatureParts[1]);
string publicDataMemberName = UppercaseFirstLetter(signatureParts[1]);
constructorSignature.AppendFormat("{0} in{1}, ", datatypeName, publicDataMemberName);
if (CreateProperties)
{
// Private data member
result.AppendLine(string.Format("\tprivate {0} {1};", datatypeName, privateDataMemberName));
// Public property associated with above private data member
properties.AppendLine(string.Format("\tpublic {0} {1}", datatypeName, publicDataMemberName));
properties.AppendLine(string.Format("\t{{"));
properties.AppendLine(string.Format("\t\tget {{ return {0}; }}", privateDataMemberName));
properties.AppendLine(string.Format("\t\tset {{ {0} = value; }}", privateDataMemberName));
properties.AppendLine(string.Format("\t}}"));
// Constructor body
constructorBody.AppendLine(string.Format("\t\t{0} = in{0};", publicDataMemberName));
}
else
{
// Constuctor body
result.AppendLine(string.Format("\tpublic {0} {1};", datatypeName, publicDataMemberName));
constructorBody.AppendLine(string.Format("\t\t{0} = in{1};", privateDataMemberName, publicDataMemberName));
constructorBody.AppendLine(string.Format("\t\t{0} = in{0};", publicDataMemberName));
}
}
// Add the properties to the output
result.AppendLine("\t");
result.AppendLine(properties.ToString());
// Add the constructor to the output