Import as Oxygene

From The Elements Wiki
Jump to: navigation, search

This is an IDE topic
 

Code Editor | Visual Designers | Build Toolchain | Debugging | Project Management | Templates


(TODO: merge into Oxidizer)

Portions of existing C# code can easily be converted into the equivalent Oxygene code using the Import C# menu item available in the context menu for the Oxygene project in the Solution Explorer.

This feature is very similar to Paste CSharp as Oxygene, but it allows to import one or more C# source files at once, while the latter only handles a single source file.

For example, the following C# source file

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Thread lTestThread = new Thread(delegate()
                   {
                       Int32 i = 0;
                       while (i < 4)
                       {
                           Console.WriteLine("Thread Step " + i.ToString());
                           i++;
                       }
                   });
            lTestThread.Start();
            Console.ReadLine();
        }
    }
}

will be imported as

namespace ConsoleApplication1;

interface

uses
  System,
  System.Collections.Generic,
  System.Linq,
  System.Text,
  System.Threading;

type
  Program = class
  private
    class method Main(args: array of System.String);
  end;

implementation

class method Program.Main(args: array of System.String);
begin
  var lTestThread: Thread := new Thread(method begin
    var i: Int32 := 0;
    while i < 4 do begin
      Console.WriteLine('Thread Step ' + i.ToString());
      {POST}inc(i)
    end
  end);
  lTestThread.Start();
  Console.ReadLine()
end;

end.


See Also