Created
January 18, 2011 05:12
-
-
Save mgroves/784015 to your computer and use it in GitHub Desktop.
Lazy load 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [LazyLoad] private IProductRepository _productRepository; | |
| public class LazyLoadAttribute : LocationInterceptionAspect | |
| { | |
| public override void OnGetValue(LocationInterceptionArgs args) | |
| { | |
| if (args.Value == null) | |
| { | |
| var locationType = args.Location.LocationType; | |
| var instantiation = ObjectFactory.GetInstance(locationType); | |
| if (instantiation != null) | |
| { | |
| args.SetNewValue(instantiation); | |
| } | |
| } | |
| args.ProceedGetValue(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment