Appendix B

MyController.cs

using System;
using System.Drawing;
using MonoTouch.CoreFoundation;
using MonoTouch.UIKit;
using MonoTouch.Foundation;
using Aras.IOM;
using System.Threading;
namespace MyApp
{
[Register("UniversalView")]
public class UniversalView : UIView
{
public UniversalView()
{
Initialize();
}
public UniversalView(RectangleF bounds)
: base(bounds)
{
Initialize();
}
void Initialize()
{
BackgroundColor = UIColor.Red;
}
}
[Register("MyController")]
partial class MyController : UIViewController
{
UITextView textView;
public MyController()
{
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
View.Frame = UIScreen.MainScreen.Bounds;
View.BackgroundColor = UIColor.White;
View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
textView = new UITextView(new RectangleF(
0,
0,
View.Frame.Width,
View.Frame.Height));
textView.ScrollEnabled = true;
ThreadPool.QueueUserWorkItem(async delegate
{
//create connection to Innovator server
HttpServerConnection connection = IomFactory.CreateHttpServerConnection("http://localhost/InnovatorServer/Server/InnovatorServer.aspx", "InnovatorSolutions", "admin", "innovator");
//login
Item user = await connection.LoginAsync();
if (user.isError())
{
throw new Exception(user.getErrorString());
}
//create innovator to connect to server
Innovator innovator = IomFactory.CreateInnovator(connection);
Item queryVariable = innovator.newItem("Variable", "get");
queryVariable.setProperty("name", "IncludedSolutions");
//send query to the server
Item variable = await queryVariable.applyAsync();
if (variable.isError())
{
throw new Exception(variable.getErrorString());
}
this.BeginInvokeOnMainThread(delegate
{
//display variable’s value property in view
textView.Text = variable.getProperty("value");
});
});
textView.Text = "Test";
View.AddSubview(textView);
}
}
}

AppDelegate.cs

using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
namespace MyApp
{
// The UIApplicationDelegate for the application. This class is responsible for launching the 
// User Interface of the application, as well as listening (and optionally responding) to 
// application events from iOS.
[Register("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
{
// class-level declarations
UIWindow window;
MyController viewController;
//
// This method is invoked when the application has loaded and is ready to run. In this 
// method you should instantiate the window, load the UI into it and then make the window
// visible.
//
// You have 17 seconds to return from this method, or iOS will terminate your application.
//
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
// create a new window instance based on the screen size
window = new UIWindow(UIScreen.MainScreen.Bounds);
// If you have defined a view, add it here:
// window.RootViewController  = navigationController;
viewController = new MyController();
window.RootViewController = viewController;
// make the window visible
window.MakeKeyAndVisible();
return true;
}
}
}