Ejemplo n.º 1
0
        /// <summary>
        /// Create the template output
        /// </summary>
        public override string TransformText()
        {
            this.Write(@"// *********************************************************************
// Copyright (c) Microsoft Corporation.  All rights reserved.
// Licensed under the MIT License
// *********************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;

using Microsoft.StreamProcessing;
using Microsoft.StreamProcessing.Internal;
using Microsoft.StreamProcessing.Internal.Collections;


");
            if (this.keyType.Namespace != null)
            {
                this.Write("using ");
                this.Write(this.ToStringHelper.ToStringWithCulture(this.keyType.Namespace));
                this.Write(";\r\n");
            }
            if (this.payloadType.Namespace != null)
            {
                this.Write("using ");
                this.Write(this.ToStringHelper.ToStringWithCulture(this.payloadType.Namespace));
                this.Write(";\r\n");
            }
            this.Write("\r\n");

            var typeInfos = types.Select(t =>
                                         Tuple.Create(String.Format("_{0}_Pool", Transformer.GetValidIdentifier(t)), t.GetCSharpSourceSyntax()));

            this.Write("\r\npublic sealed class ");
            this.Write(this.ToStringHelper.ToStringWithCulture(className));
            this.Write("<_Key, _Payload> : MemoryPool<_Key, _Payload>\r\n{\r\n");
            foreach (var t in typeInfos)
            {
                this.Write("\r\n    public ColumnPool<");
                this.Write(this.ToStringHelper.ToStringWithCulture(t.Item2));
                this.Write("> ");
                this.Write(this.ToStringHelper.ToStringWithCulture(t.Item1));
                this.Write(";\r\n\r\n    [MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n    public bool Get(" +
                           "out ColumnBatch<");
                this.Write(this.ToStringHelper.ToStringWithCulture(t.Item2));
                this.Write("> result)\r\n    {\r\n        return ");
                this.Write(this.ToStringHelper.ToStringWithCulture(t.Item1));
                this.Write(".Get(out result);\r\n    }\r\n");
            }
            this.Write("\r\n    public ");
            this.Write(this.ToStringHelper.ToStringWithCulture(className));
            this.Write("() : base(true)\r\n    {\r\n");
            foreach (var t in typeInfos)
            {
                this.Write("\r\n        ");
                this.Write(this.ToStringHelper.ToStringWithCulture(t.Item1));
                this.Write(" = MemoryManager.GetColumnPool<");
                this.Write(this.ToStringHelper.ToStringWithCulture(t.Item2));
                this.Write(">();\r\n");
            }
            this.Write("\r\n    }\r\n\r\n}");
            return(this.GenerationEnvironment.ToString());
        }