Example #1
0
        /// <summary>
        ///     Constructs a new application given properties describing a
        ///     particular kernel, and an action to configure services.
        /// </summary>
        /// <param name="properties">
        ///     Properties describing this kernel to clients.
        /// </param>
        /// <param name="configure">
        ///     An action to configure services for the new kernel application.
        ///     This action is called after all other kernel services have been
        ///     configured, and is typically used to provide an implementation
        ///     of <see cref="IExecutionEngine" /> along with any services
        ///     required by that engine.
        /// </param>
        /// <example>
        ///     To instantiate and run a kernel application using the
        ///     <c>EchoEngine</c> class:
        ///     <code>
        ///         public static int Main(string[] args) =>
        ///             new KernelApplication(
        ///                 properties,
        ///                 serviceCollection =>
        ///                      serviceCollection
        ///                     .AddSingleton&lt;IExecutionEngine, EchoEngine&gt;();
        ///             )
        ///             .WithDefaultCommands()
        ///             .Execute(args);
        ///         }
        ///     </code>
        /// </example>
        public KernelApplication(KernelProperties properties, Action <ServiceCollection> configure)
        {
            this.properties = properties;
            this.configure  = configure;

            Name        = $"dotnet {properties.KernelName}";
            Description = properties.Description;
            this.HelpOption();
            this.VersionOption(
                "--version",
                () => properties.KernelVersion,
                () =>
                $"Language kernel: {properties.KernelVersion}\n" +
                $"Jupyter core: {typeof(KernelApplication).Assembly.GetName().Version}"
                );
        }
Example #2
0
        public KernelApplication(KernelProperties properties, Action <ServiceCollection> configure)
        {
            this.properties = properties;
            this.configure  = configure;

            Name        = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
            Description = properties.Description;
            this.HelpOption();
            this.VersionOption(
                "--version",
                () => properties.KernelVersion,
                () => String.Join("\n",
                                  properties
                                  .VersionTable
                                  .Select(row => $"{row.Item1}: {row.Item2}")
                                  )
                );
        }
        /// <summary>
        ///     Constructs a new application given properties describing a
        ///     particular kernel, and an action to configure services.
        /// </summary>
        /// <param name="properties">
        ///     Properties describing this kernel to clients.
        /// </param>
        /// <param name="configure">
        ///     An action to configure services for the new kernel application.
        ///     This action is called after all other kernel services have been
        ///     configured, and is typically used to provide an implementation
        ///     of <see cref="IExecutionEngine" /> along with any services
        ///     required by that engine.
        /// </param>
        /// <example>
        ///     To instantiate and run a kernel application using the
        ///     <c>EchoEngine</c> class:
        ///     <code>
        ///         public static int Main(string[] args) =>
        ///             new KernelApplication(
        ///                 properties,
        ///                 serviceCollection =>
        ///                      serviceCollection
        ///                     .AddSingleton&lt;IExecutionEngine, EchoEngine&gt;();
        ///             )
        ///             .WithDefaultCommands()
        ///             .Execute(args);
        ///         }
        ///     </code>
        /// </example>
        public KernelApplication(KernelProperties properties, Action <ServiceCollection> configure)
        {
            this.properties = properties;
            this.configure  = configure;

            Name        = $"dotnet {properties.KernelName}";
            Description = properties.Description;
            this.HelpOption();
            this.VersionOption(
                "--version",
                () => properties.KernelVersion,
                () => String.Join("\n",
                                  properties
                                  .VersionTable
                                  .Select(row => $"{row.Item1}: {row.Item2}")
                                  )
                );
        }