Permalink
Browse files

Turned the InjectionResultFactory class into a factory method in Inje…

…ctionConfig, added license headers to all IInjectionResult classes, slight formatting changes
  • Loading branch information...
tschneidereit committed Nov 12, 2009
1 parent 90048f0 commit faaa355a11d0800378ac811967374d61a307dfc9
@@ -1 +1,2 @@
-/** Copyright (c) 2009 the original author or authors** Permission is hereby granted, free of charge, to any person obtaining a copy* of this software and associated documentation files (the "Software"), to deal* in the Software without restriction, including without limitation the rights* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell* copies of the Software, and to permit persons to whom the Software is* furnished to do so, subject to the following conditions:** The above copyright notice and this permission notice shall be included in* all copies or substantial portions of the Software.** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN* THE SOFTWARE.*/package org.swiftsuspenders{ import flash.utils.Dictionary; import org.swiftsuspenders.injectionresults.IInjectionResult; /** * @author tschneidereit */ public class InjectionConfig { /******************************************************************************************* * public properties * *******************************************************************************************/ public var request : Class; public var response : Object; public var injectionType : int; public var injectionName : String; /******************************************************************************************* * public methods * *******************************************************************************************/ public function InjectionConfig(request : Class, response : Object, injectionType : int, injectionName : String) { this.request = request; this.response = response; this.injectionType = injectionType; this.injectionName = injectionName; } public function getResponse(injector : Injector, singletons : Dictionary) : Object { var resultFactory:InjectionResultFactory = new InjectionResultFactory(this); var result:IInjectionResult = resultFactory.getResult(); return result.getResponse( injector, singletons ); } }}
+/** Copyright (c) 2009 the original author or authors** Permission is hereby granted, free of charge, to any person obtaining a copy* of this software and associated documentation files (the "Software"), to deal* in the Software without restriction, including without limitation the rights* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell* copies of the Software, and to permit persons to whom the Software is* furnished to do so, subject to the following conditions:** The above copyright notice and this permission notice shall be included in* all copies or substantial portions of the Software.** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN* THE SOFTWARE.*/package org.swiftsuspenders{ import flash.utils.Dictionary; import org.swiftsuspenders.injectionresults.IInjectionResult; import org.swiftsuspenders.injectionresults.InjectClassResult; import org.swiftsuspenders.injectionresults.InjectNullResult; import org.swiftsuspenders.injectionresults.InjectSingletonResult; import org.swiftsuspenders.injectionresults.InjectValueResult;
+ public class InjectionConfig { /******************************************************************************************* * public properties * *******************************************************************************************/ public var request : Class; public var response : Object; public var injectionType : int; public var injectionName : String; /******************************************************************************************* * public methods * *******************************************************************************************/ public function InjectionConfig(request : Class, response : Object, injectionType : int, injectionName : String) { this.request = request; this.response = response; this.injectionType = injectionType; this.injectionName = injectionName; } public function getResponse(injector : Injector, singletons : Dictionary) : Object { return createResultByInjectionType().getResponse(injector, singletons); } /******************************************************************************************* * private methods * *******************************************************************************************/ private function createResultByInjectionType() : IInjectionResult { switch (injectionType) { case InjectionType.CLASS: { return new InjectClassResult(this); } case InjectionType.VALUE: { return new InjectValueResult(this); } case InjectionType.SINGLETON: { return new InjectSingletonResult(this); } default: { break; } } return new InjectNullResult(); } }}
@@ -1,34 +0,0 @@
-package org.swiftsuspenders
-{
- import org.swiftsuspenders.injectionresults.IInjectionResult;
- import org.swiftsuspenders.injectionresults.InjectNullResult;
- import org.swiftsuspenders.injectionresults.InjectClassResult;
- import org.swiftsuspenders.injectionresults.InjectSingletonResult;
- import org.swiftsuspenders.injectionresults.InjectValueResult;
-
- public class InjectionResultFactory
- {
- private var injectionConfig:InjectionConfig;
-
- public function InjectionResultFactory(injectionConfig:InjectionConfig)
- {
- this.injectionConfig = injectionConfig;
- }
-
- public function getResult():IInjectionResult
- {
- switch(injectionConfig.injectionType)
- {
- case InjectionType.CLASS:
- return new InjectClassResult(injectionConfig);
- case InjectionType.VALUE:
- return new InjectValueResult(injectionConfig);
- case InjectionType.SINGLETON:
- return new InjectSingletonResult(injectionConfig);
- default:break;
- }
-
- return new InjectNullResult();
- }
- }
-}
@@ -1,3 +1,25 @@
+/*
+* Copyright (c) 2009 the original author or authors
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
package org.swiftsuspenders
{
public class InjectionType
@@ -1,3 +1,25 @@
+/*
+* Copyright (c) 2009 the original author or authors
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
package org.swiftsuspenders.injectionresults
{
import flash.utils.Dictionary;
@@ -1,3 +1,25 @@
+/*
+* Copyright (c) 2009 the original author or authors
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
package org.swiftsuspenders.injectionresults
{
import flash.utils.Dictionary;
@@ -7,8 +29,15 @@ package org.swiftsuspenders.injectionresults
public class InjectClassResult implements IInjectionResult
{
+ /*******************************************************************************************
+ * private properties *
+ *******************************************************************************************/
private var config:InjectionConfig;
+
+ /*******************************************************************************************
+ * public methods *
+ *******************************************************************************************/
public function InjectClassResult(config:InjectionConfig)
{
this.config = config;
@@ -1,3 +1,25 @@
+/*
+* Copyright (c) 2009 the original author or authors
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
package org.swiftsuspenders.injectionresults
{
import flash.utils.Dictionary;
@@ -6,10 +28,6 @@ package org.swiftsuspenders.injectionresults
public class InjectNullResult implements IInjectionResult
{
- public function InjectNullResult()
- {
- }
-
public function getResponse(injector : Injector, singletons : Dictionary) : Object
{
return {};
@@ -1,3 +1,25 @@
+/*
+* Copyright (c) 2009 the original author or authors
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
package org.swiftsuspenders.injectionresults
{
import flash.utils.Dictionary;
@@ -7,9 +29,16 @@ package org.swiftsuspenders.injectionresults
public class InjectSingletonResult implements IInjectionResult
{
+ /*******************************************************************************************
+ * private properties *
+ *******************************************************************************************/
private var config:InjectionConfig;
private var singletons:Dictionary;
+
+ /*******************************************************************************************
+ * public methods *
+ *******************************************************************************************/
public function InjectSingletonResult(config:InjectionConfig)
{
this.config = config;
@@ -32,7 +61,11 @@ package org.swiftsuspenders.injectionresults
return result;
}
- protected function updateSingletonsMap():Dictionary
+
+ /*******************************************************************************************
+ * private methods *
+ *******************************************************************************************/
+ private function updateSingletonsMap():Dictionary
{
var usedSingletonsMap:Dictionary = singletons[config.injectionName];
if (!usedSingletonsMap)
@@ -1,3 +1,25 @@
+/*
+* Copyright (c) 2009 the original author or authors
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
package org.swiftsuspenders.injectionresults
{
import flash.utils.Dictionary;
@@ -7,8 +29,15 @@ package org.swiftsuspenders.injectionresults
public class InjectValueResult implements IInjectionResult
{
+ /*******************************************************************************************
+ * private properties *
+ *******************************************************************************************/
private var config:InjectionConfig;
+
+ /*******************************************************************************************
+ * public methods *
+ *******************************************************************************************/
public function InjectValueResult(config:InjectionConfig)
{
this.config = config;

0 comments on commit faaa355

Please sign in to comment.