Advertisement
sewer56lol

T4 Template Example

Mar 17th, 2020
396
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.80 KB | None | 0 0
  1. <#@ template debug="false" hostspecific="false" language="C#" #>
  2. <#@ assembly name="System.Core" #>
  3. <#@ output extension=".cs" #>
  4.  
  5. <#
  6.     string[] types = { "byte", "sbyte", "short", "ushort", "int", "uint", "long", "ulong" };
  7. #>
  8.  
  9. using System.IO;
  10. using System.Runtime.CompilerServices;
  11.  
  12. namespace Reloaded.Memory.Utilities
  13. {
  14.     public partial class ExtendedMemoryStream
  15.     {
  16. <#
  17.             foreach (var type in types)
  18.             {
  19. #>        /// <summary>
  20.         /// Appends an unmanaged structure onto the <see cref="MemoryStream"/> and advances the position.
  21.         /// </summary>
  22.         public void WriteBigEndianPrimitive(<#= type #> structure)
  23.         {
  24.             structure = Endian.Reverse(structure);
  25.             Write(Struct.GetBytes(structure));
  26.         }
  27. <#
  28.             }
  29. #>
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement