CSLA.NET 5.4.2
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
ServiceClientManager.cs
Go to the documentation of this file.
1#if !NETFX_PHONE && !NETCORE && !NETSTANDARD2_0 && !NET5_0
2//-----------------------------------------------------------------------
3// <copyright file="ServiceClientManager.cs" company="Marimer LLC">
4// Copyright (c) Marimer LLC. All rights reserved.
5// Website: https://cslanet.com
6// </copyright>
7// <summary>Provides an automated way to reuse </summary>
8//-----------------------------------------------------------------------
9using System;
10
11namespace Csla.Data
12{
24 public class ServiceClientManager<C, T>
25 where C : System.ServiceModel.ClientBase<T>
26 where T : class
27 {
28 private static object _lock = new object();
29 private C _client;
30 private string _name = string.Empty;
31
38 public static ServiceClientManager<C,T > GetManager(string name)
39 {
40
41 lock (_lock)
42 {
43 ServiceClientManager<C, T> mgr = (ServiceClientManager<C, T>)ApplicationContext.LocalContext.GetValueOrNull(name);
44 if (mgr == null)
45 {
46 mgr = new ServiceClientManager<C, T>(name);
47 ApplicationContext.LocalContext[name] = mgr;
48 }
49 return mgr;
50 }
51 }
52
53
54 private ServiceClientManager(string name)
55 {
56 _client = (C)(Reflection.MethodCaller.CreateInstance(typeof(C)));
57 }
58
62 public C Client
63 {
64 get
65 {
66 return _client;
67 }
68 }
69 }
70}
71#endif
Provides an automated way to reuse a service client proxy objects within the context of a single data...
static ServiceClientManager< C, T > GetManager(string name)
Gets the client proxy object for the specified name.
C Client
Gets a reference to the current client proxy object.