Friday, August 27, 2010

Ten Secrets of Building RIA Applications using .NET Programming in uniPaaS

When most people think of .NET programming tools for RIA, they instantly think that they are going to have to get involved in learning SilverLight programming and one or more of the several languages in Visual Studio. While this may be appealing to hard core coders, those developers looking to streamline development of highly functional and interactive Rich Internet Applications now have a better way: uniPaaS RIA applications in .NET.

While this entry is titled “Ten Secrets” it should probably be entitled “Ten Fundamentals.” There is really only one secret and that is how easy it is to leverage .NET programming in a Magic RIA application. The ten concepts covered here are fundamentals of using .NET capabilities within uniPaaS.

The .NET framework provides for .NET assemblies. A .NET assembly is a logical unit of code that is available as an .exe or .dll. It contains code that the .NET framework common language runtime (CLR) executes.

1. Defining .NET Variables.
After loading a .NET assembly in uniPaaS, you will be able to work with any of its objects and methods. .NET assemblies are loaded into the Composite Resource Repository (CRR) in uniPaaS. You can then define a .NET variable for use in uniPaaS and then add the variable to a form in your RIA application and set its properties.

2. Controlling .NET Properties.

When working with .NET objects they have properties such as free-form text, numerics, or objects. The properties of a .NET object are can view and use the properties development scenarios where you need these values, such as calculations, for a display in a Verify operation so on. You can see the relationship between .NET types and uniPaaS types in the table below.

uniPaaS Type .NET Type
Numeric SByte, Byte , Int16, Uint16, Int32, UInt32, Int64, UInt64, IntPtr, UIntPtr, Char, Decimal, Single, Double, Float
Alpha Unicode Char, Char[], String, StringBuilder
TimeDateTime, TimeSpan
BlobByte, Byte[], Char, Char[], String, StringBuilder
VectorICollection (only from .NET to uniPaaS), IList and objects that implement Indexers through the usage of 'this' keyword. Only indexers that have integer indexes uniPaaS only converts simple vectors and not multi vectors

3. Using the DNSet() Function.

The uniPaaS DNSet() function is so named because it allows you to set the properties of a .NET (.NET=DN) object. In addition, you can directly access .NET in the expression editor with the expression prefix DotNet.

4. Use .NET Aliases.

OK, maybe this is a secret. .NET naming conventions are long and obnoxious as many of the assemblies have a very long path. uniPaaS allows you to define aliases in .NET so you can access things more easily. uniPaaS also includes a type-ahead / auto-complete capability but aliases often work better because too many .NET names have the same beginning.

5. Using .NET Methods.

Most of the .NET objects perform a variety of actions such as trigger events and run methods. When using .NET within uniPaaS, uniPaaS can respond to the .NET events and can activate .NET methods.

Just like with uniPaaS objects, a .NET object can trigger events during runtime. When using a .NET object within uniPaaS, it is possible to handle the .NET event in a very similar way to handling a uniPaaS event. This means you can handle the various methods in the .NET object.

It is not recommended to run a method where it will be evaluated often, such as in the property of a control. This will impact performance. Likewise, you should avoid using .NET methods that conflict with the internal uniPaaS methods as this will likely not yield the desired results.

At times, you will need to specify which .NET type you want uniPaaS to use since .NET allows method overloading where a .NET class has more than one method with the same name. To specify which .NET type you want uniPaaS to use, employ the DNCast() function in uniPaaS.

6. Trapping .NET Events.

As a uniPaaS developer, you are already familiar with event driven programming. With many .NET objects, you will find that they expose events that are triggered during runtime. Some common events are available in most .NET controls, such as OnMouseClick, and some others are unique to a specific control. In uniPaaS you can trap for .NET events and handle them in order to interact in specific ways with that .NET object. And of course, events can be propagated so that they can be handled by parent tasks as well.

7. Working with Constructors.

uniPaaS allows you to get or set properties and use methods and events that are published by the object. A .NET object must be instantiated to be usable.

When using .NET within uniPaaS, the instantiation of a .NET object is done automatically for all .NET objects that you placed on a form. When creating the Rich Client Display form, uniPaaS creates an instance for all of the form's .NET objects.

However, when a .NET variable is not placed on a form, it has not yet been instantiated, which means you should do so using a “constructor”. A constructor instantiates and initializes an object. Constructors are methods in which the name of the method is the same as the class itself. For example, the StringBuilder object therefore has a constructor named StringBuilder(). The Magic University course “.NET Programming with uniPaaS” will provide the guidance you need to follow in order to place a constructor properly within an application.

8. Defining a .NET Array.

A .NET array is similar to a uniPaaS vector. Therefore you will understand intuitively that an array is a variable that can hold multiple values of the same type. In contrast with uniPaaS vectors however, when working with .NET you need to predefine the number of cells, or elements that make up the array.

In uniPaaS, defining a .NET array is very similar to defining any other .NET object. To define an array in uniPaaS you simply add square brackets [] to the .NET Object Type. The size of the array, however, is declared by the object constructor.

9. Trapping Exceptions.

Error handling is essential to all forms of programming and using .NET programming in a uniPaaS application is no exception to that (pun intended). uniPaaS provides two internal functions for dealing with .NET exceptions: DNExceptionOccurred() and DNException(). By mastering the use of these functions, you will be able to trap errors and handle them appropriately.

10. Using .NET Code.

In addition to working with standard .NET objects, methods and properties, there may be times when you want to execute custom .NET code. uniPaaS allows you to write .NET
Code from within your application by using the Invoke .NET operation. uniPaaS passes the .NET code to the CLR provided as part of the .NET framework. The compiler returns the compiled code back to uniPaaS and the uniPaaS studio saves the task source code. During deployment, the compiled code is passed back to the client and executed.

No comments:

Post a Comment