text:
require "action_dispatch/http/response"
require "delegate"
require "active_support/json"

module ActionController
  # Mix this module into your controller, and all actions in that controller
  # will be able to stream data to the client as it's written.
  #
  #   class MyController < ActionController::Base
  #     include ActionController::Live
  #
  #     def stream
  #       response.headers['Content-Type'] = 'text/event-stream'
  #       100.times {
  #         response.stream.write "hello world\n"
  #         sleep 1
  #       }
  #     ensure
  #       response.stream.close
  #     end
  #   end
  #
  # There are a few caveats with this module. You *cannot* write headers after the
  # response has been committed (Response#committed? will return truthy).
  # Calling +write+ or +close+ on the response stream will cause the response
  # object to be committed. Make sure all headers are set before calling write
  # or close on your stream.
  #
  # You *must* call close on your stream when you're finished, otherwise the
  # socket may be left open forever.
  #
  # The final caveat is that your actions are executed in a separate thread than
  # the main thread. Make sure your actions are thread safe, and this shouldn't
  # be a problem (don't share state across threads, etc).
  module Live
    extend ActiveSupport::Concern

    module ClassMethods
      def make_response!(request)
        if request.get_header("HTTP_VERSION") == "HTTP/1.0"
          super
        else
          Live::Response.new.tap do |res|
            res.request = request
          end
        end
      end
    end

    # This class provides the ability to write an SSE (Server Sent Event)
    # to an IO stream. The class is initialized with a stream and can be used
    # to either write a JSON string or an object which can be converted to JSON.
    #
    # Writing an object will convert it into standard SSE format with whatever
    # options you have configured. You may choose to set the following options:
    #
    #   1) Event. If specified, an event with this name will be dispatched on
    #   the browser.
    #   2) Retry. The reconnection time in milliseconds used when attempting
    #   to send the event.
    #   3) Id. If the connection dies while sending an SSE to the browser, then
    #   the server will receive a +Last-Event-ID+ header with value equal to +id+.
    #
    # After setting an option in the constructor of the SSE object, all future
    # SSEs sent across the stream will use those options unless overridden.
    #
    # Example Usage:
    #
    #   class MyController < ActionController::Base
    #     include ActionController::Live
    #
    #     def index
    #       response.headers['Content-Type'] = 'text/event-stream'
    #       sse = SSE.new(response.stream, retry: 300, event: "event-name")
    #       sse.write({ name: 'John'})
    #       sse.write({ name: 'John'}, id: 10)
    #       sse.write({ name: 'John'}, id: 10, event: "other-event")
    #       sse.write({ name: 'John'}, id: 10, event: "other-event", retry: 500)
    #     ensure
    #       sse.close
    #     end
    #   end
    #
    # Note: SSEs are not currently supported by IE. However, they are supported
    # by Chrome, Firefox, Opera, and Safari.
    class SSE
      PERMITTED_OPTIONS = %w( retry event id )

      def initialize(stream, options = {})
        @stream = stream
        @options = options
      end

      def close
        @stream.close
      end

      def write(object, options = {})
        case object
        when String
          perform_write(object, options)
        else
          perform_write(ActiveSupport::JSON.encode(object), options)
        end
      end

      private
        def perform_write(json, options)
          current_options = @options.merge(options).stringify_keys

          PERMITTED_OPTIONS.each do |option_name|
            if (option_value = current_options[option_name])
              @stream.write "#{option_name}: #{option_value}\n"
            end
          end

          message = json.gsub("\n", "\ndata: ")
          @stream.write "data: #{message}\n\n"
        end
    end

    class ClientDisconnected < RuntimeError
    end

    class Buffer < ActionDispatch::Response::Buffer #:nodoc:
      include MonitorMixin

      # Ignore that the client has disconnected.
      #
      # If this value is `true`, calling `write` after the client
      # disconnects will result in the written content being silently
      # discarded. If this value is `false` (the default), a
      # ClientDisconnected exception will be raised.
      attr_accessor :ignore_disconnect

      def initialize(response)
        @error_callback = lambda { true }
        @cv = new_cond
        @aborted = false
        @ignore_disconnect = false
        super(response, SizedQueue.new(10))
      end

      def write(string)
        unless @response.committed?
          @response.headers["Cache-Control"] ||= "no-cache"
          @response.delete_header "Content-Length"
        end

        super

        unless connected?
          @buf.clear

          unless @ignore_disconnect
            # Raise ClientDisconnected, which is a RuntimeError (not an
            # IOError), because that's more appropriate for something beyond
            # the developer's control.
            raise ClientDisconnected, "client disconnected"
          end
        end
      end

      # Write a 'close' event to the buffer; the producer/writing thread
      # uses this to notify us that it's finished supplying content.
      #
      # See also #abort.
      def close
        synchronize do
          super
          @buf.push nil
          @cv.broadcast
        end
      end

      # Inform the producer/writing thread that the client has
      # disconnected; the reading thread is no longer interested in
      # anything that's being written.
      #
      # See also #close.
      def abort
        synchronize do
          @aborted = true
          @buf.clear
        end
      end

      # Is the client still connected and waiting for content?
      #
      # The result of calling `write` when this is `false` is determined
      # by `ignore_disconnect`.
      def connected?
        !@aborted
      end

      def on_error(&block)
        @error_callback = block
      end

      def call_on_error
        @error_callback.call
      end

      private
        def each_chunk(&block)
          loop do
            str = nil
            ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
              str = @buf.pop
            end
            break unless str
            yield str
          end
        end
    end

    class Response < ActionDispatch::Response #:nodoc: all
      private
        def before_committed
          super
          jar = request.cookie_jar
          # The response can be committed multiple times
          jar.write self unless committed?
        end

        def build_buffer(response, body)
          buf = Live::Buffer.new response
          body.each { |part| buf.write part }
          buf
        end
    end

    def process(name)
      t1 = Thread.current
      locals = t1.keys.map { |key| [key, t1[key]] }

      error = nil
      # This processes the action in a child thread. It lets us return the
      # response code and headers back up the Rack stack, and still process
      # the body in parallel with sending data to the client.
      new_controller_thread {
        ActiveSupport::Dependencies.interlock.running do
          t2 = Thread.current

          # Since we're processing the view in a different thread, copy the
          # thread locals from the main thread to the child thread. :'(
          locals.each { |k, v| t2[k] = v }

          begin
            super(name)
          rescue => e
            if @_response.committed?
              begin
                @_response.stream.write(ActionView::Base.streaming_completion_on_exception) if request.format == :html
                @_response.stream.call_on_error
              rescue => exception
                log_error(exception)
              ensure
                log_error(e)
                @_response.stream.close
              end
            else
              error = e
            end
          ensure
            @_response.commit!
          end
        end
      }

      ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
        @_response.await_commit
      end

      raise error if error
    end

    def response_body=(body)
      super
      response.close if response
    end

    private
      # Spawn a new thread to serve up the controller in. This is to get
      # around the fact that Rack isn't based around IOs and we need to use
      # a thread to stream data from the response bodies. Nobody should call
      # this method except in Rails internals. Seriously!
      def new_controller_thread # :nodoc:
        Thread.new {
          t2 = Thread.current
          t2.abort_on_exception = true
          yield
        }
      end

      def log_error(exception)
        logger = ActionController::Base.logger
        return unless logger

        logger.fatal do
          message = +"\n#{exception.class} (#{exception.message}):\n"
          message << exception.annotated_source_code.to_s if exception.respond_to?(:annotated_source_code)
          message << "  " << exception.backtrace.join("\n  ")
          "#{message}\n\n"
        end
      end
  end
