Skip to content

Commit

Permalink
Add optional "codeTypeReferenceOptions" options to support type refer…
Browse files Browse the repository at this point in the history
…ence generation with "global::" prefix.
  • Loading branch information
dafanasiev committed Jul 13, 2016
1 parent 38c2ceb commit 43ae02a
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 41 deletions.
6 changes: 5 additions & 1 deletion XmlSchemaClassGenerator.Console/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using XmlSchemaClassGenerator;
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
Expand Down Expand Up @@ -30,6 +31,7 @@ static void Main(string[] args)
var pascal = true;
var collectionType = typeof(Collection<>);
Type collectionImplementationType = null;
var codeTypeReferenceOptions = default(CodeTypeReferenceOptions);

var options = new OptionSet {
{ "h|help", "show this message and exit", v => showHelp = v != null },
Expand Down Expand Up @@ -68,6 +70,7 @@ A file name may be given by appending a pipe sign (|) followed by a file name (l
{ "a|pascal", "use Pascal case for class and property names (default is enabled)", v => pascal = v != null },
{ "ct|collectionType=", "collection type to use (default is " + typeof(Collection<>).FullName + ")", v => collectionType = v == null ? typeof(Collection<>) : Type.GetType(v, true) },
{ "cit|collectionImplementationType=", "the default collection type implementation to use (default is null)", v => collectionImplementationType = v == null ? null : Type.GetType(v, true) },
{ "ctro|codeTypeReferenceOptions=", "the default CodeTypeReferenceOptions Flags to use (default is unset; can be: {GlobalReference, GenericTypeParameter})", v => codeTypeReferenceOptions = v == null ? default(CodeTypeReferenceOptions) : (CodeTypeReferenceOptions)Enum.Parse(typeof(CodeTypeReferenceOptions), v, false) }
};

var files = options.Parse(args);
Expand Down Expand Up @@ -104,7 +107,8 @@ A file name may be given by appending a pipe sign (|) followed by a file name (l
GenerateInterfaces = interfaces,
NamingScheme = pascal ? NamingScheme.PascalCase : NamingScheme.Direct,
CollectionType = collectionType,
CollectionImplementationType = collectionImplementationType
CollectionImplementationType = collectionImplementationType,
CodeTypeReferenceOptions = codeTypeReferenceOptions
};

if (pclCompatible)
Expand Down
6 changes: 6 additions & 0 deletions XmlSchemaClassGenerator/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ public bool GenerateInterfaces
set { _configuration.GenerateInterfaces = value; }
}

public CodeTypeReferenceOptions CodeTypeReferenceOptions
{
get { return _configuration.CodeTypeReferenceOptions; }
set { _configuration.CodeTypeReferenceOptions = value; }
}

private readonly XmlSchemaSet Set = new XmlSchemaSet();
private Dictionary<XmlQualifiedName, XmlSchemaAttributeGroup> AttributeGroups;
private Dictionary<XmlQualifiedName, XmlSchemaGroup> Groups;
Expand Down
6 changes: 6 additions & 0 deletions XmlSchemaClassGenerator/GeneratorConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
Expand Down Expand Up @@ -106,6 +107,11 @@ public GeneratorConfiguration()
/// </summary>
public bool GenerateInterfaces { get; set; }

/// <summary>
/// Generator Code reference options
/// </summary>
public CodeTypeReferenceOptions CodeTypeReferenceOptions { get; set; }

/// <summary>
/// Provides a fast and safe way to write to the Log
/// </summary>
Expand Down
Loading

0 comments on commit 43ae02a

Please sign in to comment.