﻿// ------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version: 16.0.0.0
//  
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
namespace Codge.BasicModel.Templates.CS.Templates.Types
{
    using System.IO;
    using System.Linq;
    using System.Text;
    using System.Collections.Generic;
    using Codge.DataModel;
    using Codge.Generator.Common;
    using System;
    
    /// <summary>
    /// Class to produce the template output
    /// </summary>
    
    #line 1 "C:\Work\Codge\src\Models\Basic\CS\Codge.BasicModel.Templates\Templates\Types\Composite.tt"
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "16.0.0.0")]
    public partial class Composite : T4TemplateAction<TypeBase>
    {
#line hidden
        /// <summary>
        /// Create the template output
        /// </summary>
        public override string TransformText()
        {
            this.Write("\r\nnamespace Types.");
            
            #line 10 "C:\Work\Codge\src\Models\Basic\CS\Codge.BasicModel.Templates\Templates\Types\Composite.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Type.Namespace.GetFullName(".")));
            
            #line default
            #line hidden
            this.Write("\r\n{\r\n\tpublic class ");
            
            #line 12 "C:\Work\Codge\src\Models\Basic\CS\Codge.BasicModel.Templates\Templates\Types\Composite.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Type.Name));
            
            #line default
            #line hidden
            this.Write("\r\n");
            
            #line 13 "C:\Work\Codge\src\Models\Basic\CS\Codge.BasicModel.Templates\Templates\Types\Composite.tt"
					
					if(Type.BaseType != null)
					{

            
            #line default
            #line hidden
            this.Write("\t\t: ");
            
            #line 17 "C:\Work\Codge\src\Models\Basic\CS\Codge.BasicModel.Templates\Templates\Types\Composite.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Type.BaseType.Name));
            
            #line default
            #line hidden
            this.Write("\r\n");
            
            #line 18 "C:\Work\Codge\src\Models\Basic\CS\Codge.BasicModel.Templates\Templates\Types\Composite.tt"

					}

            
            #line default
            #line hidden
            this.Write("\t{\r\n\t    public ");
            
            #line 22 "C:\Work\Codge\src\Models\Basic\CS\Codge.BasicModel.Templates\Templates\Types\Composite.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Type.Name));
            
            #line default
            #line hidden
            this.Write("()\r\n\t\t{}\r\n\r\n");
            
            #line 25 "C:\Work\Codge\src\Models\Basic\CS\Codge.BasicModel.Templates\Templates\Types\Composite.tt"
				
					if(Type.GetAllFields().Any())
					{

            
            #line default
            #line hidden
            this.Write("\r\n\t\tpublic ");
            
            #line 30 "C:\Work\Codge\src\Models\Basic\CS\Codge.BasicModel.Templates\Templates\Types\Composite.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Type.Name));
            
            #line default
            #line hidden
            this.Write("(");
            
            #line 30 "C:\Work\Codge\src\Models\Basic\CS\Codge.BasicModel.Templates\Templates\Types\Composite.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(ModelBehaviour.GetCtorParamters(Type)));
            
            #line default
            #line hidden
            this.Write(")\r\n");
            
            #line 31 "C:\Work\Codge\src\Models\Basic\CS\Codge.BasicModel.Templates\Templates\Types\Composite.tt"
				
					if(Type.BaseType != null)
					{

            
            #line default
            #line hidden
            this.Write("\t\t\t: base(");
            
            #line 35 "C:\Work\Codge\src\Models\Basic\CS\Codge.BasicModel.Templates\Templates\Types\Composite.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(string.Join(", ", Type.BaseType.GetAllFields().Select(ModelBehaviour.GetParameterName))));
            
            #line default
            #line hidden
            this.Write(")\r\n");
            
            #line 36 "C:\Work\Codge\src\Models\Basic\CS\Codge.BasicModel.Templates\Templates\Types\Composite.tt"
				
					}

            
            #line default
            #line hidden
            this.Write("\t\t{\r\n");
            
            #line 40 "C:\Work\Codge\src\Models\Basic\CS\Codge.BasicModel.Templates\Templates\Types\Composite.tt"
				
						foreach(var field in Type.Fields)
						{

            
            #line default
            #line hidden
            this.Write("\t\t\t");
            
            #line 44 "C:\Work\Codge\src\Models\Basic\CS\Codge.BasicModel.Templates\Templates\Types\Composite.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(ModelBehaviour.GetMemberName(field)));
            
            #line default
            #line hidden
            this.Write(" = ");
            
            #line 44 "C:\Work\Codge\src\Models\Basic\CS\Codge.BasicModel.Templates\Templates\Types\Composite.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(ModelBehaviour.GetParameterName(field)));
            
            #line default
            #line hidden
            this.Write(";\r\n");
            
            #line 45 "C:\Work\Codge\src\Models\Basic\CS\Codge.BasicModel.Templates\Templates\Types\Composite.tt"
				
						}

            
            #line default
            #line hidden
            this.Write("\t\t}\r\n\r\n\r\n");
            
            #line 51 "C:\Work\Codge\src\Models\Basic\CS\Codge.BasicModel.Templates\Templates\Types\Composite.tt"
				
					}

					foreach(var field in Type.Fields)
					{

            
            #line default
            #line hidden
            this.Write("\t\tpublic\t");
            
            #line 57 "C:\Work\Codge\src\Models\Basic\CS\Codge.BasicModel.Templates\Templates\Types\Composite.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(ModelBehaviour.GetNativeType(field)));
            
            #line default
            #line hidden
            this.Write(" ");
            
            #line 57 "C:\Work\Codge\src\Models\Basic\CS\Codge.BasicModel.Templates\Templates\Types\Composite.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(ModelBehaviour.GetMemberName(field)));
            
            #line default
            #line hidden
            this.Write(" {get; set;}\r\n");
            
            #line 58 "C:\Work\Codge\src\Models\Basic\CS\Codge.BasicModel.Templates\Templates\Types\Composite.tt"
				
					}

            
            #line default
            #line hidden
            this.Write("\t}\r\n}\r\n\r\n\r\n");
            return this.GenerationEnvironment.ToString();
        }
        
        #line 65 "C:\Work\Codge\src\Models\Basic\CS\Codge.BasicModel.Templates\Templates\Types\Composite.tt"

	

	public CompositeType Type {get; private set;}

	public Composite(TypeBase type, ModelBehaviour modelBehaviour)
        : base(modelBehaviour)
	{
		Type = type as CompositeType;
	}

	public override bool IsApplicable()
	{
		return Type!=null;
	}

	public override PathAndContent Execute(Context context)
	{
		return new PathAndContent(new ItemInformation(Type.QName(), "Types.cs"), TransformText());
	}


        
        #line default
        #line hidden
    }
    
    #line default
    #line hidden
}
