| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <#@ template debug="true" hostSpecific="true" #>
- <#@ output extension=".cs" #>
- <#@ Assembly Name="System.Core.dll" #>
- <#@ Assembly Name="System.Xml.dll" #>
- <#@ Assembly Name="System.Xml.Linq.dll" #>
- <#@ Assembly Name="System.Windows.Forms.dll" #>
- <#@ import namespace="System" #>
- <#@ import namespace="System.IO" #>
- <#@ import namespace="System.Diagnostics" #>
- <#@ import namespace="System.Linq" #>
- <#@ import namespace="System.Xml.Linq" #>
- <#@ import namespace="System.Collections" #>
- <#@ import namespace="System.Collections.Generic" #>
- <#@ import namespace="System.Runtime.InteropServices" #>
- <#@ include file="GenerationConfig.ttinclude" #><# GenerateCopyrightHeader(); #>
- using System.Runtime.CompilerServices;
- namespace System.Numerics
- {
- internal class ConstantHelper
- {
- <#
- foreach (var type in supportedTypes)
- {
- string hexValue = "0x" + new string('f', Marshal.SizeOf(type) * 2);
- #>
- [MethodImplAttribute(MethodImplOptions.AggressiveInlining)]
- public static <#= typeAliases[type] #> Get<#= type.Name #>WithAllBitsSet()
- {
- <#= typeAliases[type] #> value = 0;
- unsafe
- {
- unchecked
- {
- *((<#= typeAliases[GetIntegralEquivalent(type)] #>*)&value) = (<#= typeAliases[GetIntegralEquivalent(type)] #>)<#= hexValue #>;
- }
- }
- return value;
- }
- <#
- }
- #>
- }
- }<#+
- public Type GetIntegralEquivalent(Type type)
- {
- if (type == typeof(float))
- {
- return typeof(int);
- }
- else if (type == typeof(double))
- {
- return typeof(long);
- }
- else
- {
- return type;
- }
- }
- #>
|