Salient Solutions

wrasslin ones and nones for fun and profit - Sky Sanders' Blog
posts - 96, comments - 70, trackbacks - 0

August 2009 Entries

Patching json2.js - deep serialize

  There are times when you have an object that has been cloned and no longer 'owns' all of it's properties, but you want to serialize it with json2.js. function clone (object) { /// <summary> /// Creates a new Object with prototype = object. /// Protypal inheritance. /// </summary> /// <param name="object" type="Object"></param> /// <returns type="Object"></returns> function F() { } F.prototype = object; return new F; } The use case in point is a template object which I...

posted @ Thursday, August 27, 2009 1:33 PM | Feedback (0) |

Software Design Patterns - JavaScript

As an exercise in refreshing my GOF-FU, I began a little project implementing the GOF patterns in JavaScript. The app is a pattern browser that loads and executes the examples and displays the source and output in a tabbed editor. All 24 patterns are implemented/approximated with exemplars and sample implementations. The supporting content is still a bit sparse but I do provide links to content. You can find it at http://skysanders.net/jspatterns

posted @ Tuesday, August 25, 2009 4:21 AM | Feedback (0) |

JsUnitTest-VS

I have forked JsUnitTest over at github into JsUnitTest-VS in the interest of creating a Visual Studio 2008 friendly JavaScript unit testing framework. The fork, new name and versioning are prompted by the fact that the infrastructure of the project is php/ruby oriented. I am not only NOT really inclined to switch my development paradigm to PHP/RUBY to work on a library that is intended for Visual Studio, I have identified various areas in which I intend to make fairly significant changes to the feature set. Reconciliation can be considered at a later date. That said, I intend to maintain full API compatibility to keep...

posted @ Thursday, August 20, 2009 10:58 AM | Feedback (0) |

JsUnitTest Async Test Pattern

Lately I have been using a lightweight JavaScript testing framework called JsUnitTest. It is quite easy to use but the documentation is non-existent. This is a situation I have begun to remedy by vs-doccing my copy. I may post it soon. In any case, my cursory investigation did not uncover an established async pattern so I wrote a song about it. Wanna hear it? Here it goes........ Listing 1: jsunittest async pattern  /* Jsunittest async runner pattern by Sky Sanders http://skysanders.net/subtext/archive/2009/08/19/jsunittest-async-test-pattern.aspx This pattern enhances standard test runs with the ability to 'pause' the run until the currently running case signals completion. If...

posted @ Wednesday, August 19, 2009 10:41 PM | Feedback (0) |

A Better JavaScript Generic Type Implementation

download source code download this article in .doc format. Overview In a recent article I presented a simple implementation of a generic type system in JavaScript. Please see that document for a detailed enumeration of the motivations and benefits, including type safetly and Visual Studio intellisense support. In this document I will present a 'better' implementation that eliminates many of the limitations of my 'simple' generic type implementation. I will also provide a starter library of generic compatible collections including Queue, ListArray and Dictionary that you may use immediately and that can serve as a reference for implementing your own generic types in JavaScript. Features: ...

posted @ Wednesday, August 19, 2009 5:40 PM | Feedback (1) |

Salient.Web.Security.AccessControlModule

download source code and demo download this article in .doc format Overview I a previous article I complained about the lack of a true 403 Forbidden error in ASP.NET and the clumsy way that authentication is handled by FormsAuthenticationModule. The solution I came up with was a good first attempt but, in my opinion, came up short. Particularly when handling authentication of requests that ScriptModule touches. So I decided to take another swing at it, this time with some ammunition. I took the list of HttpModules from the root Web.config and the ScriptModule that is added to ASP.NET 3.5 web apps and dove in with...

posted @ Monday, August 17, 2009 10:18 PM | Feedback (1) |

Lesser known .NET Logging frameworks

This is just a list of some of the lesser known logging frameworks that I have found to be useful, each in their own way. I will elucidate at a later date, mate, but they are all great. Elmah Ukadc.Diagnostics

posted @ Sunday, August 16, 2009 12:17 PM | Feedback (0) |

Exploring Web.config - system.web/httpModules

download this document in .doc form HttpApplication Events, the HttpModules that handle them and in what order: It is a generally held opinion that to depend upon the order of module/event execution is bad practice and produces brittle code.  I agree somewhat with the spirit of the opinion but not at all with the explicit reason. Events and Collections are not magic bags that arbitrarily insert handlers/items in some random order. I think, in a general sense, that to depend on event handler execution order is a 'bad idea' is valid. In a more specific context, in which the enviroment is known and...

posted @ Sunday, August 16, 2009 11:31 AM | Feedback (2) |

Consuming ASP.net WebServices, WCF Services and static Page methods from JavaScript (sans MS AJAX)

download sample code Overview The Microsoft ASP.NET AJAX platform, known previously as ATLAS and ASP.NET 2.0 AJAX Extensions and fully rolled into ASP.NET 3.5, offers rich functionality but in certain scenarios the the required .ASPX client page and ScriptManager control coupled with the Microsoft Ajax library may conflict with existing requirements or present unnecessary overhead. This document will illustrate that it is possible to leverage the full power of the ASP.NET platform from client script with just a few lines of javascript code on an HTML page. Caveats: This document will not attempt to illustrate a robust...

posted @ Saturday, August 15, 2009 11:04 AM | Feedback (5) |

Nugget: Running ASMX Web Services on STA Threads

An old MSDN mag article with a cool hack for running COM components in a web service context.  If you are scratching your head then consider yourself lucky and move on, these are not the bits you are looking for. If you have been pulling your hair out then go to http://msdn.microsoft.com/en-us/magazine/cc163544.aspx  

posted @ Friday, August 14, 2009 10:41 PM | Feedback (0) |

A simple JavaScript generic type pattern implementation

source and demo What are 'generic types'? A generic type is defined using one or more type variables and has one or more methods that use a type variable as a placeholder for an argument or return type. For example, the type java.util.List<E> is a generic type: a list that holds elements of some type represented by the placeholder E. This type has a method named add(), declared to take an argument of type E, and a method named get(), declared to return a value of type E. source Why attempt this in JavaScript? My answer is two-fold. Primarily for type safety. While the...

posted @ Tuesday, August 11, 2009 12:43 PM | Feedback (0) |

Controlling ASP.Net Login Redirects with HTTPModule

    An issue that has been common for me is the way that ASP.Net FormsAuthenticationModule handles login redirection and the opaque nature of the mechanism itself.  Any authentication failure, 401 Unauthorized, e.g. not logged in, and 403 Forbidden, e.g. logged in but no permissions, are both unquestionably redirected to the the login page specified in the forms element. While this behavior regarding the 401 is expected, I have always taken issue with the 403 redirect. It is confusing and counterproductive. The user is already logged in and it has been determined that they do not have appropriate permissions to access the resource. ...

posted @ Monday, August 10, 2009 2:03 PM | Feedback (0) |

Powered by: