Skip to content

Commit

Permalink
Merge pull request #20 from travislaborde/first-pass
Browse files Browse the repository at this point in the history
cleaned up if without {}
  • Loading branch information
mganss authored Mar 17, 2017
2 parents 9756308 + 053c82d commit 7e71bf8
Show file tree
Hide file tree
Showing 17 changed files with 488 additions and 193 deletions.
4 changes: 2 additions & 2 deletions XmlSampleGenerator/XmlGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public static void Main(string[] args) {
XmlTextWriter textWriter = new XmlTextWriter("Sample.xml", null);
textWriter.Formatting = Formatting.Indented;
XmlSampleGenerator genr = new XmlSampleGenerator(schemas, qname);
if (max > 0) genr.MaxThreshold = max;
if (listLength > 0) genr.ListLength = listLength;
if (max > 0) { genr.MaxThreshold = max; }
if (listLength > 0) { genr.ListLength = listLength; }
genr.WriteXml(textWriter);
}

Expand Down
2 changes: 2 additions & 0 deletions XmlSampleGenerator/XmlSampleGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ public XmlSampleGenerator(XmlSchema schema, XmlQualifiedName rootElem) {

public XmlSampleGenerator(XmlSchemaSet schemaSet, XmlQualifiedName rootElem) {
if (schemaSet == null || schemaSet.Count == 0)
{
throw new Exception("Provided Schema set is empty. Xml cannot be generated.");
}
this.schemaSet = schemaSet;
schemaSet.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack);
if (xmlResolver == null) {
Expand Down
32 changes: 16 additions & 16 deletions XmlSchemaClassGenerator.Console/Glob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void Cancel()

private void Log(string s, params object[] args)
{
if (ErrorLog != null) ErrorLog(string.Format(s, args));
if (ErrorLog != null) { ErrorLog(string.Format(s, args)); }
}

/// <summary>
Expand Down Expand Up @@ -170,7 +170,7 @@ public bool IsMatch(string input)

private RegexOrString CreateRegexOrString(string pattern)
{
if (!CacheRegexes) return new RegexOrString(GlobToRegex(pattern), pattern, IgnoreCase, compileRegex: false);
if (!CacheRegexes) { return new RegexOrString(GlobToRegex(pattern), pattern, IgnoreCase, compileRegex: false); }

RegexOrString regexOrString;

Expand All @@ -187,7 +187,7 @@ private RegexOrString CreateRegexOrString(string pattern)

private IEnumerable<FileSystemInfo> Expand(string path, bool dirOnly)
{
if (Cancelled) yield break;
if (Cancelled) { yield break; }

if (string.IsNullOrEmpty(path))
{
Expand All @@ -209,10 +209,10 @@ private IEnumerable<FileSystemInfo> Expand(string path, bool dirOnly)
catch (Exception ex)
{
Log("Error getting FileSystemInfo for '{0}': {1}", path, ex);
if (ThrowOnError) throw;
if (ThrowOnError) { throw; }
}

if (exists) yield return fsi;
if (exists) { yield return fsi; }
yield break;
}

Expand All @@ -225,7 +225,7 @@ private IEnumerable<FileSystemInfo> Expand(string path, bool dirOnly)
catch (Exception ex)
{
Log("Error getting directory name for '{0}': {1}", path, ex);
if (ThrowOnError) throw;
if (ThrowOnError) { throw; }
yield break;
}

Expand All @@ -240,10 +240,10 @@ private IEnumerable<FileSystemInfo> Expand(string path, bool dirOnly)
catch (Exception ex)
{
Log("Error getting DirectoryInfo for '{0}': {1}", path, ex);
if (ThrowOnError) throw;
if (ThrowOnError) { throw; }
}

if (dir != null) yield return dir;
if (dir != null) { yield return dir; }
yield break;
}

Expand All @@ -256,7 +256,7 @@ private IEnumerable<FileSystemInfo> Expand(string path, bool dirOnly)
catch (Exception ex)
{
Log("Error getting current working directory: {1}", ex);
if (ThrowOnError) throw;
if (ThrowOnError) { throw; }
}
}

Expand Down Expand Up @@ -290,7 +290,7 @@ private IEnumerable<FileSystemInfo> Expand(string path, bool dirOnly)
catch (Exception ex)
{
Log("Error finding recursive directory in {0}: {1}.", dir, ex);
if (ThrowOnError) throw;
if (ThrowOnError) { throw; }
continue;
}

Expand Down Expand Up @@ -318,7 +318,7 @@ private IEnumerable<FileSystemInfo> Expand(string path, bool dirOnly)
catch (Exception ex)
{
Log("Error finding file system entries in {0}: {1}.", parentDir, ex);
if (ThrowOnError) throw;
if (ThrowOnError) { throw; }
continue;
}

Expand All @@ -330,8 +330,8 @@ private IEnumerable<FileSystemInfo> Expand(string path, bool dirOnly)
}
}

if (childRegexes.Any(r => r.Pattern == @"^\.\.$")) yield return parentDir.Parent ?? parentDir;
if (childRegexes.Any(r => r.Pattern == @"^\.$")) yield return parentDir;
if (childRegexes.Any(r => r.Pattern == @"^\.\.$")) { yield return parentDir.Parent ?? parentDir; }
if (childRegexes.Any(r => r.Pattern == @"^\.$")) { yield return parentDir; }
}
}

Expand All @@ -348,7 +348,7 @@ private static string GlobToRegex(string glob)
{
if (characterClass)
{
if (c == ']') characterClass = false;
if (c == ']') { characterClass = false; }
regex.Append(c);
continue;
}
Expand All @@ -366,7 +366,7 @@ private static string GlobToRegex(string glob)
regex.Append(c);
break;
default:
if (RegexSpecialChars.Contains(c)) regex.Append('\\');
if (RegexSpecialChars.Contains(c)) { regex.Append('\\'); }
regex.Append(c);
break;
}
Expand Down Expand Up @@ -511,7 +511,7 @@ public override int GetHashCode()
public override bool Equals(object obj)
{
//Check for null and compare run-time types.
if (obj == null || GetType() != obj.GetType()) return false;
if (obj == null || GetType() != obj.GetType()) { return false; }

Glob g = (Glob)obj;
return Pattern == g.Pattern;
Expand Down
Loading

0 comments on commit 7e71bf8

Please sign in to comment.