Home Account Search
Web 2.0 Ajax projects

DOTNUTSHELL is contantly working with clients to create feature rich, database driven websites using the current leading technologies:

Here is one project our developers have worked on:

 

2.jpg

 

 

The project used current AJAX techniques and frameworks to create a rich and responsive user interface for businesses using the BusinessWise intranet portal.

Silverlight 2 work

Check out what we have been playing with at DOTNUTSHELL, Silverlight 2 LBA (Large Business Application).

.NET and Silverlight Software Development

main.jpg

meettha.jpg

search.jpg

meettha2.jpg

What has DOTNUTSHELL been up to?

I was recently asked to describe what WellStart is all about at a technical level:

Removing the need for desktop databases in high performance software systems by using bleeding edge object relational mapping techniques and .NET technologies to store and optimise data collections in memory.
 
Data management tasks in object-oriented (OO) programming are typically implemented by manipulating objects, which are almost always non-scalar values. For example, consider an address book entry that represents a single person along with zero or more phone numbers and zero or more addresses. The problem is, that we need fast access to large collctions of object without effecting the integrity of the data coming back, which simply canot be done with a standard SQL databases, so WellStart introduces a new database engine which stores collections in memory, and then wraps an SQL-like layer around these collecions dramatically speeding up access to the data while maintaining integrity on the objects.
 
WellStart also introduces selective persistence. In programming, persistence refers specifically to the ability to retain data structures between program executions, either at the interface level (i.e the GUI) and the data level (i.e database). WellStart's persistence engine relies on the ability of the aplication to selectively infer (as in implicitly be able to tell) which objects in the datastore require updating, even before they have been created, by inspecting the business logic. This reduces the execution overhead because only objects whch are more likely to require upating are updated and execution code is generated for these updates.

Some screen shots of WellStart:

wellMain.jpg

Media wall:

mediaWall.jpg

Graphing module:

wellGraph.jpg

WellStart also introduces new technologies which mesh interpreted languages with native languages, allowing applications to utilse a rich user interface while still using standard system calls and services at the the lowest level to keep applications efficient.

This means that WellStart implements a strict version of model view controller, where each logicial layer is seperated into very logical partitions, allowing us to plug different business layers into the application without having any noticable effect on the user interface and its interaction. It also introduces a new data exhange mechanism which dynamicaly converts compiled cass types into types which can be used directly by ActionScript.

Advanced Software Development

Silverlight 2 - Get the host address of the site hosting a XAP

More C# Silverlight 2 tidbits.  

 

 public string GetHost()

        {

            string domain = string.Empty;

            try

            {

                string htmloc = HtmlPage.Window.Eval("window.location.href;") as string;

                domain = htmloc.Replace("http://", String.Empty);

                if (domain.Contains("/"))

                {

                    domain = domain.Substring(0, domain.IndexOf("/"));

                }

            }

            catch

            {

               return string.Empty;

            }

            return domain;

        }

 

This returns the host name of the hosting website.

 

Custom software development

Silverlight 2: Dynamically loadng a XAP

Here is a little method which will dynamically load a XAP and instantiate a class inside it, This is especially useful for a custom Silverlight loader.

Custom Software Development

public static object CreateFromXAP(Stream package, string objectTypeName, string mainass)

{

// Extract the AppManifest from the XAP package

string appManifestString = new StreamReader(

System.Windows.Application.GetResourceStream(

new StreamResourceInfo(package, null),

new Uri("AppManifest.xaml", UriKind.Relative)

).Stream).ReadToEnd();

// Use the XamlReader to parse the AppManifest into managed objects

//var deployment = System.Windows.Markup.XamlReader.Load(appManifestString);

 

XElement deploymentRoot = XDocument.Parse(appManifestString).Root;

IList<XElement> deploymentParts = (from assemblyParts in deploymentRoot.Elements().Elements()

select assemblyParts).ToList();

 

// Keep track of the main assembly,

// we'll assume that the element to create is located here.

Assembly mainAssembly = null;

// Walk all of the assemblies and load them into the CLR.

// This will load any dependent assemblies.

foreach (XElement xElement in deploymentParts)

{

string source = xElement.Attribute("Source").Value;

AssemblyPart asmPart = new AssemblyPart();

StreamResourceInfo streamInfo = System.Windows.Application.GetResourceStream(

new StreamResourceInfo(package, "application/binary"),

new Uri(source, UriKind.Relative));

Assembly assembly = asmPart.Load(streamInfo.Stream);

if (assembly.FullName.Split(',')[0] == mainass)

mainAssembly = assembly;

}

// Create a new instance of the object from the main assembly

Type objectType = mainAssembly.GetType(objectTypeName);

return Activator.CreateInstance(objectType);

}

