-
Notifications
You must be signed in to change notification settings - Fork 1
Usage
dotnetwise edited this page Mar 25, 2013
·
13 revisions
There are two files coming with this library.
_vs2012.intallisense.js and NamespacesAndEnumSupport.js
You only need to include NamespacesAndEnumSupport.js in your code if you want to use the utilities namespace, ns or Enum so you won't get a runtime error in your javascript.
- By using the
namespace(aliasns) method
namespace("MyApp.controllers") // defines MyApp.controllers nested namespaces in window
ns("mvvm.invoicing", MyApp) // defines MyApp.mvvm.invoicing namespaces by specifying where to store them
ns("a/b/c/d", window, "/") // defines namespaces a.b.c.d by using a custom separator- Your own manual code
window.MyApp = window.MyApp || {};
MyApp.__namespace = true;
MyApp.controllers = MyApp.controllers || {};
MyApp.__namespace = true;- By using the
Enumfunction
var countries = new Enum({Romania: 1, USA: 2, Germany: 3, Spain: 4, Netherlands: 5}) // defines an enum with some countries
var plants = new Enum({Flower: "flower", Tree: "tree", Cereal: "seed"}) // defines an enum with string values- Your own manual code
var countries = {Romania: 1, USA: 2, Germany: 3, Spain: 4, Netherlands: 5};
countries.__enum = true; // enables the enum glyphYou can set any of these on your objects/functions accordingly:
-

__namespace = true- makes an object to look like a namespace -

__class = true- makes an function to look like a class -

__enum = true- makes an object to look like an enum -

__interface = true- makes a function to look like an interface -

__map = true- makes an object to look like a dictionary -

__const = true- makes an object to look like a constant -

__event = true- makes an object to look like an event -

__delegate = true- makes a function to look like a delegate
Besides the explicit setting of the above options, following rules apply:
-
Anything named on****will be considered an event -
Anything named with an Uppercaseletter will be considered a Class - Fields will automatically be declared by their current value type i.e.
-

Number -

Boolean -

String -

RegExp -

null -

undefined -
Anything named constructoris always considered a Class -
Methods defined on Object.prototypehave specific glyph icon -
Methods defined on custom .prototypehave specific glyph icon (like an external method) -
Keyword prototypehas a specific glyph icon -
Any DOM elementwill be automatically detected and have specific glyph icon