CSLA.NET 6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
AsyncLoader.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="AsyncLoader.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>no summary</summary>
7//-----------------------------------------------------------------------
8using System;
9using System.Collections.Generic;
10using System.ComponentModel;
11using System.Linq;
12using System.Text;
13using System.Reflection;
14using System.Threading.Tasks;
15using Csla.Server;
16
18{
23 internal class AsyncLoader<T> : IAsyncLoader
24 {
25 private readonly IPropertyInfo _property;
26 private readonly Delegate _factory;
27 private readonly object[] _parameters;
28
29 public IPropertyInfo Property
30 {
31 get { return _property; }
32 }
33
34 public AsyncLoader(
35 IPropertyInfo property,
36 Delegate factory,
37 params object[] parameters)
38 {
39 _property = property;
40 _factory = factory;
41 _parameters = parameters;
42 }
43
44 public void Load(Action<IAsyncLoader, IDataPortalResult> callback)
45 {
46 var parameters = new List<object>();
47 if (_parameters.Any())
48 parameters.Add(_parameters.First());
49
50 var myCallback = new EventHandler<DataPortalResult<T>>((sender, result) => callback(this, result));
51 parameters.Add(myCallback);
52 _factory.DynamicInvoke(parameters.ToArray());
53 }
54 }
55}
Maintains metadata about a property.