Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

prefixing privat members with '_' to improve intellisense result

  • Loading branch information...
commit b25674c2a2fa8b025ea2c674c443cd5c7458a25f 1 parent 089c727
@fschwiet authored
View
6 Intellisense.js
@@ -2,5 +2,7 @@
/// <reference path="build/JsfIoc.testutil.js" />
-// not sure why, but this helps the intellisense:
-new JsfIoc().Register().withConstructor().asSingleton().asSingleton();
+// not sure why, but including this helps the intellisense:
+new JsfIoc().Register().withConstructor().asSingleton().withDependencies(new JsfIoc().Parameter().asSingleJQueryElement().withValidator().withDefault());
+
+
View
76 build/JsfIoc.js
@@ -30,8 +30,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
function BindingStart(ioc, name) {
- this.container = ioc;
- this.name = name;
+ this._container = ioc;
+ this._name = name;
ExtendAsFluent.PrototypeOf(BindingStart);
}
@@ -49,10 +49,10 @@ BindingStart.prototype = {
/// </param>
/// <returns type="Binding" />
- var binding = new Binding(this.name);
+ var binding = new Binding(this._name);
binding.service = value;
- this.container.RegBinding(binding);
+ this._container.RegBinding(binding);
return binding;
},
@@ -65,18 +65,18 @@ BindingStart.prototype = {
/// An instance of the component
/// </param>
- this.container.RegisterInstance(this.name, value);
+ this._container.RegisterInstance(this._name, value);
}
}
function Binding(name) {
- this.name = name;
- this.requires = [];
- this.parameters = [];
- this.singleton = false;
- this.eventSource = [];
- this.eventListener = [];
+ this._name = name;
+ this._requires = [];
+ this._parameters = [];
+ this._singleton = false;
+ this._eventSource = [];
+ this._eventListener = [];
ExtendAsFluent.PrototypeOf(Binding);
}
@@ -86,33 +86,33 @@ Binding.prototype = {
withDependencies: function() {
/// <returns type="Binding" />
- Binding.AppendArgsToMember(arguments, this, "requires");
+ Binding.AppendArgsToMember(arguments, this, "_requires");
},
withParameters: function() {
/// <returns type="Binding" />
- Binding.AppendArgsToMember(arguments, this, "parameters");
+ Binding.AppendArgsToMember(arguments, this, "_parameters");
- for (var i = 0; i < this.parameters.length; i++) {
- if (typeof this.parameters[i] == "string") {
- this.parameters[i] = JsfIoc.prototype.Parameter(this.parameters[i]);
+ for (var i = 0; i < this._parameters.length; i++) {
+ if (typeof this._parameters[i] == "string") {
+ this._parameters[i] = JsfIoc.prototype.Parameter(this._parameters[i]);
}
}
},
asSingleton: function() {
/// <returns type="Binding" />
- this.singleton = true;
+ this._singleton = true;
},
sendingEvents: function() {
/// <returns type="Binding" />
- Binding.AppendArgsToMember(arguments, this, "eventSource");
+ Binding.AppendArgsToMember(arguments, this, "_eventSource");
},
receivingEvents: function() {
/// <returns type="Binding" />
- Binding.AppendArgsToMember(arguments, this, "eventListener");
+ Binding.AppendArgsToMember(arguments, this, "_eventListener");
},
GetFriendlyName: function () {
@@ -124,7 +124,7 @@ Binding.prototype = {
result = result.slice("function ".length);
if (Binding.WhitespaceRegex.test(result))
- return this.name;
+ return this._name;
return result;
}
@@ -188,7 +188,7 @@ JsfIoc.prototype = {
},
RegBinding: function (binding) {
- this._bindings[binding.name] = binding;
+ this._bindings[binding._name] = binding;
},
RegisterInstance: function (name, instance) {
@@ -207,15 +207,15 @@ JsfIoc.prototype = {
result = new binding.service;
- for (var i = 0; i < binding.requires.length; i++) {
- var dependency = binding.requires[i];
+ for (var i = 0; i < binding._requires.length; i++) {
+ var dependency = binding._requires[i];
result[dependency] = this.Load(dependency);
}
if (binding.boundParameters) {
- for (var i = 0; i < binding.parameters.length; i++) {
- var parameter = binding.parameters[i];
- result[parameter.name] = binding.boundParameters[parameter.name];
+ for (var i = 0; i < binding._parameters.length; i++) {
+ var parameter = binding._parameters[i];
+ result[parameter._name] = binding.boundParameters[parameter._name];
}
}
else {
@@ -224,17 +224,17 @@ JsfIoc.prototype = {
this._SetParametersToObject(binding, result, values)
}
- for (var i = 0; i < binding.eventSource.length; i++) {
+ for (var i = 0; i < binding._eventSource.length; i++) {
(function (event, that) {
result["_notify" + event] = function () {
that.NotifyEvent(event, arguments);
};
- })(binding.eventSource[i], this);
+ })(binding._eventSource[i], this);
}
- if (binding.singleton) {
+ if (binding._singleton) {
this._singletons[name] = result;
}
@@ -246,8 +246,8 @@ JsfIoc.prototype = {
var boundParameters = {};
- for (var i = 0; i < binding.parameters.length; i++) {
- this._SetParameterToObject(binding, binding.parameters[i], boundParameters, arguments[1 + i], i);
+ for (var i = 0; i < binding._parameters.length; i++) {
+ this._SetParameterToObject(binding, binding._parameters[i], boundParameters, arguments[1 + i], i);
}
binding.boundParameters = boundParameters;
@@ -269,7 +269,7 @@ JsfIoc.prototype = {
if (!this._bindings.hasOwnProperty(bindingName))
continue;
- var events = this._bindings[bindingName].eventListener;
+ var events = this._bindings[bindingName]._eventListener;
if (events) {
@@ -286,28 +286,28 @@ JsfIoc.prototype = {
}
},
_SetParametersToObject: function(binding, target, values) {
- for (var i = 0; i < binding.parameters.length; i++) {
- this._SetParameterToObject(binding, binding.parameters[i], target, values[i], i);
+ for (var i = 0; i < binding._parameters.length; i++) {
+ this._SetParameterToObject(binding, binding._parameters[i], target, values[i], i);
}
},
_SetParameterToObject: function (binding, parameter, target, value, index) {
if (!parameter.validator(value)) {
- throw new Error("Invalid parameter #" + (index + 1) + " passed to " + binding.name + ".");
+ throw new Error("Invalid parameter #" + (index + 1) + " passed to " + binding._name + ".");
}
if (typeof(value) === "undefined") {
if (typeof(parameter.defaultValue) !== "undefined") {
- target[parameter.name] = parameter.defaultValue;
+ target[parameter._name] = parameter.defaultValue;
}
} else {
- target[parameter.name] = value;
+ target[parameter._name] = value;
}
}
};
function JsfParameter(name) {
- this.name = name;
+ this._name = name;
this.validator = function () { return true; };
ExtendAsFluent.PrototypeOf(JsfParameter);
View
36 build/JsfIoc.testutil.js
@@ -66,11 +66,11 @@ DependencyGrapher.prototype = {
var binding = bindings[name];
- if (binding && binding.requires) {
- for (var i = 0; i < binding.requires.length; i++) {
+ if (binding && binding._requires) {
+ for (var i = 0; i < binding._requires.length; i++) {
for (var j = 0; j < servicesLeft.length; j++) {
- if (servicesLeft[j] == binding.requires[i]) {
+ if (servicesLeft[j] == binding._requires[i]) {
servicesLeft.splice(j, 1);
break;
}
@@ -97,7 +97,7 @@ DependencyGrapher.prototype = {
if (binding) {
- var requires = binding.requires;
+ var requires = binding._requires;
if (requires) for (var i = 0; i < requires.length; i++) {
@@ -152,8 +152,8 @@ DependencyGrapher.prototype = {
var requires = [];
- if (nodeBinding && nodeBinding.requires) {
- requires = nodeBinding.requires.slice(0);
+ if (nodeBinding && nodeBinding._requires) {
+ requires = nodeBinding._requires.slice(0);
}
this.VisitDependencies(visitor, requires, node, depth + 1);
@@ -208,9 +208,9 @@ FakeJsfIoc.prototype = {
var result = new binding.service;
dependencyLoadingLoop:
- for (var i = 0; i < binding.requires.length; i++) {
+ for (var i = 0; i < binding._requires.length; i++) {
- var dependency = binding.requires[i];
+ var dependency = binding._requires[i];
for (var includeIndex = 0; includeIndex < this._includedServices.length; includeIndex++) {
if (dependency == this._includedServices[includeIndex]) {
@@ -226,10 +226,10 @@ FakeJsfIoc.prototype = {
this._ioc._SetParametersToObject(binding, result, parameterValues);
- for (var i = 0; i < binding.eventSource.length; i++) {
+ for (var i = 0; i < binding._eventSource.length; i++) {
- result["_notify" + binding.eventSource[i]] =
- this.TestDoublePolicy(binding.GetFriendlyName(), "_notify" + binding.eventSource[i]);
+ result["_notify" + binding._eventSource[i]] =
+ this.TestDoublePolicy(binding.GetFriendlyName(), "_notify" + binding._eventSource[i]);
}
return result;
@@ -247,7 +247,7 @@ FakeJsfIoc.prototype = {
var service = nameOrService;
- name = this.GetBindingByClass(service).name;
+ name = this.GetBindingByClass(service)._name;
}
if (this._preloadedDependencies[name]) {
@@ -368,10 +368,10 @@ GraphVizFormatting.prototype = {
var eventListenerString = "";
- if (binding.eventListener.length > 0) {
+ if (binding._eventListener.length > 0) {
eventListenerString = " | \\>";
- var events = binding.eventListener.slice();
+ var events = binding._eventListener.slice();
events.sort();
@@ -386,10 +386,10 @@ GraphVizFormatting.prototype = {
var eventSourceString = "";
- if (binding.eventSource.length > 0) {
+ if (binding._eventSource.length > 0) {
eventSourceString = " |";
- var events = binding.eventSource.slice();
+ var events = binding._eventSource.slice();
events.sort();
@@ -406,9 +406,9 @@ GraphVizFormatting.prototype = {
var relationString = "";
- for (var i = 0; i < binding.requires.length; i++) {
+ for (var i = 0; i < binding._requires.length; i++) {
- var targetName = binding.requires[i];
+ var targetName = binding._requires[i];
if (this._ioc._bindings[targetName]) {
targetName = this._ioc._bindings[targetName].GetFriendlyName();
View
40 src/Binding.js
@@ -2,8 +2,8 @@
function BindingStart(ioc, name) {
- this.container = ioc;
- this.name = name;
+ this._container = ioc;
+ this._name = name;
ExtendAsFluent.PrototypeOf(BindingStart);
}
@@ -21,10 +21,10 @@ BindingStart.prototype = {
/// </param>
/// <returns type="Binding" />
- var binding = new Binding(this.name);
+ var binding = new Binding(this._name);
binding.service = value;
- this.container.RegBinding(binding);
+ this._container.RegBinding(binding);
return binding;
},
@@ -37,18 +37,18 @@ BindingStart.prototype = {
/// An instance of the component
/// </param>
- this.container.RegisterInstance(this.name, value);
+ this._container.RegisterInstance(this._name, value);
}
}
function Binding(name) {
- this.name = name;
- this.requires = [];
- this.parameters = [];
- this.singleton = false;
- this.eventSource = [];
- this.eventListener = [];
+ this._name = name;
+ this._requires = [];
+ this._parameters = [];
+ this._singleton = false;
+ this._eventSource = [];
+ this._eventListener = [];
ExtendAsFluent.PrototypeOf(Binding);
}
@@ -58,33 +58,33 @@ Binding.prototype = {
withDependencies: function() {
/// <returns type="Binding" />
- Binding.AppendArgsToMember(arguments, this, "requires");
+ Binding.AppendArgsToMember(arguments, this, "_requires");
},
withParameters: function() {
/// <returns type="Binding" />
- Binding.AppendArgsToMember(arguments, this, "parameters");
+ Binding.AppendArgsToMember(arguments, this, "_parameters");
- for (var i = 0; i < this.parameters.length; i++) {
- if (typeof this.parameters[i] == "string") {
- this.parameters[i] = JsfIoc.prototype.Parameter(this.parameters[i]);
+ for (var i = 0; i < this._parameters.length; i++) {
+ if (typeof this._parameters[i] == "string") {
+ this._parameters[i] = JsfIoc.prototype.Parameter(this._parameters[i]);
}
}
},
asSingleton: function() {
/// <returns type="Binding" />
- this.singleton = true;
+ this._singleton = true;
},
sendingEvents: function() {
/// <returns type="Binding" />
- Binding.AppendArgsToMember(arguments, this, "eventSource");
+ Binding.AppendArgsToMember(arguments, this, "_eventSource");
},
receivingEvents: function() {
/// <returns type="Binding" />
- Binding.AppendArgsToMember(arguments, this, "eventListener");
+ Binding.AppendArgsToMember(arguments, this, "_eventListener");
},
GetFriendlyName: function () {
@@ -96,7 +96,7 @@ Binding.prototype = {
result = result.slice("function ".length);
if (Binding.WhitespaceRegex.test(result))
- return this.name;
+ return this._name;
return result;
}
View
16 src/Binding.tests.js
@@ -16,7 +16,7 @@ describe("BindingStart", function () {
var sut = new BindingStart(ioc, "someServiceName");
- expect(sut.name).toEqual("someServiceName");
+ expect(sut._name).toEqual("someServiceName");
});
it("has a fluent interface", function () {
@@ -33,7 +33,7 @@ describe("BindingStart", function () {
var binding = new BindingStart(ioc, "someServiceName").withConstructor(Foo);
expect(ioc.RegBinding).toHaveBeenCalledWith(binding);
- expect(binding.name).toEqual("someServiceName");
+ expect(binding._name).toEqual("someServiceName");
expect(binding.service).toEqual(Foo);
});
@@ -59,7 +59,7 @@ describe("Binding", function () {
var binding = new Binding("serviceName");
- expect(binding.name).toEqual("serviceName");
+ expect(binding._name).toEqual("serviceName");
});
it("has a fluent interface", function () {
@@ -73,35 +73,35 @@ describe("Binding", function () {
var binding = new Binding("serviceName").withDependencies(1, 2, 3);
- expect(binding.requires).toEqual([1, 2, 3]);
+ expect(binding._requires).toEqual([1, 2, 3]);
});
it("can specify parameters", function () {
var binding = new Binding("serviceName").withParameters(1, 2, 3);
- expect(binding.parameters).toEqual([1, 2, 3]);
+ expect(binding._parameters).toEqual([1, 2, 3]);
});
it("can load component as a singleton", function () {
var binding = new Binding("serviceName").asSingleton();
- expect(binding.singleton).toEqual(true);
+ expect(binding._singleton).toEqual(true);
});
it("can specify events sourced from this component", function () {
var binding = new Binding("serviceName").sendingEvents(1, 2, 3);
- expect(binding.eventSource).toEqual([1, 2, 3]);
+ expect(binding._eventSource).toEqual([1, 2, 3]);
})
it("can specify events received by this component", function () {
var binding = new Binding("serviceName").receivingEvents(1, 2, 3);
- expect(binding.eventListener).toEqual([1, 2, 3]);
+ expect(binding._eventListener).toEqual([1, 2, 3]);
})
describe("has a friendly name", function () {
View
36 src/JsfIoc.js
@@ -13,7 +13,7 @@ JsfIoc.prototype = {
},
RegBinding: function (binding) {
- this._bindings[binding.name] = binding;
+ this._bindings[binding._name] = binding;
},
RegisterInstance: function (name, instance) {
@@ -32,15 +32,15 @@ JsfIoc.prototype = {
result = new binding.service;
- for (var i = 0; i < binding.requires.length; i++) {
- var dependency = binding.requires[i];
+ for (var i = 0; i < binding._requires.length; i++) {
+ var dependency = binding._requires[i];
result[dependency] = this.Load(dependency);
}
if (binding.boundParameters) {
- for (var i = 0; i < binding.parameters.length; i++) {
- var parameter = binding.parameters[i];
- result[parameter.name] = binding.boundParameters[parameter.name];
+ for (var i = 0; i < binding._parameters.length; i++) {
+ var parameter = binding._parameters[i];
+ result[parameter._name] = binding.boundParameters[parameter._name];
}
}
else {
@@ -49,17 +49,17 @@ JsfIoc.prototype = {
this._SetParametersToObject(binding, result, values)
}
- for (var i = 0; i < binding.eventSource.length; i++) {
+ for (var i = 0; i < binding._eventSource.length; i++) {
(function (event, that) {
result["_notify" + event] = function () {
that.NotifyEvent(event, arguments);
};
- })(binding.eventSource[i], this);
+ })(binding._eventSource[i], this);
}
- if (binding.singleton) {
+ if (binding._singleton) {
this._singletons[name] = result;
}
@@ -71,8 +71,8 @@ JsfIoc.prototype = {
var boundParameters = {};
- for (var i = 0; i < binding.parameters.length; i++) {
- this._SetParameterToObject(binding, binding.parameters[i], boundParameters, arguments[1 + i], i);
+ for (var i = 0; i < binding._parameters.length; i++) {
+ this._SetParameterToObject(binding, binding._parameters[i], boundParameters, arguments[1 + i], i);
}
binding.boundParameters = boundParameters;
@@ -94,7 +94,7 @@ JsfIoc.prototype = {
if (!this._bindings.hasOwnProperty(bindingName))
continue;
- var events = this._bindings[bindingName].eventListener;
+ var events = this._bindings[bindingName]._eventListener;
if (events) {
@@ -111,28 +111,28 @@ JsfIoc.prototype = {
}
},
_SetParametersToObject: function(binding, target, values) {
- for (var i = 0; i < binding.parameters.length; i++) {
- this._SetParameterToObject(binding, binding.parameters[i], target, values[i], i);
+ for (var i = 0; i < binding._parameters.length; i++) {
+ this._SetParameterToObject(binding, binding._parameters[i], target, values[i], i);
}
},
_SetParameterToObject: function (binding, parameter, target, value, index) {
if (!parameter.validator(value)) {
- throw new Error("Invalid parameter #" + (index + 1) + " passed to " + binding.name + ".");
+ throw new Error("Invalid parameter #" + (index + 1) + " passed to " + binding._name + ".");
}
if (typeof(value) === "undefined") {
if (typeof(parameter.defaultValue) !== "undefined") {
- target[parameter.name] = parameter.defaultValue;
+ target[parameter._name] = parameter.defaultValue;
}
} else {
- target[parameter.name] = value;
+ target[parameter._name] = value;
}
}
};
function JsfParameter(name) {
- this.name = name;
+ this._name = name;
this.validator = function () { return true; };
ExtendAsFluent.PrototypeOf(JsfParameter);
View
12 testutil/DependencyGraphing.js
@@ -38,11 +38,11 @@ DependencyGrapher.prototype = {
var binding = bindings[name];
- if (binding && binding.requires) {
- for (var i = 0; i < binding.requires.length; i++) {
+ if (binding && binding._requires) {
+ for (var i = 0; i < binding._requires.length; i++) {
for (var j = 0; j < servicesLeft.length; j++) {
- if (servicesLeft[j] == binding.requires[i]) {
+ if (servicesLeft[j] == binding._requires[i]) {
servicesLeft.splice(j, 1);
break;
}
@@ -69,7 +69,7 @@ DependencyGrapher.prototype = {
if (binding) {
- var requires = binding.requires;
+ var requires = binding._requires;
if (requires) for (var i = 0; i < requires.length; i++) {
@@ -124,8 +124,8 @@ DependencyGrapher.prototype = {
var requires = [];
- if (nodeBinding && nodeBinding.requires) {
- requires = nodeBinding.requires.slice(0);
+ if (nodeBinding && nodeBinding._requires) {
+ requires = nodeBinding._requires.slice(0);
}
this.VisitDependencies(visitor, requires, node, depth + 1);
View
12 testutil/FakeJsfIoc.js
@@ -34,9 +34,9 @@ FakeJsfIoc.prototype = {
var result = new binding.service;
dependencyLoadingLoop:
- for (var i = 0; i < binding.requires.length; i++) {
+ for (var i = 0; i < binding._requires.length; i++) {
- var dependency = binding.requires[i];
+ var dependency = binding._requires[i];
for (var includeIndex = 0; includeIndex < this._includedServices.length; includeIndex++) {
if (dependency == this._includedServices[includeIndex]) {
@@ -52,10 +52,10 @@ FakeJsfIoc.prototype = {
this._ioc._SetParametersToObject(binding, result, parameterValues);
- for (var i = 0; i < binding.eventSource.length; i++) {
+ for (var i = 0; i < binding._eventSource.length; i++) {
- result["_notify" + binding.eventSource[i]] =
- this.TestDoublePolicy(binding.GetFriendlyName(), "_notify" + binding.eventSource[i]);
+ result["_notify" + binding._eventSource[i]] =
+ this.TestDoublePolicy(binding.GetFriendlyName(), "_notify" + binding._eventSource[i]);
}
return result;
@@ -73,7 +73,7 @@ FakeJsfIoc.prototype = {
var service = nameOrService;
- name = this.GetBindingByClass(service).name;
+ name = this.GetBindingByClass(service)._name;
}
if (this._preloadedDependencies[name]) {
View
12 testutil/GraphVizFormatting.js
@@ -18,10 +18,10 @@ GraphVizFormatting.prototype = {
var eventListenerString = "";
- if (binding.eventListener.length > 0) {
+ if (binding._eventListener.length > 0) {
eventListenerString = " | \\>";
- var events = binding.eventListener.slice();
+ var events = binding._eventListener.slice();
events.sort();
@@ -36,10 +36,10 @@ GraphVizFormatting.prototype = {
var eventSourceString = "";
- if (binding.eventSource.length > 0) {
+ if (binding._eventSource.length > 0) {
eventSourceString = " |";
- var events = binding.eventSource.slice();
+ var events = binding._eventSource.slice();
events.sort();
@@ -56,9 +56,9 @@ GraphVizFormatting.prototype = {
var relationString = "";
- for (var i = 0; i < binding.requires.length; i++) {
+ for (var i = 0; i < binding._requires.length; i++) {
- var targetName = binding.requires[i];
+ var targetName = binding._requires[i];
if (this._ioc._bindings[targetName]) {
targetName = this._ioc._bindings[targetName].GetFriendlyName();
Please sign in to comment.
Something went wrong with that request. Please try again.