mirror of
https://github.com/prime31/FNA-VSCode-Template.git
synced 2025-10-31 21:50:44 +07:00
40 lines
1.2 KiB
Plaintext
40 lines
1.2 KiB
Plaintext
<#@ template language="C#" hostSpecific="true" #>
|
|
<#@ assembly name="System.Core" #>
|
|
<#@ import namespace="System.Collections.Generic" #>
|
|
<# var enumTypes = new string[] { "System.StringSplitOptions" }; #>
|
|
using System.Collections.Generic;
|
|
|
|
|
|
namespace Nez
|
|
{
|
|
<#
|
|
// loop through all of our enumTypes and generate a comparer
|
|
foreach( var enumType in enumTypes )
|
|
{
|
|
var classPrefix = char.ToUpper( enumType[0] ) + enumType.Substring( 1 ).Replace( ".", string.Empty );
|
|
if( enumType.IndexOf( "." ) > 0 )
|
|
{
|
|
var enumTypeSansNS = enumType.Substring( enumType.IndexOf( "." ) + 1 );
|
|
classPrefix = char.ToUpper( enumTypeSansNS[0] ) + enumTypeSansNS.Substring( 1 ).Replace( ".", string.Empty );
|
|
}
|
|
|
|
WriteLine( "\tpublic class {0}Comparer : IEqualityComparer<{1}>", classPrefix, enumType );
|
|
WriteLine( "\t{" );
|
|
|
|
WriteLine( "\t\tstatic public readonly {0}Comparer default{0}Comparer = new {0}Comparer();\n", classPrefix );
|
|
|
|
WriteLine( "\t\tpublic bool Equals( {0} x, {0} y )", enumType );
|
|
WriteLine( "\t\t{" );
|
|
WriteLine( "\t\t\treturn x == y;" );
|
|
WriteLine( "\t\t}\n\n" );
|
|
|
|
WriteLine( "\t\tpublic int GetHashCode( {0} b )", enumType );
|
|
WriteLine( "\t\t{" );
|
|
WriteLine( "\t\t\treturn (int)b;" );
|
|
WriteLine( "\t\t}" );
|
|
|
|
WriteLine( "\t}\n\n" );
|
|
}
|
|
|
|
#>
|
|
} |