end


text:
using Innovator.Client;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace InnovatorAdmin
{
  public class OutputModelClasses
  {
    private IAsyncConnection _conn;
    private string _baseDir = @"C:\Users\eric.domke\Documents\Models\";
    private string _companyName = "Gentex";

    public OutputModelClasses(IAsyncConnection conn)
    {
      _conn = conn;
    }

    public async Task Run()
    {
      var itemTypes = (await _conn.ApplyAsync(@"<Item type='ItemType' action='get' select='id,implementation_type,is_relationship,is_versionable'>
  <Relationships>
    <Item type='Property' action='get' select='name,data_source,data_type,foreign_property(data_type)'>
      <name condition='not in'>'classification','config_id','created_by_id','created_on','css','current_state','generation','is_current','is_released','itemtype','keyed_name','locked_by_id','major_rev','managed_by_id','minor_rev','modified_by_id','modified_on','new_version','not_lockable','owned_by_id','permission_id','state','team_id'</name>
    </Item>
    <Item type='Morphae' action='get' select='related_id' related_expand='0' />
  </Relationships>
</Item>", true, false).ToTask()).Items().OfType<Innovator.Client.Model.ItemType>().ToArray();

      var defaultFactory = new Innovator.Client.DefaultItemFactory();
      //itemTypes = itemTypes.Where(i => defaultFactory.NewItem(_conn.AmlContext, i.IdProp().KeyedName().Value) == null).ToArray();

      var dict = itemTypes.ToDictionary(i => i.Id());
      var polymorphicIds = new HashSet<string>();
      var links = new NameValueCollection();

      var files = new List<string>() { "AssemblyInfo.Version.cs" };
      var directories = new string[]
      {
        Path.Combine(_baseDir, "Innovator.Client." + _companyName),
        Path.Combine(_baseDir, "Innovator.Client." + _companyName + "/Properties")
      };

      foreach (var dir in directories)
      {
        if (!Directory.Exists(dir))
          Directory.CreateDirectory(dir);
      }

      foreach (var itemType in itemTypes.Where(i => i.ImplementationType().Value == "polymorphic"))
      {
        polymorphicIds.Add(itemType.Id());
        var itemTypeLabel = "I" + itemType.IdProp().KeyedName().Value.Replace(" ", "");
        files.Add(itemTypeLabel + ".cs");
        using (var writer = new StreamWriter(Path.Combine(_baseDir, "Innovator.Client." + _companyName + "/" + itemTypeLabel + ".cs")))
        {
          await writer.WriteAsync(@"using Innovator.Client;
using System;

namespace Innovator.Client.Model
{
  ///");
          await writer.WriteAsync("Interface for polymorphic item type " + itemType.IdProp().KeyedName().Value);
          await writer.WriteAsync(@"
  public interface ");
          await writer.WriteAsync(itemTypeLabel);
          await writer.WriteAsync(@" : IItem
  {
");
          var versionable = itemType.Relationships("Morphae").All(m => dict[m.RelatedId().Value].IsVersionable().AsBoolean(false));

          foreach (var prop in itemType
            .Relationships()
            .OfType<Innovator.Client.Model.Property>()
            .Where(p => p.NameProp().Value != "source_id" && p.NameProp().Value != "related_id" && p.NameProp().Value != "id"))
          {
            if (!versionable
              && (prop.NameProp().Value == "effective_date" || prop.NameProp().Value == "release_date" || prop.NameProp().Value == "superseded_date"))
              continue;

            await writer.WriteAsync("    /// Retrieve the <c>");
            await writer.WriteAsync(prop.NameProp().Value);
            await writer.WriteAsync("</c> property of the item\r\n");
            await writer.WriteAsync("    IProperty_");
            await writer.WriteAsync(PropType(prop, polymorphicIds));
            await writer.WriteAsync(" ");
            await writer.WriteAsync(GetPropName(prop.NameProp().Value, itemTypeLabel.Substring(1)));
            await writer.WriteLineAsync(@"();");
          }
          await writer.WriteAsync(@"  }
}");
        }
        links.Add(itemType.Id(), itemTypeLabel);
        foreach (var poly in itemType.Relationships("Morphae"))
        {
          links.Add(poly.RelatedId().Value, itemTypeLabel);
        }
      }

      foreach (var itemType in itemTypes)
      {
        var itemTypeLabel = itemType.IdProp().KeyedName().Value.Replace(" ", "");
        files.Add(itemTypeLabel + ".cs");
        using (var writer = new StreamWriter(Path.Combine(_baseDir, "Innovator.Client." + _companyName + "/" + itemTypeLabel + ".cs")))
        {
          await writer.WriteAsync(@"using Innovator.Client;
using System;

namespace Innovator.Client.Model
{
  ///");
          await writer.WriteAsync("Class for the item type " + itemType.IdProp().KeyedName().Value);
          await writer.WriteAsync(@"
  [ArasName(""");
          await writer.WriteAsync(itemType.IdProp().KeyedName().Value);
          await writer.WriteAsync(@""")]
  public class ");
          await writer.WriteAsync(itemTypeLabel);
          await writer.WriteAsync(@" : Item");
          if (links[itemType.Id()] != null)
          {
            await writer.WriteAsync(@", ");
            await writer.WriteAsync(links.GetValues(itemType.Id()).GroupConcat(", "));
          }
          if (itemType.IsRelationship().AsBoolean(false))
          {
            var source = itemType.Relationships().OfType<Innovator.Client.Model.Property>().Single(p => p.NameProp().Value == "source_id");
            if (source.DataSource().KeyedName().HasValue())
            {
              await writer.WriteAsync(@", INullRelationship<");
              await writer.WriteAsync((polymorphicIds.Contains(source.DataSource().Value) ? "I" : "") + source.DataSource().KeyedName().Value.Replace(" ", ""));
              await writer.WriteAsync(@">");
            }

            var related = itemType.Relationships().OfType<Innovator.Client.Model.Property>().Single(p => p.NameProp().Value == "related_id");
            if (related.DataSource().KeyedName().HasValue())
            {
              await writer.WriteAsync(@", IRelationship<");
              await writer.WriteAsync((polymorphicIds.Contains(source.DataSource().Value) ? "I" : "") + related.DataSource().KeyedName().Value.Replace(" ", ""));
              await writer.WriteAsync(@">");
            }
          }
          await writer.WriteAsync(@"
  {
    protected ");
          await writer.WriteAsync(itemTypeLabel);
          await writer.WriteAsync(@"() { }
    public ");
          await writer.WriteAsync(itemTypeLabel);
          await writer.WriteAsync(@"(ElementFactory amlContext, params object[] content) : base(amlContext, content) { }
    static ");
          await writer.WriteAsync(itemTypeLabel);
          await writer.WriteAsync("() { Innovator.Client.Item.AddNullItem<");
          await writer.WriteAsync(itemTypeLabel);
          await writer.WriteAsync(">(new ");
          await writer.WriteAsync(itemTypeLabel);
          await writer.WriteAsync(@" { _attr = ElementAttributes.ReadOnly | ElementAttributes.Null }); }

");

          foreach (var prop in itemType
            .Relationships()
            .OfType<Innovator.Client.Model.Property>()
            .Where(p => p.NameProp().Value != "source_id" && p.NameProp().Value != "related_id" && p.NameProp().Value != "id"))
          {
            await writer.WriteAsync("    /// Retrieve the <c>");
            await writer.WriteAsync(prop.NameProp().Value);
            await writer.WriteAsync("</c> property of the item\r\n");
            await writer.WriteAsync("    [ArasName(\"");
            await writer.WriteAsync(prop.NameProp().Value);
            await writer.WriteAsync("\")]\r\n");
            await writer.WriteAsync("    public IProperty_");
            await writer.WriteAsync(PropType(prop, polymorphicIds));
            await writer.WriteAsync(" ");
            await writer.WriteAsync(GetPropName(prop.NameProp().Value, itemTypeLabel));
            await writer.WriteAsync(@"()
    {
      return this.Property(""");
            await writer.WriteAsync(prop.NameProp().Value);
            await writer.WriteAsync(@""");
    }
");
          }
          await writer.WriteAsync(@"  }
}");
        }
      }

      files.Add("CorporateItemFactory.cs");
      using (var writer = new StreamWriter(Path.Combine(_baseDir, "Innovator.Client." + _companyName + "/" + "CorporateItemFactory.cs")))
      {
        await writer.WriteAsync(@"using Innovator.Client;
using Innovator.Client.Model;

namespace Innovator.Client.Model
{
  public class CorporateItemFactory : IItemFactory
  {
    private static ElementFactory _local = new ElementFactory(new ServerContext(false), new CorporateItemFactory());
    public static ElementFactory Local { get { return _local; } }

    private static IReadOnlyItem _nullItem = new IReadOnlyItem[] { }.FirstOrNullItem();
    public static IReadOnlyItem NullItem { get { return _nullItem; } }

    private IItemFactory _default = new DefaultItemFactory();

    public Item NewItem(ElementFactory factory, string type)
    {
      switch (type)
      {
");
        foreach (var itemType in itemTypes)
        {
          var itemTypeLabel = itemType.IdProp().KeyedName().Value.Replace(" ", "");
          await writer.WriteAsync("        case \"");
          await writer.WriteAsync(itemType.IdProp().KeyedName().Value);
          await writer.WriteAsync("\": return new ");
          await writer.WriteAsync(itemTypeLabel);
          await writer.WriteAsync("(factory);");
          await writer.WriteLineAsync();
        }
        await writer.WriteAsync(@"      }

      return _default.NewItem(factory, type);
    }
  }
}");
      }

      using (var writer = new StreamWriter(Path.Combine(_baseDir, "Innovator.Client." + _companyName + "/Innovator.Client." + _companyName + ".csproj")))
      {
        await writer.WriteAsync(@"<?xml version=""1.0"" encoding=""utf-8""?>
<Project ToolsVersion=""14.0"" DefaultTargets=""Build"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
  <Import Project=""$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"" Condition=""Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"" />
  <PropertyGroup>
    <MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
    <Configuration Condition="" '$(Configuration)' == '' "">Debug</Configuration>
    <Platform Condition="" '$(Platform)' == '' "">AnyCPU</Platform>
    <ProjectGuid>{779753D2-6514-4A32-B180-D13B4FA61CB3}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>Innovator.Client." + _companyName + @"</RootNamespace>
    <AssemblyName>Innovator.Client." + _companyName + @"</AssemblyName>
    <DefaultLanguage>en-US</DefaultLanguage>
    <FileAlignment>512</FileAlignment>
    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    <TargetFrameworkProfile>
    </TargetFrameworkProfile>
    <TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
  </PropertyGroup>
  <PropertyGroup Condition="" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition="" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>

    <None Include=""project.json"" />
  </ItemGroup>
  <ItemGroup>
");
        files.Sort();
        foreach (var file in files)
        {
          await writer.WriteAsync("    <Compile Include=\"");
          await writer.WriteAsync(file);
          await writer.WriteAsync("\" />");
          await writer.WriteLineAsync();
        }
        await writer.WriteAsync(@"  </ItemGroup>
  <Import Project=""$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets"" />

</Project>");
      }

      using (var writer = new StreamWriter(Path.Combine(_baseDir, "Innovator.Client." + _companyName + "/Properties/AssemblyInfo.cs")))
      {
        await writer.WriteAsync(@"using System.Resources;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle(""Innovator.Client.");
        await writer.WriteAsync(_companyName);
        await writer.WriteAsync(@""")]
[assembly: AssemblyDescription(""Client models for an Aras Innovator installation"")]
[assembly: AssemblyConfiguration("""")]
[assembly: AssemblyCompany("""")]
[assembly: AssemblyProduct(""Innovator.Client.");
        await writer.WriteAsync(_companyName);
        await writer.WriteAsync(@""")]
[assembly: AssemblyCopyright(""Copyright © 2017"")]
[assembly: AssemblyTrademark("""")]
[assembly: AssemblyCulture("""")]
[assembly: NeutralResourcesLanguage(""en"")]");
      }

      using (var writer = new StreamWriter(Path.Combine(_baseDir, "Innovator.Client." + _companyName + "/AssemblyInfo.Version.cs")))
      {
        await writer.WriteAsync(@"using System.Reflection;

[assembly: AssemblyVersion(""1.0.6213.30600"")]
[assembly: AssemblyFileVersion(""1.0.6213.30600"")]
");
      }

      var projJson = @"{
  ""version"": ""1.0.6213.30600"",
  ""title"": ""Innovator.Client.Corporate"",
  ""supports"": {},
  ""frameworks"": {
    ""net35"": {
      ""dependencies"": {
        ""Innovator.Client"": ""2017.1.3.420""
      }
    },
    ""net40"": {
      ""dependencies"": {
        ""Innovator.Client"": ""2017.1.3.420""
      }
    },
    ""net45"": {
      ""dependencies"": {
        ""Innovator.Client"": ""2017.1.3.420""
      }
    },
    ""netstandard1.1"":
    {
      ""dependencies"": {
        ""Microsoft.NETCore.Portable.Compatibility"": ""1.0.1"",
        ""NETStandard.Library"": ""1.6.0"",
        ""Innovator.Client"": ""2017.1.3.420""
      }
    },
    ""netstandard1.3"":
    {
      ""dependencies"": {
        ""Microsoft.NETCore.Portable.Compatibility"": ""1.0.1"",
        ""NETStandard.Library"": ""1.6.0"",
        ""Innovator.Client"": ""2017.1.3.420""
      }
    }
  }
}".Replace("Innovator.Client.Corporate", "Innovator.Client." + _companyName);
      using (var writer = new StreamWriter(Path.Combine(_baseDir, "Innovator.Client." + _companyName + "/project.json")))
      {
        await writer.WriteAsync(projJson);
      }

      var build = @"<#
.SYNOPSIS
  This is a helper function that runs a scriptblock and checks the PS variable $lastexitcode
  to see if an error occcured. If an error is detected then an exception is thrown.
  This function allows you to run command-line programs without having to
  explicitly check the $lastexitcode variable.
.EXAMPLE
  exec { svn info $repository_trunk } ""Error executing SVN. Please verify SVN command-line client is installed""
#>

$epoch = Get-Date -Date ""2000-01-01 00:00:00Z""
$epoch = $epoch.ToUniversalTime()
$now = [System.DateTime]::UtcNow
$span = NEW-TIMESPAN -Start $epoch -End $now
$days = [int]$span.TotalDays
$span = NEW-TIMESPAN -Start $now.Date -End $now
$seconds = [int]($span.TotalSeconds / 2)

$version = ""1.0.$days.$seconds""

$assyInfo = ""using System.Reflection;`r`n`r`n[assembly: AssemblyVersion(""""$version"""")]`r`n[assembly: AssemblyFileVersion(""""$version"""")]""

$assyInfo | Out-File Innovator.Client.Corporate\AssemblyInfo.Version.cs

(Get-Content Innovator.Client.Corporate/project.json) `
    -replace '""version"": ""\d+\.\d+\.\d+\.\d+"",', """"""version"""": """"$version"""","" |
  Out-File Innovator.Client.Corporate/project.json

function Exec
{
    [CmdletBinding()]
    param(
        [Parameter(Position=0,Mandatory=1)][scriptblock]$cmd,
        [Parameter(Position=1,Mandatory=0)][string]$errorMessage = ($msgs.error_bad_command -f $cmd)
    )
    & $cmd
    if ($lastexitcode -ne 0) {
        throw (""Exec: "" + $errorMessage)
    }
}

exec { & dotnet restore }
exec { & dotnet pack Innovator.Client.Corporate/project.json -c Release -o .\artifacts --version-suffix=$version }  ".Replace("Innovator.Client.Corporate", "Innovator.Client." + _companyName);
      using (var writer = new StreamWriter(Path.Combine(_baseDir, "build.ps1")))
      {
        await writer.WriteAsync(build);
      }

      using (var writer = new StreamWriter(Path.Combine(_baseDir, "Innovator.Client." + _companyName + ".sln")))
      {
        await writer.WriteAsync(@"
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project(""{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"") = ""Innovator.Client.");
        await writer.WriteAsync(_companyName);
        await writer.WriteAsync(@""", ""Innovator.Client.");
        await writer.WriteAsync(_companyName);
        await writer.WriteAsync(@"\Innovator.Client.");
        await writer.WriteAsync(_companyName);
        await writer.WriteAsync(@".csproj"", ""{779753D2-6514-4A32-B180-D13B4FA61CB3}""
EndProject
Global
  GlobalSection(SolutionConfigurationPlatforms) = preSolution
    Debug|Any CPU = Debug|Any CPU
    Release|Any CPU = Release|Any CPU
  EndGlobalSection
  GlobalSection(ProjectConfigurationPlatforms) = postSolution
    {779753D2-6514-4A32-B180-D13B4FA61CB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
    {779753D2-6514-4A32-B180-D13B4FA61CB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
    {779753D2-6514-4A32-B180-D13B4FA61CB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
    {779753D2-6514-4A32-B180-D13B4FA61CB3}.Release|Any CPU.Build.0 = Release|Any CPU
  EndGlobalSection
  GlobalSection(SolutionProperties) = preSolution
    HideSolutionNode = FALSE
  EndGlobalSection
EndGlobal
");
      }
    }

    private string PropType(Innovator.Client.Model.Property prop, HashSet<string> polymorphicIds)
    {
      var dataType = prop.DataType().Value;
      if (dataType == "foreign" && prop.ForeignProperty().HasValue())
      {
        prop = prop.ForeignProperty().AsModel();
        dataType = prop.DataType().Value;
      }
      switch (dataType)
      {
        case "boolean":
          return "Boolean";
        case "date":
          return "Date";
        case "integer":
        case "float":
        case "decimal":
          return "Number";
        case "item":
          if (prop.DataSource().KeyedName().Exists)
            return "Item<"
              + (polymorphicIds.Contains(prop.DataSource().Value) ? "I" : "")
              + prop.DataSource().KeyedName().Value.Replace(" ", "") + ">";
          return "Item<IReadOnlyItem>";
        default:
          return "Text";
      }
    }

    private string GetPropName(string name, string itemTypeLabel)
    {
      var output = new char[name.Length];
      var o = 0;
      bool lastCharBoundary = true;
      for (var i = 0; i < name.Length; i++)
      {
        if (name[i] == '_')
        {
          lastCharBoundary = true;
        }
        else
        {
          if (lastCharBoundary)
            output[o] = char.ToUpper(name[i]);
          else
            output[o] = char.ToLower(name[i]);
          o++;
          lastCharBoundary = false;
        }
      }
      var result = new string(output, 0, o);
      switch (result)
      {
        case "Add":
        case "AmlContext":
        case "Attribute":
        case "Attributes":
        case "Clone":
        case "Elements":
        case "Equals":
        case "Exists":
        case "GetHashCode":
        case "GetType":
        case "Id":
        case "Name":
        case "Next":
        case "Parent":
        case "Property":
        case "ReadOnly":
        case "Relationships":
        case "Remove":
        case "RemoveAttributes":
        case "RemoveNodes":
        case "ToAml":
        case "ToString":
        case "TypeName":
        case "Value":
          return result + "Prop";
      }
      if (result == itemTypeLabel)
        return result + "Prop";
      return result;
    }
  }
}

redpajama_set_name: RedPajamaGithub


text:
#include "include/core/SkCanvas.h"
#include "include/core/SkColorFilter.h"
#include "include/core/SkImage.h"
#include "include/core/SkPath.h"
#include "include/core/SkRegion.h"
#include "include/core/SkShader.h"
#include "include/effects/SkGradientShader.h"
#include "samplecode/Sample.h"
#include "src/core/SkUtils.h"
#include "tools/Resources.h"

const float gMat[] = {
    .3f, .6f, .1f, 0, 0,
    .3f, .6f, .1f, 0, 0,
    .3f, .6f, .1f, 0, 0,
      0,   0,   0, 1, 0,
};

class MixerView : public Sample {
    sk_sp<SkImage>          fImg;
    sk_sp<SkColorFilter>    fCF0;
    sk_sp<SkColorFilter>    fCF1;

    float fWeight = 0;
    float fDW = 0.02f;

public:
    MixerView() {}

protected:
    SkString name() override { return SkString("Mixer"); }

    void dodraw(SkCanvas* canvas, sk_sp<SkColorFilter> cf0, sk_sp<SkColorFilter> cf1, float gap) {
        SkPaint paint;
        paint.setColorFilter(cf0);
        canvas->drawImage(fImg, 0, 0, &paint);

        paint.setColorFilter(SkColorFilters::Lerp(fWeight, cf0, cf1));
        canvas->drawImage(fImg, fImg->width() + gap * fWeight, 0, &paint);

        paint.setColorFilter(cf1);
        canvas->drawImage(fImg, 2*fImg->width() + gap, 0, &paint);
    }

    void onDrawContent(SkCanvas* canvas) override {
        if (!fImg) {
            fImg = GetResourceAsImage("images/mandrill_256.png");
            fCF0 = SkColorFilters::Matrix(gMat);
            fCF1 = SkColorFilters::Blend(0xFF44CC88, SkBlendMode::kScreen);
        }

        float gap = fImg->width() * 3;

        canvas->translate(10, 10);
        dodraw(canvas, nullptr, fCF1, gap);
        canvas->translate(0, fImg->height() + 10);
        dodraw(canvas, fCF0, nullptr, gap);
        canvas->translate(0, fImg->height() + 10);
        dodraw(canvas, fCF0, fCF1, gap);

        fWeight += fDW;
        if (fWeight > 1 || fWeight < 0) {
            fDW = -fDW;
        }
    }

    virtual Click* onFindClickHandler(SkScalar x, SkScalar y, skui::ModifierKey) override {
        return fRect.contains(SkScalarRoundToInt(x),
                              SkScalarRoundToInt(y)) ? new Click() : nullptr;
    }

    bool onClick(Click* click) override {
        fRect.offset(click->fCurr.fX - click->fPrev.fX,
                     click->fCurr.fY - click->fPrev.fY);
        return true;
    }

private:
    SkIRect fRect;

    typedef Sample INHERITED;
};
DEF_SAMPLE( return new MixerView; )


text:
module Slugforge
  module Commands
    class Config < Slugforge::SubCommand
      desc 'show', 'Print current configuration options'
      def show
        if json?
          logger.say_json config.values
        else
          logger.say "The following configuration options are in use:"
          rows = config.values.map { |name, value| [name, value] }
          print_table(rows, :indent => 4)

          unless config.slugins.empty?
            logger.say "Slugins detected:"
            rows = config.slugins.map do |(name, slugin)|
              [name, slugin.spec.version, slugin.enabled ? 'enabled' : 'disabled']
            end
            print_table(rows, :indent => 4)
          end
        end
      end
    end
  end
end