Silverlight 2 : Get the Height and Width of a dynamically loaded image

This should help you all. SL won't know the dimensions of an image until its fully downloaded and rendered.

Have it!!

  Uri path = new Uri(“YOUR URL”, UriKind.Absolute);

            BitmapImage bitmapImage = new BitmapImage();

            bitmapImage.UriSource = path;

            bitmapImage.DownloadProgress +=

                new EventHandler<DownloadProgressEventArgs>(bitmapImage_DownloadProgress);

 

                        yourImage = new Image();
            yourImage.Source = bitmapImage;
 
void bitmapImage_DownloadProgress(object sender, DownloadProgressEventArgs e)
        {
            if (e.Progress == 100)
            {
                Dispatcher.BeginInvoke(delegate()
                {
                   GetSizes();
                });
            }
        }
 

 

void GetSizes (){
    double height = yourImage.ActualHeight;
    double width = yourImage.ActualWidth;
          
}
Custom Software Development Company
 
Silverlight 2 launched and loaded

Microsoft finally launched Silverlight 2.

Its actually a really solid platform.

 

Don't forget that DOTNUTSHELL do Silverlight Custom Software Development

FREE SEO reports which should help new websites with initial SEO stuff

We at DOTNUTSHELL are a nice bunch. We believe in giving. So, our SEO services, and initial report and consultation are now free.

Have a look on the DOTNUTSHELL site here: Free SEO Tips and Report

eCommerce Software

Just a quick note to observers that the ecanecommerce site is being updated as ecan ecommerce is maturing to a state that we can start shipping the lite version, as well as the managed and bespoke version.

More can be found here: eCommerce Software.

Anonymous delegates for localised implementations with a return value

So, you have a localised code block, in a foreach statement and you wish to use anonymous methods to structure the code elegantly.

Here is how:

//define your delegate with your return type:

delegate System.Collections.Generic.List<String> ListOfStrings();

var data =  new System.Collections.Generic.Dictionary<String, System.Collections.Generic.List<String>>();

//the above will define your dictionary

data.Add("myself"), new ListOfStrings(

delegate{

System.Collections.Generic.List<String> result = new System.Collections.Generic.List<String>();

result.Add("child1");

result.Add("child2");

result.Add("child3");

return result;

}

).Invoke());

Software Development Services

Lambda and other such like interesting code snippets

Up until now, we have relied on defined delegates and anoymous delegates to do the brunt of work when it comes to isolated code blocks which are repetitive but localised to a method. But with C# 3.0, we are provided with Lambda expressions aswell.

 

You can find software coding samples here.

Extension methods in C#

You cna find the full post on my software development homepage.

 

Extension methods are a new feature added to the C# specifiation. They allow you to dynamically add methods to classes from the context of your own application. It is especially usefull for code re-usability and keeps messy static and instance oriented functions to their variable scope.

An example would be to add a regular expresion extension directly to the string class.

VB.NET - Working out wether your process window is topmost and has focus

There isn't much on the Internet about this,

so thought I would ost this smidge of information:

Private Declare Function GetForegroundWindow Lib "user32" () As IntPtr

Private Function IsFromMe() As Boolean

Dim lngPid As Integer

Dim MyProc As Integer

Try

MyProc = System.Diagnostics.Process.GetCurrentProcess().Id

Dim window = GetForegroundWindow()

GetWindowThreadProcessId(window, lngPid)

 

Dim item = GetFocus()

'' System.Windows.Forms.MessageBox.Show(lngPid.ToString())

Catch ex As Exception

'' System.Windows.Forms.MessageBox.Show(ex.Message)

End Try

If MyProc = lngPid Then

Return True

Else

Return False

End If

End Function

 

Rapid software development

Google Chrome

