Archive for the ‘.NET’ Category

Delphi Live — Day 1 Recap

Day one of Delphi Live has been great, here in San Jose. After the morning Keynote with David I, Michael Swindell, Tony de la Lama and Mike Rozlog and the official launch of RAD Studio XE, Andreano Lanusse gave a whirlwind tour of the cross platform capabilities in Delphi Prism XE — which included creating a ASP.NET web service in Visual Studio 2010 and deploying it to his Linux VM to run in Apache with mod_mono, and using MonoDevelop on the Mac to create an iOS application for the iPhone using MonoTouch (creating a web browser seems to be the Hello World of the iOS platform).

The highlight of the day most definitely was the return of Jim McKeeth‘s Delphi Bots Live, a hands on session where the audience was invited to program a bot for the Unreal Tournament ego-shooter game to fight and hunt down Jim’s real-live player. The battle raged on for over two hours, and participation was great, with people using Delphi Prism in Visual Studio, MonoDevelop and even in Notepad with the command line compiler to create their bots. In fact, Michael Swindell was so successful developing his bot with the command line compiler that we have decided to pull Visual Studio support from the product, and to concentrate our development efforts on Notepad, moving forward.

IMG_0363.jpg

San Jose City Hall; collage of multiple exposures
shot with the iPhone 4 and “See This

by marc hoffman, August 25th, 2010

Teaser – MonoDroid with Oxygene

Now that the MonoDroid preview is out, I thought I’d experiment a little with Oxygene (aka Delphi Prism), so I ported the “Button” sample to Oxygene. Here’s a taste of what I came up with:

method Activity1.OnCreate(bundle : Bundle);
begin
    inherited OnCreate(bundle);
 
    // Create your application here
    var button := new Button(self);
 
    button.Text := 'Oxygene Says: Click Me!';
    button.Click += method begin
      button.Text := string.Format('{0} clicks!', count);
      inc(count);
    end;
 
    SetContentView(button);
end;

As you can see, there’s not a lot of difference from the C# version.

Obviously, this won’t be in the build that we RTM’ed last week, and will soon be available from our friends at Embarcadero, but it will work with said release. So if you’re a Delphi Prism customer, or just have a fondness for Pascal syntax, keep an eye out here – more info will be available soon, including templates & other support files.

method Activity1.OnCreate(bundle : Bundle);
begin
inherited OnCreate(bundle);

// Create your application here
var button := new Button(self);

button.Text := ‘Oxygene Says: Click Me!’;
button.Click += method begin
button.Text := string.Format (‘{0} clicks!’, count);
inc(count);
end;

SetContentView (button);
end;

by R. Brian Lindahl, August 20th, 2010

Accessing a Data Abstract Server from Javascript

One of the client platforms for Data Abstract that has so far received little attention are JavaScript based web clients.

This morning I wrote a simple JavaScript (dojo toolkit based) web application that talks to an expanded PCTrade Sample Server. It leverages the JsonMessage to talk to the server, using JavaScript code for the simple service generated with Service Builder. The Dojo Toolkit btw is a very nice toolkit for writing javascript web applications.

 

Click on the image to start the video:

Start the video

Details

The Data Abstract Server sample contains a custom ExtendedHttpDispatcher implementation that serves the files in the javascript/ directory part of the sample, so acts like a regular web server when accessing http://127.0.0.1:8099/javascript, sending the files as-is, like a regular web server. The index.html file contains the JavaScript code, part of which is created with Service Builder, using the Tools/CodeGen/JavaScript menu on the Data Abstract Simple Data Service RODL.

Note that due to JavaScript security, the sample only works when accessing it from the same URL as the service itself.

The service provides 2 methods interesting for this web interface:

  • GetSchema: Returns the schema as an xml, used to populate the tree view on the left
  • SimpleGetData: GetData implementation that returns the data in an array of array of string with some Schema information.

The JavaScript application first asks for the schema, and uses XML DOM to find the names of all DataTables and their columns. When clicking a data table it changes the text area to the DA SQL select statment for that table. The “Execute Query” button calls the SimpleGetData service api, and when the callback for the response occurs, fills the grid with the returned data.

by Carlo Kok, June 17th, 2010

Release Timeline for 2010

