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.
CslaDataSource.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="CslaDataSource.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>A Web Forms data binding control designed to support</summary>
7//-----------------------------------------------------------------------
8using System;
9using System.Web.UI;
10using System.ComponentModel;
11using System.Reflection;
12using Csla.Properties;
13
14namespace Csla.Web
15{
16
21 [Designer(typeof(Csla.Web.Design.CslaDataSourceDesigner))]
22 [DisplayName("CslaDataSource")]
23 [Description("CSLA .NET Data Source Control")]
24 [ToolboxData("<{0}:CslaDataSource runat=\"server\"></{0}:CslaDataSource>")]
25 public class CslaDataSource : DataSourceControl
26 {
27
28 private CslaDataSourceView _defaultView;
29
37 public event EventHandler<SelectObjectArgs> SelectObject;
38
46 public event EventHandler<InsertObjectArgs> InsertObject;
47
54 public event EventHandler<UpdateObjectArgs> UpdateObject;
55
61 public event EventHandler<DeleteObjectArgs> DeleteObject;
62
69 protected override DataSourceView GetView(string viewName)
70 {
71 if (_defaultView == null)
72 _defaultView = new CslaDataSourceView(this, "Default");
73 return _defaultView;
74 }
75
80 public string TypeAssemblyName
81 {
82 get { return ((CslaDataSourceView)this.GetView("Default")).TypeAssemblyName; }
83 set { ((CslaDataSourceView)this.GetView("Default")).TypeAssemblyName = value; }
84 }
85
92 public string TypeName
93 {
94 get { return ((CslaDataSourceView)this.GetView("Default")).TypeName; }
95 set { ((CslaDataSourceView)this.GetView("Default")).TypeName = value; }
96 }
97
108 {
109 get { return ((CslaDataSourceView)this.GetView("Default")).TypeSupportsPaging; }
110 set { ((CslaDataSourceView)this.GetView("Default")).TypeSupportsPaging = value; }
111 }
112
118 {
119 get { return ((CslaDataSourceView)this.GetView("Default")).TypeSupportsSorting; }
120 set { ((CslaDataSourceView)this.GetView("Default")).TypeSupportsSorting = value; }
121 }
122
123 private static System.Collections.Generic.Dictionary<string,Type> _typeCache =
124 new System.Collections.Generic.Dictionary<string,Type>();
125
134 internal static Type GetType(
135 string typeAssemblyName, string typeName)
136 {
137 Type result = null;
138 if (!string.IsNullOrEmpty(typeAssemblyName))
139 {
140 // explicit assembly name provided
141 result = Type.GetType(string.Format(
142 "{0}, {1}", typeName, typeAssemblyName), true, true);
143 }
144 else if (typeName.IndexOf(",") > 0)
145 {
146 // assembly qualified type name provided
147 result = Type.GetType(typeName, true, true);
148 }
149 else
150 {
151 // no assembly name provided
152 result = _typeCache[typeName];
153 if (result == null)
154 foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
155 {
156 result = asm.GetType(typeName, false, true);
157 if (result != null)
158 {
159 _typeCache.Add(typeName, result);
160 break;
161 }
162 }
163 }
164
165 if (result == null)
166 throw new TypeLoadException(String.Format(Resources.TypeLoadException, typeName));
167
168 return result;
169 }
170
175 protected override System.Collections.ICollection GetViewNames()
176 {
177 return new string[] { "Default" };
178 }
179
183 internal void OnSelectObject(SelectObjectArgs e)
184 {
185 if (SelectObject != null)
186 SelectObject(this, e);
187 }
188
192 internal void OnInsertObject(InsertObjectArgs e)
193 {
194 if (InsertObject != null)
195 InsertObject(this, e);
196 }
197
201 internal void OnUpdateObject(UpdateObjectArgs e)
202 {
203 if (UpdateObject != null)
204 UpdateObject(this, e);
205 }
206
210 internal void OnDeleteObject(DeleteObjectArgs e)
211 {
212 if (DeleteObject != null)
213 DeleteObject(this, e);
214 }
215 }
216}
A strongly-typed resource class, for looking up localized strings, etc.
static string TypeLoadException
Looks up a localized string similar to Failed to load type '{0}'.
A Web Forms data binding control designed to support CSLA .NET business objects as data sources.
string TypeName
Get or set the full type name of the business object class to be used as a data source.
EventHandler< DeleteObjectArgs > DeleteObject
Event raised when an object is to be deleted.
EventHandler< SelectObjectArgs > SelectObject
Event raised when an object is to be created and populated with data.
string TypeAssemblyName
Get or set the name of the assembly (no longer used).
EventHandler< InsertObjectArgs > InsertObject
Event raised when an object is to be populated with data and inserted.
bool TypeSupportsSorting
Get or set a value indicating whether the business object data source supports sorting.
bool TypeSupportsPaging
Get or set a value indicating whether the business object data source supports paging.
override DataSourceView GetView(string viewName)
Returns the default view for this data control.
EventHandler< UpdateObjectArgs > UpdateObject
Event raised when an object is to be updated.
override System.Collections.ICollection GetViewNames()
Returns a list of views available for this control.
The object responsible for managing data binding to a specific CSLA .NET object.
Implements designer support for CslaDataSource.
Argument object used in the SelectObject event.