Wow. I am  no lover of Google, but Chrome is a breath of fresh air. Its fast and speedy and for a developer, its Javascript debugging is just awesome. Its actually a very neat browser.

I read an interesting piece on it which I have posted on DOT's website.

You can find it at 'Google Chrome as a Cloud OS'.

I think anyone with a brain cell should download a copy now.

Impressive stuff Google.

Silverlight up against Flash and Flex
I am an experienced Flash/Flex developer, with experience in combining Flash/Flex with ASP.NET web services. I am also an experienced developer when using Microsoft Silverlight and WCF services. Flash/Flex serve a purpose, and Web Services are well supported, but I think the overrall runtime needs improving. The ActionScript platform needs refining, as it lack the exception handling that makes debugging ilverlight so much easier. Silverlight is also, performance wise, just better. The byte-code seems to be optimised alot better, and its performance on a sub P.C is actually alot better. The animation tools are also alot cleverer, and alot of the animation can be controlled within the XAML or programmatically.
.NET embedded resources

Just a snippet to show how to get an embedded resource from an assembly.

Assembly assembly = Assembly.GetExecutingAssembly();
Stream stream = assembly.GetManifestResourceStream(“MyClassLib.MyResourceFolder.MyTextFile.txt”);
StreamReader streamReader = new StreamReader(stream);
String myText = streamReader.ReadToEnd();

 

http://www.dotnutshellnet

Hex to ByteArray in C# and .NET

Got asked recently about converting Hex to ByteArray and vice versa. I found this little helper utility which is great.

 

 

using System;

using System.Text;

 

namespace Utility

{

      /// <summary>

      /// Summary description for HexEncoding.

      /// </summary>

      public class HexEncoding

      {

            public HexEncoding()

            {

                  //

                  // TODO: Add constructor logic here

                  //

            }

            public static int GetByteCount(string hexString)

            {

                  int numHexChars = 0;

                  char c;

                  // remove all none A-F, 0-9, characters

                  for (int i=0; i<hexString.Length; i++)

                  {

                        c = hexString[i];

                        if (IsHexDigit(c))

                              numHexChars++;

                  }

                  // if odd number of characters, discard last character

                  if (numHexChars % 2 != 0)

                  {

                        numHexChars--;

                  }

                  return numHexChars / 2; // 2 characters per byte

            }

            /// <summary>

            /// Creates a byte array from the hexadecimal string. Each two characters are combined

            /// to create one byte. First two hexadecimal characters become first byte in returned array.

            /// Non-hexadecimal characters are ignored.

            /// </summary>

            /// <param name="hexString">string to convert to byte array</param>

            /// <param name="discarded">number of characters in string ignored</param>

            /// <returns>byte array, in the same left-to-right order as the hexString</returns>

            public static byte[] GetBytes(string hexString, out int discarded)

            {

                  discarded = 0;

                  string newString = "";

                  char c;

                  // remove all none A-F, 0-9, characters

                  for (int i=0; i<hexString.Length; i++)

                  {

                        c = hexString[i];

                        if (IsHexDigit(c))

                              newString += c;

                        else

                              discarded++;

                  }

                  // if odd number of characters, discard last character

                  if (newString.Length % 2 != 0)

                  {

                        discarded++;

                        newString = newString.Substring(0, newString.Length-1);

                  }

 

                  int byteLength = newString.Length / 2;

                  byte[] bytes = new byte[byteLength];

                  string hex;

                  int j = 0;

                  for (int i=0; i<bytes.Length; i++)

                  {

                        hex = new String(new Char[] {newString[j], newString[j+1]});

                        bytes[i] = HexToByte(hex);

                        j = j+2;

                  }

                  return bytes;

            }

            public static string ToString(byte[] bytes)

            {

                  string hexString = "";

                  for (int i=0; i<bytes.Length; i++)

                  {

                        hexString += bytes[i].ToString("X2");

                  }

                  return hexString;

            }

            /// <summary>

            /// Determines if given string is in proper hexadecimal string format

            /// </summary>

            /// <param name="hexString"></param>

            /// <returns></returns>

            public static bool InHexFormat(string hexString)

            {

                  bool hexFormat = true;

 

                  foreach (char digit in hexString)

                  {

                        if (!IsHexDigit(digit))

                        {

                              hexFormat = false;

                              break;

                        }

                  }

                  return hexFormat;

            }

 

