Created
January 19, 2011 01:31
-
-
Save mgroves/785518 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; | |
| [Serializable] | |
| public sealed class LazyLoadAttribute : LocationInterceptionAspect | |
| { | |
| public override void OnGetValue(LocationInterceptionArgs args) | |
| { | |
| args.ProceedGetValue(); | |
| 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