With the major release of Delphi Prism out of the way now, it probably is time to talk a bit about our remaining timeline for releases this year. I realize we haven’t updated our official ROadmap since the beginning of the year, and hopefully, this post will make up for that until we get a chance to do that.

The last release of ROFX, our suite of library products including RemObjects SDK, Data Abstract, and more, was in early March and the teams have been busy since, working on good stuff on all fronts.

Because we have several “big” features in the works for the next releases, we have decided to vary slightly from our usual quarterly release cycle this year by “merging” the May and August releases into one single release that will hit sometime in July, instead. This will give us slightly longer development cycles, both for this next release, and also for the (regular, as scheduled) November release later this year. This in turn allows us to tackle more big features in a single go.

Among the new features you will see this Summer (most of which we have already talked about or hinted at) are modelling support via Relativity Server and a full-blown Server Explorer and Schema Modeler for the Mac (in DA/OSX), new Server and Client side business rules scripting in both DA/.NET and Relativity, and a brand new New Project wizard system in DA/.NET that will make it way easier to start new projects, or add a new client project to an existing solution. And these are just the big ones.

For the Winter release (in November), we’ll expand the scripting support to the other two platforms (Client and Server for Delphi/Windows, and  Client for Mac OS X), and also bring you a new Schema Modeler for Windows. The current Scheme Modeler has gotten long in the tooth and we’ve been meaning to thoroughly revamp it, for a long time. The new SM will be driven by some of the experiences we collected implementing the Mac version, but also by years of working with the current Schema Modeler and learning its limitations and issues. We’ll also bring the new template system to Delphi, as well.

Betas

Starting a couple weeks from now (probably once I’m back from WWDC), we’ll start up a more regular beta cycle again, with (mostly) weekly beta builds of RO/DA for all three platforms, all the way thru to the July release, and beyond. Many of the new features (especially DASM/Mac, and the Scripting) will be fully functional by then, and we’ll be looking forward to your feedback.

Remember that beta access is available for all customers with an active subscription. Simply point your browser to beta.remobjects.com, which will take you to the beta section on our new portal site. After logging in, you will see a list of all the products you have with an active beta program, and a list of their beta downloads (if any – we don’t always have a current beta, especially not shortly after a “release” release). The usual caveats for using beta builds of course apply.

by marc hoffman, June 2nd, 2010

Delphi Prism 2011 has RTMed

Last night, we ran the RTM build of the latest Delphi Prism release.

Delphi Prism 4.0.23.741 is the result of over a year of work from the team here at RemObjects, and marks the probably single biggest release we ever have done, since ‘Chrome 1.0″ shipped back in the spring of 2005.

The Road to a New Project System

The funny part is that the biggest new feature is one that most users will not notice, or take for granted – and that is  a complete rewrite of the core IDE integration engine. You see, back when we first shipped the product, Visual Studio .NET 2003 was the latest version of Visual Studio, and the way to integrate with that was cold, hard C++. We didn’t like it, but we had no choice. We tried to implement large parts of our IDE smarts (code model and code completion, these sorts of things) in managed code, but the crucial parts that talked to Visual Studio, the parts that were the most difficult, were done in C++

With Visual Studio 2005 and later 2008, Microsoft introduced the option to create full project systems in managed code, but for one reason or another, we never made the switch. The thing was working, after all. and we had better things to do with our time, like adding new features.

With Visual Studio 2010 looming ahead, and with integration into MonoDevelop also starting to look like more of a possibility, we finally made the plunge last year, after the Spring 2009 release was out the door, and started serious work on the new project system. We did a lot of refactoring, to separate VS-specific code from generic code, with the goal to be able to share as much code as possible between IDEs, and have as little IE specific code for Visual Studio or MonoDevelop, as we could get away with.

This all progressed great, but as the August 2010 release date was approaching, we realized there was way too much work ahead of us, too many Ts to cross and Is to be dotted for us to deliver a quality release based on the new code, so we rowed back, and in a branch of our VSN repository combined the old “May 2009″ IDE code base with the latest compiler, to ship the August release, “Delphi Prism 2010″. At the same time, work went on in the main trunk, on the new project system, which we are now shipping, half a year later after having waited for MonoDevelop 2.2.2 and Visual Studio 2010 to finalize.