            /// <summary>

            /// Returns true is c is a hexadecimal digit (A-F, a-f, 0-9)

            /// </summary>

            /// <param name="c">Character to test</param>

            /// <returns>true if hex digit, false if not</returns>

            public static bool IsHexDigit(Char c)

            {

                  int numChar;

                  int numA = Convert.ToInt32('A');

                  int num1 = Convert.ToInt32('0');

                  c = Char.ToUpper(c);

                  numChar = Convert.ToInt32(c);

                  if (numChar >= numA && numChar < (numA + 6))

                        return true;

                  if (numChar >= num1 && numChar < (num1 + 10))

                        return true;

                  return false;

            }

            /// <summary>

            /// Converts 1 or 2 character string into equivalant byte value

            /// </summary>

            /// <param name="hex">1 or 2 character string</param>

            /// <returns>byte</returns>

            private static byte HexToByte(string hex)

            {

                  if (hex.Length > 2 || hex.Length <= 0)

                        throw new ArgumentException("hex must be 1 or 2 characters in length");

                  byte newByte = byte.Parse(hex, System.Globalization.NumberStyles.HexNumber);

                  return newByte;

            }

 

 

      }

}

 

Found more on software development stuff at MLS and DNS.

Silverlight, WCF and FaultContracts

As most Silverlight .NET developers who use WCF know, Silverlight doesn't support FaultContracts, and a 404 exception will be returned if the Services do throw an exception.

The way to fix this is create an encapsulating Interpreter class which is the default return value for all calls. You can then enapsulate resultant data in here and explicitly deal with an exception on the WCF side, by interpreting it and providing the exception in the resultant adapter.

A quick example is provided below:

[DataContract]
    public class Response
    {
  

        [DataMember]
        public bool BooleanResult { get; set; }

        [DataMember]
        public Exception Error { get; set; }

     }

    [DataContract]
    public class Exception
    {
        [DataMember(Order = 0)]
        public string Message { get; set; }
        [DataMember(Order = 1)]
        public CustomException InnerException;
        public Exception ToException()
        {
            Exception e;
            CustomException ce = this;
            if (ce.InnerException != null)
            {
                Exception inner = ce.InnerException.ToException();
                e = new Exception(ce.Message, inner);
            }
            else
                e = new Exception(ce.Message);
            return e;
        }
    }

So, an example of how to handle an exception in a services method would be:

       [OperationContract]
        public Response ProcessRequest(RequestData request)
        {
            return Process(request);
        }

    private Response Process(RequestData request) {


        Response result = new Response(); 
        try

        {
              //your operation
        }    

        catch (Exception ex)
         {

               //So error has been thrown so enapcsulate it properly and send it back
                while (ex.InnerException != null)
                    ex = ex.InnerException;
                result.Error = new Exception();
                result.Error.Message = ex.Message + ex.StackTrace;
         }
         return result; 
    }

I should be posting some software development source code examples of this on http://www.dotnutshell.co.uk/programming_-_silverlight_and_wcf_fault_contracts.show.126.aspx in the near future.

Software Development .NET and Cloud Computing

There are three ways of taking advantage of this idea of cloud computing: data completely in the cloud, local applications that utilize some data in the clouds with some local, and being your own cloud where you provide the local data from your device to a service.

With mobile devices now gaining better browsers, broadband-like speeds, and the services to tie these together, it's a good idea to take a look at the advantages and what is possible, with this is mind, we can create a Cloud for our own use. Expose its interfaces to different bindings and thus, build applications which reside online to access amd manipulate the data as well as on a local machine to modify the data, serialise it, then sync it whenever it has access to the Internet.

For this example, we will be using Silverlight 2.2 beta, WCF, WPF and POW (plain old wap).

You will need Visual Studio 2008 and the beta tools for Silverlight.

You can get at this tutorial and example source software development code at DOTNUTSHELL's website.

Software Development the DOTNUTSHELL way

DOTNUTSHELL provides well thought out software solutions to businesses. I work for DOTNUTSHELL aswell as Micro Librarian Systems as a senior software developer. My expertise ranges from the Linux world, embedded systems all the way up to Flash and Silverlight. I am an avid producer of software, working in new .NET Technologies incluidng Silverlight, WCF and WPF.