So, the big feature for this release, as far as we are concerned, is that you don;t really see a difference between this release and the last, but that Delphi Prism is seamlessly integrated into two brand new IDEs: Visual Studio 2010 and MonoDevelop.

Visual Studio 2010

Along with Visual Studio comes of course a host of new features – i’m tempted to say ‘for free” when of course many of these have been a lot of work under the hood, for us. There’s support for the new Silverlight 4, better WPF support and – most importantly, the new .NET 4.0 runtime, which allowed us a lot of new and advanced compiler features, from Dynamic Types over Tuples and Big Integers to obscure (but cool) things such as generic co- and contra-variance.

There’s also things that truly do come for free with the new IDE, such as new new WPF based code editor (which is very nice to use and due to WPF’s smooth (and dare i say Mac-like) font rendering very easy on the eyes. There’s also the new Visual Studio debugger, which as been vastly improved in many areas, not the last of which the debugging of multi-threaded programs. The list goes on – just search for what’s new in VS2010, and the vast vast majority of what you’ll find will apply to the new Delphi Prism.

Of course Delphi Prism 2011 will install into an existing version of VS2010, or come with and install its own copy of the Visual Studio 2010 Shell, if you don’t own VS2010 yourself. (Delphi Prism 2011 will also still install with Visual Studio 2008, if present, but it won’t bring it’s own copy. If you need both VS2008 and VS2010 on a fresh install, you can install the August 2009 release, and then upgrade to the new version, to get both Shells)

MonoDevelop

But wait; Visual Studio is not where it ends. Delphi Prism 2011 also supports MonoDevelop 2.2, on both Windows and Mac OS X. When you run the Delphi 2011 installer, it will automatically detect MonoDevelop (if present) and offer to register with it, or offer to freshly install MonoDevelop 2.2.2 for you, if you don;t have it yet.

So you can choose to use either VS, MD or both IDEs, depending on your preference.

For the Mac, we have a separate distribution of MonoDevelop.app that includes Delphi Prism; this will be a .zip file on your ISO or DVD that you can simply unzip on your mac and copy to the Applications folder.

On both Windows and the Mac, Delphi Prism integration into MD will give you the full development experience that MD has to offer. This includes the Gtk# visual designer on Windows (the MonoDevelop guys don’t yet support that on the Mac, i’m afraid), integration with MonoTouch (if you own a copy) on the Mac, and so on.

Of course MonoDevelop as an IDE is still very young, so compared to Visual Studio there is still a lot of catching up that needs to be done, both on the IDE itself, and on the more advanced IDE features that Delphi Prism supports. Our goal for this release was to provide a basic set of functionality that allows you to start working and be productive in MD. Over time, we’ll work on feature parity with VS, bringing more of the advanced features (such as “Paste C# as Oxygene“, or the Oxfuscator integration) over.

We’ll also be working on adding support for Linux as third MonoDevelop platform to Delphi Prism.

What Else?

Of course there’s a lot more to Delphi Prism 2011 than “just” two brand new IDEs. I finalized the official change log for this release a couple days back, and amazed to see that we have close to 400 bug fixes and minor improvements thru-out the product (and that does NOT even include any fixes and enhancements that happened witjhin the product cycle [such as, any "fix" related to VS2010 or MD support, which never shipped before]. that’s just fixes and improvements over the previous August 2009 release.

There’s also roughly 30 major new features (such as for example new Expression types, MacPack Integration, a cross-platform helper library for Mono) and 30 less major but noteworthy  enhancements (such as enhanced functionality in Cirrus, compiler optimizations, framework multi-targetting or support for T4 template files).

What’s Next?

The next release of Delphi Prism is already looming ahead, this fall alongside the new RAD Studio. Because  the current release was such a major milestone (and is shipping such a vastly new codebase, for the core IDE integration), we’re planning for that next release to be a pure maintenance and bug-fix release only. To start with, our team here at RemObjects will take a week or two off to recover from the rush of getting such a major release out the door.

After that, we’re planing to get back to a regular cycle. We want to release weekly new beta releases (as we have done over most of the course of this past beta cycle), combined with monthly “stable” releases that focus on  fixes and improvements in various areas of the product. The idea is that (if you join the beta program – and remember, every Delphi Prism customer is welcome to join, and we’d welcome your feedback),  you have the choice of frequent latest builds, or regular “production level” builds, as we move from the current release towards the August 2010 one.

When can You Get it?

As mentioned at the beginning, the RTM build was signed off to the team at Embarcadero yesterday. The team in Scott’s Valle will go thru some final QA cycles and prepare for the distribution to customers. If all goes well, i’m told the new release should be in the hands of people within about a week, both as new public trial, and as free update to all customers with Software Assurance (you do have Software Assurance, right!?).

Even if i were to just link to the direct download, for this release you will need a new serial number, which you should receive from Embarcadero in time.

 

Thanx for reading, and i hope you’ll enjoy Delphi Prism 2011 as much (if not more ;) as we have enjoyed creating it. Let us know what you think, either here, via email, or on the ongoing beta program.

by marc hoffman, May 23rd, 2010

Join us at Data Rage 2

RemObjects will present Data Abstract in a vendor showcase session at the Embarcadero DataRage 2 online conference, that will take place May 25-27, 2010.

Currently our session “n-Tier in a Box: Data Abstract in Action” is scheduled on Thursday, May 27th from 06:00 to 06:45 PDT.

In this session you will see how easy it is to create a Data Abstract server in Delphi, access that from a Delphi Client and we additionally show you how to create a Relativity-hosted DA server, access this via REST from a browser and at the same time from a native Mac application written with DA/OS X.

I like to invite you to the online conference and I’m excited to see (well, rather read or hear ;-) ) you at Data Rage 2.

by Sebastian, May 15th, 2010

DA/.NET Client-Side Scripting

We just finished our dataset scripting support for Data Abstract for .NET. DA now lets you define scripts on the server side (inside the schema), that the client will download and hook up to the events of the dataset. Scripting is supported for both the server and the client, and uses the RemObjects Script engine, which provides the ECMAScript (a.k.a. JavaScript) syntax.

An example, take this script for a “Customers” table:

function beforePost(row) {
  if (row["Discount"] > 50) 
    fail('Discount has to be less than 50');
  if (row["Discount"] < 0) 
    fail('Discount cannot be negative');
}
function onNewRow(row) {
  row["Discount"] = 20;
}

Now any time you fill a DataTable, on a remote data adapter with the script engine property set will receive this JavaScript from the server, and assign them to the datatable:

    var lDs := new System.Data.DataTable();
    lDs.TableName := "Customers";
    RemoteDataAdapter1.Fill(lDs, WhereExpression(nil), true);
 
    var rows := lDs.Select;
 
    rows[0].BeginEdit;
    rows[0]['Discount'] := 60;
    rows[0].EndEdit; // will fail here with a ScriptingException "Discount has to be less than 50"
 
    var lNewRec := lDs.NewRow;
    // lNewRec is preinitialized with a discount of 20 here.

Unit tests for this new feature have been written and all is working nicely. Next will be the same feature for the Linq Remote (and Local) Data Adapter.

Of course, client side scripts are there only to provide immediate user feedback, not to enforce business rules. For this reason, DA will run this business rules script not only on the client, but (where applicable) also on the server. DA also provides a range of additional server-only script events that can implement more extensive business logic – something i will talk more about, soon.

by Carlo Kok, April 19th, 2010

Delphi Prism in MonoDevelop at a glance

Our beta users (marc already did mention you can apply for the Prism beta here, didn’t he?) are already playing around with this for some time now, and we are going to ship it with the upcoming release: the Delphi Prism MonoDevelop integration. Marc already mentioned this some time ago and a lot has happened since then. This article should give you a ‘what is it and how could I start?’ introduction into Delphi Prism in MonoDevelop.

MonoDevelop LogoMonoDevelop is a free and open source .NET IDE. and has its roots in the also free and open-source SharpDevelop .NET IDE. With SharpDevelop still being a Windows-only IDE using Windows Forms, MonoDevelop (or in short MD, as we call it internally) was ported to Gtk# and massively extended in regards to cross-platform compatibility. It is now able to work smoothly on Linux, Mac OS X and, of course, Windows. You can use your solutions from Visual Studio with MD and vice versa, so you are able to have a single source solution for different platforms.

With the Delphi Prism MonoDevelop integration we target mainly the Mac and then Windows. For Windows we have the Visual Studio integration and we ship the Visual Studio Shell which is, in fact and to be honest, a far more comfortable and powerful IDE. That said: Of course we want to make sure that MonoDevelop on Windows (MD/Win) also works like a charm, but MD/Mac is of a higher priority because you don’t have an alternative IDE there.

The MD/Mac flavor of our MonoDevelop integration comes in form of a complete Mac application. It looks like it’s the original MonoDevelop, but additionally contains our Delphi Prism plug-in. That means you will have to install the MonoDevelop prerequisite by yourself (which is Mono >= 2.4). You can grab it here.

After startup, the Delphi Prism will tell you that it is not licensed and ask you to register your license (if you don’t have a Delphi Prism license yet you can get your copy and a 30-day trial key from the Delphi Prism download page).

When selecting “Start a new Solution” you have several options: The first one is a Console application, but you also have the choice to work with ASP.NET projects, create iPhone or iPod touch applications (be sure to have the iPhone SDK and at least the Trial of MonoTouch (http://monotouch.net/) installed for this) and you can build Moonlight applications (the Mono alternative to Silverlight).

For this article we’re going for an iPhone application. Not because we want you to go and buy you into the iPhone Developer Program and additionally buy MonoTouch from Novell, but just because it’s a neat thing to show ;)

In this dialog you see the options I set for the Hello world iPhone application. Be sure to meet the requirements (MD prereqs, iPhone SDK and MonoTouch) if you want to follow this article in code yourself. The next thing you’ll see is the MD editor with the project opened and ready to start.

We’re not going too deep into the MVC approach of the iPhone development, which is also the key to general Cocoa development, but you need to know that the UI is separated from your code. Unlike in Delphi or Windows forms where controls dropped on the form are automatically properties of your form class, you need to define which controls and events (called Actions) are visible to your code using defined classes.

The first thing we’re creating is the GUI. No demo without a ‘Hello World’, so we simply want to display the text entered in a text box on a label when the user presses a button. In the ‘Solution’ part of the MonoDevelop IDE to your left we expand the project and double-click on the ‘MainWindow.xib’ file. This should launch a program called ‘Interface Builder’ which belongs to the iPhone SDK. The .xib file is somewhat compareable to .dfm files you know from Delphi or like .Designer.pas files which define the layout of a Windows Forms form. The following part of designing the GUI and connecting the outlets and signals is in fact the most difficult if you never worked with interface builder. Because of that I also created a short video of this walk-through so that you have the chance to actually see what I’m going to describe now.

S1.png

On the ‘Library’ window you select the ‘Objects’ part on top and use the search box on the bottom to search for a ‘Toolbar’. Take it and drop it on the window and let it dock on the top. Then do the same for a ‘Text Field’ and a ‘Label’. You can drag them to the width that pleases you. Now that all controls are in place it’s time to make them accessible. In the ‘Library’ Windows please select ‘Classes’ on top and type ‘App’ in the search box. Then you can select the ‘AppDelegate’ class which is the interface between our application code and the GUI. Still in the library window select ‘Outlets’ in the lower half. We’re going to define accessors to the text field and the label now by clicking on the ‘+’ below the listed outlets and enter text and repeat that for label. Now we’re going to make our click event accessible by selecting ‘Actions’ instead of outlets and add the action ‘onClick:’ (mind the colon!) to the AppDelegate class.

The next task is to connect our outlets and the action to the controls. To do this, you simply select the toolbar button (labeled ‘Item’) in the window. In the property window you select the connections (white arrow on blue circle). There is an area called ‘Sent actions’ with an entry for ‘Selector’. Use the mouse and click in the circle to the right and drag this on the yellow ‘App Delegate’ box in the ‘MainWindow.xib’ window. On dropping you are able to select the action you want to link with the sent ‘selector’ action of the item. For both the text field and the label drag the ‘New referencing outlet’ circle on the App delegate and link them to the text and label outlets we defined before. Now you can press Apple+S to save the MainWindow.xib file.

MonoDevelop generates the code behind for us automatically. Please open the ‘MainWindow.xib.designer.pas’ file (expand the ‘MainWindow.xib’ node in your solution to find it) to have a loot at the generated code. Locate the

method onClick(sender: MonoTouch.UIKit.UIBarButtonItem); partial; empty;

line and copy it (withouth the empty;). Pase that in the ‘private’ section of the ‘AppDelegate’ class in the Program.pas file and double check that the empty; part did not get pasted too. This is the method that get’s called when the event (sorry, Signal ;-) ) fires from the GUI. In the implementation part complete the partial method and fill in it’s body:

method AppDelegate.onClick(sender: UIBarButtonItem);
begin
  label.Text := textbox.Text;
end;

In fact that’s all. Compile the project using the building blocks icon in the toolbar of MD (or by pressing Apple-B). Your code will be compiled into an assembly and the assemblies then will automatically be compiled in to native code for the iPhone by the MonoTouch compiler. When clicking on ‘Run’ or ‘Debug’ the iPhone simulator application should pop up and run our Hello world application:

S2.png

As you can see building an application for the iPhone using Delphi Prism is not only working, but you can make use of the full Cocoa API the iPhone SDK is offering you. Of course this only works if you have the iPhone SDK and MonoTouch, but to develop for the simulator as we just did, the free version of both is enough. You would only need to pay for the Apple developer program membership and for the MonoTouch licence if you’re going to deploy your programs on a physical device. In other words: Unless you want to start selling your application and earn money in return, you can work for free.

Here you can watch a little video that shows how the application was build:



Download this Video: as mp4 or in open ogg format.

This was a first feature preview of Delphi Prism in MonoDevelop and we hope you like it and stay tuned for more.

Sebastian

by Sebastian, March 29th, 2010

Episode 39 of the Podcast at Delphi.org

It’s been a long while, but Jim and i finally found the time again to sit down and record a new episode of The Podcast at Delphi.org, talking about the upcoming Delphi Prism 2011 release, software development for the mac using Mono, and a lot more. It’s been great to be back on air, and we’ll hope to make this a more regular thing once again. In the mean time, i hope you’ll enjoy this episode!

See the official post for this episode at Delphi.org. Or subscribe in iTunes or via the RemObjects on Air feed.

(Via The Podcast at Delphi.org.)

by marc hoffman, March 19th, 2010

Intercepting RO/.NET HttpServer requests

With the Spring 2010 release, RemObjects SDK for .NET lets you intercept any configurable path on any of the non-super http Server channels and do something completely different with the http request. This feature was added to support REST in Data Abstract, but can also easily be used to host custom pages or whole websites from within any of the http components (IpHttpServerChannel, HttpSysServerChannel, WebProcessor).

How it Works

Each of the HTTP servers implements IHttpServer and exposes a Register and Unregister method. An Extended Http Dispatcher passes it’s implementation of IHttpDispatcher that gets called for each request, returns if it can handle a specific url, and if so, is asked to process the request. Else the next dispatcher from the list gets called, until none are left and the default helpers get called.

Creating Your Own Dispatcher

Writing a custom dispatcher for a given url is quite simple. You simply need to write a new class descending from the ExtendedHttpDispatcher class and override the Process method.

class MyDispatcher: ExtendedHttpDispatcher 
{
  public override void Process(
    IHttpRequest aRequest,
    IHttpResponse aResponse,
    Stream aRequestData,
    Stream aResponseData)
  {
    StreamWriter sw = new StreamWriter(aResponseData);
    aResponse.ContentType = "text/html";
    sw.WriteLine(@"
<html>
  <head>
    <title>Hello World</title>
  </head>
  <body>
    <font size='7'>Hello World</font>
  </body>
</html>
");
    sw.Flush();
  }
}
 
  //...
MyDispatcher disp = new MyDispatcher();
disp.Path = "/hello";
disp.Server = ipHttpServer1;

Given this code, all requests to /hello or ones that start with /hello/ will get a nice “Hello World” page.

REST

The RestSchemaDispatcher class that ships with Data Abstract essentially does the same as above. It intercepts all requests to a given path. the first identifier after the path url is the table name for that request, and anything after that is used to find a record by primary key. More on the features of the RestSchemaDispatcher will be in one of my next blog posts.

by Carlo Kok, March 13th, 2010