Commit for development environment setup

This commit is contained in:
2023-06-19 16:12:33 -04:00
parent be72063a3c
commit bbce2ad0a6
2209 changed files with 1171775 additions and 625 deletions

View File

@@ -0,0 +1,210 @@
using System;
using System.Web.UI;
using System.Web.UI.Design;
using System.ComponentModel;
using System.Reflection;
using Csla.Properties;
namespace Csla.Web
{
/// <summary>
/// A Web Forms data binding control designed to support
/// CSLA .NET business objects as data sources.
/// </summary>
[Designer(typeof(Csla.Web.Design.CslaDataSourceDesigner))]
[DisplayName("CslaDataSource")]
[Description("CSLA .NET Data Source Control")]
[ToolboxData("<{0}:CslaDataSource runat=\"server\"></{0}:CslaDataSource>")]
public class CslaDataSource : DataSourceControl
{
private CslaDataSourceView _defaultView;
/// <summary>
/// Event raised when an object is to be created and
/// populated with data.
/// </summary>
/// <remarks>Handle this event in a page and set
/// e.BusinessObject to the populated business object.
/// </remarks>
public event EventHandler<SelectObjectArgs> SelectObject;
/// <summary>
/// Event raised when an object is to be populated with data
/// and inserted.
/// </summary>
/// <remarks>Handle this event in a page to create an
/// instance of the object, load the object with data and
/// insert the object into the database.</remarks>
public event EventHandler<InsertObjectArgs> InsertObject;
/// <summary>
/// Event raised when an object is to be updated.
/// </summary>
/// <remarks>Handle this event in a page to update an
/// existing instance of an object with new data and then
/// save the object into the database.</remarks>
public event EventHandler<UpdateObjectArgs> UpdateObject;
/// <summary>
/// Event raised when an object is to be deleted.
/// </summary>
/// <remarks>Handle this event in a page to delete
/// an object from the database.</remarks>
public event EventHandler<DeleteObjectArgs> DeleteObject;
/// <summary>
/// Returns the default view for this data control.
/// </summary>
/// <param name="viewName">Ignored.</param>
/// <returns></returns>
/// <remarks>This control only contains a "Default" view.</remarks>
protected override DataSourceView GetView(string viewName)
{
if (_defaultView == null)
_defaultView = new CslaDataSourceView(this, "Default");
return _defaultView;
}
/// <summary>
/// Get or set the name of the assembly (no longer used).
/// </summary>
/// <value>Obsolete - do not use.</value>
public string TypeAssemblyName
{
get { return ((CslaDataSourceView)this.GetView("Default")).TypeAssemblyName; }
set { ((CslaDataSourceView)this.GetView("Default")).TypeAssemblyName = value; }
}
/// <summary>
/// Get or set the full type name of the business object
/// class to be used as a data source.
/// </summary>
/// <value>Full type name of the business class,
/// including assembly name.</value>
public string TypeName
{
get { return ((CslaDataSourceView)this.GetView("Default")).TypeName; }
set { ((CslaDataSourceView)this.GetView("Default")).TypeName = value; }
}
/// <summary>
/// Get or set a value indicating whether the
/// business object data source supports paging.
/// </summary>
/// <remarks>
/// To support paging, the business object
/// (collection) must implement
/// <see cref="Csla.Core.IReportTotalRowCount"/>.
/// </remarks>
public bool TypeSupportsPaging
{
get { return ((CslaDataSourceView)this.GetView("Default")).TypeSupportsPaging; }
set { ((CslaDataSourceView)this.GetView("Default")).TypeSupportsPaging = value; }
}
/// <summary>
/// Get or set a value indicating whether the
/// business object data source supports sorting.
/// </summary>
public bool TypeSupportsSorting
{
get { return ((CslaDataSourceView)this.GetView("Default")).TypeSupportsSorting; }
set { ((CslaDataSourceView)this.GetView("Default")).TypeSupportsSorting = value; }
}
private static System.Collections.Generic.Dictionary<string,Type> _typeCache =
new System.Collections.Generic.Dictionary<string,Type>();
/// <summary>
/// Returns a <see cref="Type">Type</see> object based on the
/// assembly and type information provided.
/// </summary>
/// <param name="typeAssemblyName">Optional assembly name.</param>
/// <param name="typeName">Full type name of the class,
/// including assembly name.</param>
/// <remarks></remarks>
internal static Type GetType(
string typeAssemblyName, string typeName)
{
Type result = null;
if (!string.IsNullOrEmpty(typeAssemblyName))
{
// explicit assembly name provided
result = Type.GetType(string.Format(
"{0}, {1}", typeName, typeAssemblyName), true, true);
}
else if (typeName.IndexOf(",") > 0)
{
// assembly qualified type name provided
result = Type.GetType(typeName, true, true);
}
else
{
// no assembly name provided
result = _typeCache[typeName];
if (result == null)
foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
{
result = asm.GetType(typeName, false, true);
if (result != null)
{
_typeCache.Add(typeName, result);
break;
}
}
}
if (result == null)
throw new TypeLoadException(String.Format(Resources.TypeLoadException, typeName));
return result;
}
/// <summary>
/// Returns a list of views available for this control.
/// </summary>
/// <remarks>This control only provides the "Default" view.</remarks>
protected override System.Collections.ICollection GetViewNames()
{
return new string[] { "Default" };
}
/// <summary>
/// Raises the SelectObject event.
/// </summary>
internal void OnSelectObject(SelectObjectArgs e)
{
if (SelectObject != null)
SelectObject(this, e);
}
/// <summary>
/// Raises the InsertObject event.
/// </summary>
internal void OnInsertObject(InsertObjectArgs e)
{
if (InsertObject != null)
InsertObject(this, e);
}
/// <summary>
/// Raises the UpdateObject event.
/// </summary>
internal void OnUpdateObject(UpdateObjectArgs e)
{
if (UpdateObject != null)
UpdateObject(this, e);
}
/// <summary>
/// Raises the DeleteObject event.
/// </summary>
internal void OnDeleteObject(DeleteObjectArgs e)
{
if (DeleteObject != null)
DeleteObject(this, e);
}
}
}

View File

@@ -0,0 +1,290 @@
using System;
using System.Collections;
using System.Web.UI;
namespace Csla.Web
{
/// <summary>
/// The object responsible for managing data binding
/// to a specific CSLA .NET object.
/// </summary>
public class CslaDataSourceView : DataSourceView
{
private CslaDataSource _owner;
private string _typeAssemblyName;
private string _typeName;
private bool _typeSupportsPaging;
private bool _typeSupportsSorting;
/// <summary>
/// Creates an instance of the object.
/// </summary>
/// <param name="owner">The CslaDataSource object
/// that owns this view.</param>
/// <param name="viewName">The name of the view.</param>
public CslaDataSourceView(CslaDataSource owner, string viewName)
: base(owner, viewName)
{
_owner = owner;
}
/// <summary>
/// Get or set the name of the assembly (no longer used).
/// </summary>
/// <value>Obsolete - do not use.</value>
public string TypeAssemblyName
{
get { return _typeAssemblyName; }
set { _typeAssemblyName = value; }
}
/// <summary>
/// Get or set the full type name of the business object
/// class to be used as a data source.
/// </summary>
/// <value>Full type name of the business class.</value>
public string TypeName
{
get { return _typeName; }
set { _typeName = value; }
}
/// <summary>
/// Get or set a value indicating whether the
/// business object data source supports paging.
/// </summary>
/// <remarks>
/// To support paging, the business object
/// (collection) must implement
/// <see cref="Csla.Core.IReportTotalRowCount"/>.
/// </remarks>
public bool TypeSupportsPaging
{
get { return _typeSupportsPaging; }
set { _typeSupportsPaging = value; }
}
/// <summary>
/// Get or set a value indicating whether the
/// business object data source supports sorting.
/// </summary>
public bool TypeSupportsSorting
{
get { return _typeSupportsSorting; }
set { _typeSupportsSorting = value; }
}
#region Select
/// <summary>
/// Implements the select behavior for
/// the control by raising the
/// <see cref="CslaDataSource.SelectObject"/> event.
/// </summary>
/// <param name="arguments">Arguments object.</param>
/// <returns>The data returned from the select.</returns>
protected override System.Collections.IEnumerable
ExecuteSelect(DataSourceSelectArguments arguments)
{
// get the object from the page
SelectObjectArgs args = new SelectObjectArgs(arguments);
_owner.OnSelectObject(args);
object result = args.BusinessObject;
if (arguments.RetrieveTotalRowCount)
{
int rowCount;
if (result == null)
rowCount = 0;
else if (result is Csla.Core.IReportTotalRowCount)
rowCount = ((Csla.Core.IReportTotalRowCount)result).TotalRowCount;
else if (result is IList)
rowCount = ((IList)result).Count;
else if (result is IEnumerable)
{
IEnumerable temp = (IEnumerable)result;
int count = 0;
foreach (object item in temp)
count++;
rowCount = count;
}
else
rowCount = 1;
arguments.TotalRowCount = rowCount;
}
// if the result isn't IEnumerable then
// wrap it in a collection
if (!(result is IEnumerable))
{
ArrayList list = new ArrayList();
if (result != null)
list.Add(result);
result = list;
}
// now return the object as a result
return (IEnumerable)result;
}
#endregion
#region Insert
/// <summary>
/// Gets a value indicating whether the data source can
/// insert data.
/// </summary>
public override bool CanInsert
{
get
{
if (typeof(Csla.Core.IUndoableObject).IsAssignableFrom(
CslaDataSource.GetType(_typeAssemblyName, _typeName)))
return true;
else
return false;
}
}
/// <summary>
/// Implements the insert behavior for
/// the control by raising the
/// <see cref="CslaDataSource.InsertObject"/> event.
/// </summary>
/// <param name="values">The values from
/// the UI that are to be inserted.</param>
/// <returns>The number of rows affected.</returns>
protected override int ExecuteInsert(
IDictionary values)
{
// tell the page to insert the object
InsertObjectArgs args =
new InsertObjectArgs(values);
_owner.OnInsertObject(args);
return args.RowsAffected;
}
#endregion
#region Delete
/// <summary>
/// Gets a value indicating whether the data source can
/// delete data.
/// </summary>
public override bool CanDelete
{
get
{
if (typeof(Csla.Core.IUndoableObject).IsAssignableFrom(
CslaDataSource.GetType(_typeAssemblyName, _typeName)))
return true;
else
return false;
}
}
/// <summary>
/// Implements the delete behavior for
/// the control by raising the
/// <see cref="CslaDataSource.DeleteObject"/> event.
/// </summary>
/// <param name="keys">The key values from
/// the UI that are to be deleted.</param>
/// <param name="oldValues">The old values
/// from the UI.</param>
/// <returns>The number of rows affected.</returns>
protected override int ExecuteDelete(IDictionary keys, IDictionary oldValues)
{
// tell the page to delete the object
DeleteObjectArgs args = new DeleteObjectArgs(keys, oldValues);
_owner.OnDeleteObject(args);
return args.RowsAffected;
}
#endregion
#region Update
/// <summary>
/// Gets a value indicating whether the data source can
/// update data.
/// </summary>
public override bool CanUpdate
{
get
{
if (typeof(Csla.Core.IUndoableObject).IsAssignableFrom(
CslaDataSource.GetType(_typeAssemblyName, _typeName)))
return true;
else
return false;
}
}
/// <summary>
/// Implements the update behavior for
/// the control by raising the
/// <see cref="CslaDataSource.UpdateObject"/> event.
/// </summary>
/// <param name="keys">The key values from the UI
/// that identify the object to be updated.</param>
/// <param name="values">The values from
/// the UI that are to be inserted.</param>
/// <param name="oldValues">The old values
/// from the UI.</param>
/// <returns>The number of rows affected.</returns>
protected override int ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues)
{
// tell the page to update the object
UpdateObjectArgs args = new UpdateObjectArgs(keys, values, oldValues);
_owner.OnUpdateObject(args);
return args.RowsAffected;
}
#endregion
#region Other Operations
/// <summary>
/// Gets a value indicating whether the data source supports
/// paging of the data.
/// </summary>
public override bool CanPage
{
get
{
return _typeSupportsPaging;
}
}
/// <summary>
/// Gets a value indicating whether the data source can
/// retrieve the total number of rows of data. Always
/// returns <see langword="true"/>.
/// </summary>
public override bool CanRetrieveTotalRowCount
{
get { return true; }
}
/// <summary>
/// Gets a alue indicating whether the data source supports
/// sorting of the data. Always returns <see langword="false"/>.
/// </summary>
public override bool CanSort
{
get
{
return _typeSupportsSorting;
}
}
#endregion
}
}

View File

@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Csla.Web
{
/// <summary>
/// Argument object used in the DeleteObject event.
/// </summary>
public class DeleteObjectArgs : EventArgs
{
private System.Collections.IDictionary _keys;
private System.Collections.IDictionary _oldValues;
private int _rowsAffected;
/// <summary>
/// Gets or sets the number of rows affected
/// while handling this event.
/// </summary>
/// <value></value>
/// <returns></returns>
/// <remarks>
/// The code handling the event should set this
/// value to indicate the number of rows affected
/// by the operation.
/// </remarks>
public int RowsAffected
{
get { return _rowsAffected; }
set { _rowsAffected = value; }
}
/// <summary>
/// The list of key values entered by the user.
/// </summary>
/// <remarks>It is up to the event handler in the
/// web page to use the values to identify the
/// object to be deleted.</remarks>
public System.Collections.IDictionary Keys
{
get { return _keys; }
}
/// <summary>
/// The list of old data values maintained by
/// data binding.
/// </summary>
/// <remarks>It is up to the event handler in the
/// web page to use the values to identify the
/// object to be deleted.</remarks>
public System.Collections.IDictionary OldValues
{
get { return _oldValues; }
}
/// <summary>
/// Create an instance of the object.
/// </summary>
public DeleteObjectArgs(System.Collections.IDictionary keys, System.Collections.IDictionary oldValues)
{
_keys = keys;
_oldValues = oldValues;
}
}
}

View File

@@ -0,0 +1,90 @@
namespace Csla.Web.Design
{
partial class CslaDataSourceConfiguration
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CslaDataSourceConfiguration));
this.label2 = new System.Windows.Forms.Label();
this.okButton = new System.Windows.Forms.Button();
this.cancelButton = new System.Windows.Forms.Button();
this.TypeComboBox = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
//
// label2
//
resources.ApplyResources(this.label2, "label2");
this.label2.Name = "label2";
//
// okButton
//
resources.ApplyResources(this.okButton, "okButton");
this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
this.okButton.Name = "okButton";
this.okButton.UseVisualStyleBackColor = true;
//
// cancelButton
//
resources.ApplyResources(this.cancelButton, "cancelButton");
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.cancelButton.Name = "cancelButton";
this.cancelButton.UseVisualStyleBackColor = true;
//
// TypeComboBox
//
resources.ApplyResources(this.TypeComboBox, "TypeComboBox");
this.TypeComboBox.FormattingEnabled = true;
this.TypeComboBox.Name = "TypeComboBox";
//
// CslaDataSourceConfiguration
//
this.AcceptButton = this.okButton;
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.cancelButton;
this.ControlBox = false;
this.Controls.Add(this.TypeComboBox);
this.Controls.Add(this.cancelButton);
this.Controls.Add(this.okButton);
this.Controls.Add(this.label2);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "CslaDataSourceConfiguration";
this.ShowInTaskbar = false;
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button okButton;
private System.Windows.Forms.Button cancelButton;
private System.Windows.Forms.ComboBox TypeComboBox;
}
}

View File

@@ -0,0 +1,91 @@
using System;
using System.Collections.Generic;
using System.Collections;
using System.Web.UI;
using System.Web.UI.Design;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Csla.Web.Design
{
/// <summary>
/// CslaDataSource configuration form.
/// </summary>
public partial class CslaDataSourceConfiguration : Form
{
private DataSourceControl _control;
/// <summary>
/// Create instance of object.
/// </summary>
public CslaDataSourceConfiguration()
{
InitializeComponent();
}
/// <summary>
/// Create instance of object.
/// </summary>
/// <param name="control">Reference to the data source control.</param>
/// <param name="oldTypeName">Existing type name.</param>
public CslaDataSourceConfiguration(DataSourceControl control, string oldTypeName)
: this()
{
_control = control;
DiscoverTypes();
this.TypeComboBox.Text = oldTypeName;
}
/// <summary>
/// Gets the type name entered by the user.
/// </summary>
public string TypeName
{
get { return this.TypeComboBox.Text; }
}
private void DiscoverTypes()
{
// try to get a reference to the type discovery service
ITypeDiscoveryService discovery = null;
if (_control.Site != null)
discovery = (ITypeDiscoveryService)_control.Site.GetService(typeof(ITypeDiscoveryService));
if (discovery != null)
{
// saves the cursor and sets the wait cursor
Cursor previousCursor = Cursor.Current;
Cursor.Current = Cursors.WaitCursor;
try
{
// gets all types using the type discovery service
ICollection types = discovery.GetTypes(typeof(object), true);
TypeComboBox.BeginUpdate();
TypeComboBox.Items.Clear();
// adds the types to the list
foreach (Type type in types)
{
if (type.Assembly.FullName.Substring(0, type.Assembly.FullName.IndexOf(",")) != "Csla" &&
typeof(Csla.Core.IBusinessObject).IsAssignableFrom(type))
{
string name = type.AssemblyQualifiedName;
if (name.Substring(name.Length - 19, 19) == "PublicKeyToken=null")
name = name.Substring(0, name.IndexOf(",", name.IndexOf(",") + 1));
TypeComboBox.Items.Add(name);
}
}
}
finally
{
Cursor.Current = previousCursor;
TypeComboBox.EndUpdate();
}
}
}
}
}

View File

@@ -0,0 +1,249 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="mscorlib" name="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="label2.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="label2.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 17</value>
</data>
<data name="label2.Size" type="System.Drawing.Size, System.Drawing">
<value>104, 13</value>
</data>
<data name="label2.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="label2.Text" xml:space="preserve">
<value>Business object type</value>
</data>
<data name="&gt;&gt;label2.Name" xml:space="preserve">
<value>label2</value>
</data>
<data name="&gt;&gt;label2.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;label2.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;label2.ZOrder" xml:space="preserve">
<value>3</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="okButton.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="okButton.Location" type="System.Drawing.Point, System.Drawing">
<value>562, 12</value>
</data>
<data name="okButton.Size" type="System.Drawing.Size, System.Drawing">
<value>75, 23</value>
</data>
<data name="okButton.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
</data>
<data name="okButton.Text" xml:space="preserve">
<value>OK</value>
</data>
<data name="&gt;&gt;okButton.Name" xml:space="preserve">
<value>okButton</value>
</data>
<data name="&gt;&gt;okButton.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;okButton.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;okButton.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="cancelButton.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="cancelButton.Location" type="System.Drawing.Point, System.Drawing">
<value>562, 41</value>
</data>
<data name="cancelButton.Size" type="System.Drawing.Size, System.Drawing">
<value>75, 23</value>
</data>
<data name="cancelButton.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="cancelButton.Text" xml:space="preserve">
<value>Cancel</value>
</data>
<data name="&gt;&gt;cancelButton.Name" xml:space="preserve">
<value>cancelButton</value>
</data>
<data name="&gt;&gt;cancelButton.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;cancelButton.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;cancelButton.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="TypeComboBox.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Left, Right</value>
</data>
<data name="TypeComboBox.Location" type="System.Drawing.Point, System.Drawing">
<value>122, 14</value>
</data>
<data name="TypeComboBox.Size" type="System.Drawing.Size, System.Drawing">
<value>429, 21</value>
</data>
<data name="TypeComboBox.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="&gt;&gt;TypeComboBox.Name" xml:space="preserve">
<value>TypeComboBox</value>
</data>
<data name="&gt;&gt;TypeComboBox.Type" xml:space="preserve">
<value>System.Windows.Forms.ComboBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;TypeComboBox.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;TypeComboBox.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
<value>6, 13</value>
</data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>649, 75</value>
</data>
<data name="$this.StartPosition" type="System.Windows.Forms.FormStartPosition, System.Windows.Forms">
<value>CenterParent</value>
</data>
<data name="$this.Text" xml:space="preserve">
<value>Configure CslaDataSource</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>CslaDataSourceConfiguration</value>
</data>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>System.Windows.Forms.Form, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>

View File

@@ -0,0 +1,164 @@
using System;
using System.Web.UI;
using System.Web.UI.Design;
using System.ComponentModel;
using System.Windows.Forms.Design;
using Csla.Web;
namespace Csla.Web.Design
{
/// <summary>
/// Implements designer support for CslaDataSource.
/// </summary>
public class CslaDataSourceDesigner : DataSourceDesigner
{
private DataSourceControl _control = null;
private CslaDesignerDataSourceView _view = null;
/// <summary>
/// Initialize the designer component.
/// </summary>
/// <param name="component">The CslaDataSource control to
/// be designed.</param>
public override void Initialize(IComponent component)
{
base.Initialize(component);
_control = (DataSourceControl)component;
}
internal System.ComponentModel.ISite Site
{
get
{
return _control.Site;
}
}
/// <summary>
/// Returns the default view for this designer.
/// </summary>
/// <param name="viewName">Ignored</param>
/// <returns></returns>
/// <remarks>
/// This designer supports only a "Default" view.
/// </remarks>
public override DesignerDataSourceView GetView(string viewName)
{
if (_view == null)
{
_view = new CslaDesignerDataSourceView(this, "Default");
}
return _view;
}
/// <summary>
/// Return a list of available views.
/// </summary>
/// <remarks>
/// This designer supports only a "Default" view.
/// </remarks>
public override string[] GetViewNames()
{
return new string[] { "Default" };
}
/// <summary>
/// Refreshes the schema for the data.
/// </summary>
/// <param name="preferSilent"></param>
/// <remarks></remarks>
public override void RefreshSchema(bool preferSilent)
{
this.OnSchemaRefreshed(EventArgs.Empty);
}
/// <summary>
/// Get a value indicating whether the control can
/// refresh its schema.
/// </summary>
public override bool CanRefreshSchema
{
get
{
return true;
}
}
/// <summary>
/// Invoke the design time configuration
/// support provided by the control.
/// </summary>
public override void Configure()
{
InvokeTransactedChange(_control, ConfigureCallback, null, "ConfigureDataSource");
}
private bool ConfigureCallback(object context)
{
bool result = false;
string oldTypeName;
if (string.IsNullOrEmpty(((CslaDataSource)DataSourceControl).TypeAssemblyName))
oldTypeName = ((CslaDataSource)DataSourceControl).TypeName;
else
oldTypeName = string.Format("{0}, {1}",
((CslaDataSource)DataSourceControl).TypeName, ((CslaDataSource)DataSourceControl).TypeAssemblyName);
IUIService uiService = (IUIService)_control.Site.GetService(typeof(IUIService));
CslaDataSourceConfiguration cfg = new CslaDataSourceConfiguration(_control, oldTypeName);
if (uiService.ShowDialog(cfg) == System.Windows.Forms.DialogResult.OK)
{
SuppressDataSourceEvents();
try
{
((CslaDataSource)DataSourceControl).TypeAssemblyName = string.Empty;
((CslaDataSource)DataSourceControl).TypeName = cfg.TypeName;
OnDataSourceChanged(EventArgs.Empty);
result = true;
}
finally
{
ResumeDataSourceEvents();
}
}
cfg.Dispose();
return result;
}
/// <summary>
/// Get a value indicating whether this control
/// supports design time configuration.
/// </summary>
public override bool CanConfigure
{
get
{
return true;
}
}
/// <summary>
/// Get a value indicating whether the control can
/// be resized.
/// </summary>
public override bool AllowResize
{
get
{
return false;
}
}
/// <summary>
/// Get a reference to the CslaDataSource control being
/// designed.
/// </summary>
internal CslaDataSource DataSourceControl
{
get
{
return (CslaDataSource)_control;
}
}
}
}

View File

@@ -0,0 +1,229 @@
using System;
using System.Collections;
using System.Web.UI;
using System.Web.UI.Design;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Reflection;
using System.Data;
namespace Csla.Web.Design
{
/// <summary>
/// Object responsible for providing details about
/// data binding to a specific CSLA .NET object.
/// </summary>
public class CslaDesignerDataSourceView : DesignerDataSourceView
{
private CslaDataSourceDesigner _owner = null;
/// <summary>
/// Creates an instance of the object.
/// </summary>
public CslaDesignerDataSourceView(CslaDataSourceDesigner owner, string viewName)
: base(owner, viewName)
{
_owner = owner;
}
/// <summary>
/// Returns a set of sample data used to populate
/// controls at design time.
/// </summary>
/// <param name="minimumRows">Minimum number of sample rows
/// to create.</param>
/// <param name="isSampleData">Returns True if the data
/// is sample data.</param>
public override IEnumerable GetDesignTimeData(int minimumRows, out bool isSampleData)
{
IDataSourceViewSchema schema = this.Schema;
DataTable result = new DataTable();
// create the columns
foreach (IDataSourceFieldSchema item in schema.GetFields())
{
result.Columns.Add(item.Name, item.DataType);
}
// create sample data
for (int index = 1; index <= minimumRows; index++)
{
object[] values = new object[result.Columns.Count];
int colIndex = 0;
foreach (DataColumn col in result.Columns)
{
if (col.DataType.Equals(typeof(string)))
values[colIndex] = "abc";
else if (col.DataType.Equals(typeof(System.DateTime)))
values[colIndex] = System.DateTime.Today.ToShortDateString();
else if (col.DataType.Equals(typeof(bool)))
values[colIndex] = false;
else if (col.DataType.IsPrimitive)
values[colIndex] = index;
else if (col.DataType.Equals(typeof(Guid)))
values[colIndex] = Guid.Empty;
else if (col.DataType.IsValueType)
values[colIndex] = Activator.CreateInstance(col.DataType);
else
values[colIndex] = null;
colIndex += 1;
}
result.LoadDataRow(values, LoadOption.OverwriteChanges);
}
isSampleData = true;
return (IEnumerable)result.DefaultView;
}
/// <summary>
/// Returns schema information corresponding to the properties
/// of the CSLA .NET business object.
/// </summary>
/// <remarks>
/// All public properties are returned except for those marked
/// with the <see cref="BrowsableAttribute">Browsable attribute</see>
/// as False.
/// </remarks>
public override IDataSourceViewSchema Schema
{
get
{
return new ObjectSchema(
_owner,
_owner.DataSourceControl.TypeName).GetViews()[0];
}
}
/// <summary>
/// Get a value indicating whether data binding can retrieve
/// the total number of rows of data.
/// </summary>
public override bool CanRetrieveTotalRowCount
{
get
{
return true;
}
}
private Type GetObjectType()
{
Type result;
try
{
ITypeResolutionService typeService = null;
typeService = (ITypeResolutionService)(_owner.Site.GetService(typeof(ITypeResolutionService)));
result = typeService.GetType(this._owner.DataSourceControl.TypeName, true, false);
}
catch
{
result = typeof(object);
}
return result;
}
/// <summary>
/// Get a value indicating whether data binding can directly
/// delete the object.
/// </summary>
/// <remarks>
/// If this returns true, the web page must handle the
/// <see cref="CslaDataSource.DeleteObject">DeleteObject</see>
/// event.
/// </remarks>
public override bool CanDelete
{
get
{
Type objectType = GetObjectType();
if (typeof(Csla.Core.IUndoableObject).IsAssignableFrom(objectType))
{
return true;
}
else if (objectType.GetMethod("Remove") != null)
{
return true;
}
else
{
return false;
}
}
}
/// <summary>
/// Get a value indicating whether data binding can directly
/// insert an instance of the object.
/// </summary>
/// <remarks>
/// If this returns true, the web page must handle the
/// <see cref="CslaDataSource.InsertObject">InsertObject</see>
/// event.
/// </remarks>
public override bool CanInsert
{
get
{
Type objectType = GetObjectType();
if (typeof(Csla.Core.IUndoableObject).IsAssignableFrom(objectType))
{
return true;
}
else
{
return false;
}
}
}
/// <summary>
/// Get a value indicating whether data binding can directly
/// update or edit the object.
/// </summary>
/// <remarks>
/// If this returns true, the web page must handle the
/// <see cref="CslaDataSource.UpdateObject">UpdateObject</see>
/// event.
/// </remarks>
public override bool CanUpdate
{
get
{
Type objectType = GetObjectType();
if (typeof(Csla.Core.IUndoableObject).IsAssignableFrom(objectType))
{
return true;
}
else
{
return false;
}
}
}
/// <summary>
/// Gets a value indicating whether the data source supports
/// paging.
/// </summary>
public override bool CanPage
{
get
{
return _owner.DataSourceControl.TypeSupportsPaging;
}
}
/// <summary>
/// Gets a value indicating whether the data source supports
/// sorting.
/// </summary>
public override bool CanSort
{
get
{
return _owner.DataSourceControl.TypeSupportsSorting;
}
}
}
}

View File

@@ -0,0 +1,181 @@
using System;
using System.Data;
using System.Web.UI;
using System.Web.UI.Design;
using System.ComponentModel;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
namespace Csla.Web.Design
{
/// <summary>
/// Contains schema information for a single
/// object property.
/// </summary>
[Serializable]
public class ObjectFieldInfo : IDataSourceFieldSchema
{
private Type _dataType;
private bool _primaryKey;
private bool _isIdentity;
private bool _isNullable;
private int _length;
private bool _isReadOnly;
private string _name;
private bool _nullable;
/// <summary>
/// Creates an instance of the object.
/// </summary>
/// <param name="field">The PropertyInfo object
/// describing the property.</param>
public ObjectFieldInfo(PropertyDescriptor field)
{
DataObjectFieldAttribute attribute =
(DataObjectFieldAttribute)
field.Attributes[typeof(DataObjectFieldAttribute)];
if (attribute != null)
{
_primaryKey = attribute.PrimaryKey;
_isIdentity = attribute.IsIdentity;
_isNullable = attribute.IsNullable;
_length = attribute.Length;
}
_dataType = Utilities.GetPropertyType(
field.PropertyType);
_isReadOnly = field.IsReadOnly;
_name = field.Name;
// nullable
Type t = field.PropertyType;
if (!t.IsValueType || _isNullable)
_nullable = true;
else
{
if (t.IsGenericType)
_nullable = (t.GetGenericTypeDefinition() == typeof(Nullable<>));
else
_nullable = false;
}
}
/// <summary>
/// Gets the data type of the property.
/// </summary>
public Type DataType
{
get
{
return _dataType;
}
}
/// <summary>
/// Gets a value indicating whether this property
/// is an identity key for the object.
/// </summary>
/// <remarks>
/// Returns the optional value provided through
/// the <see cref="DataObjectFieldAttribute">DataObjectField</see>
/// attribute on the property.
/// </remarks>
public bool Identity
{
get { return _isIdentity; }
}
/// <summary>
/// Gets a value indicating whether this property
/// is readonly.
/// </summary>
public bool IsReadOnly
{
get { return _isReadOnly; }
}
/// <summary>
/// Gets a value indicating whether this property
/// must contain a unique value.
/// </summary>
/// <returns>
/// Always returns True if the property
/// is marked as a primary key, otherwise
/// returns False.
/// </returns>
public bool IsUnique
{
get { return _primaryKey; }
}
/// <summary>
/// Gets the length of the property value.
/// </summary>
/// <remarks>
/// Returns the optional value provided through
/// the <see cref="DataObjectFieldAttribute">DataObjectField</see>
/// attribute on the property.
/// </remarks>
public int Length
{
get { return _length; }
}
/// <summary>
/// Gets the property name.
/// </summary>
public string Name
{
get { return _name; }
}
/// <summary>
/// Gets a value indicating whether the property
/// is nullable
/// </summary>
/// <remarks>
/// Returns True for reference types, and for
/// value types wrapped in the Nullable generic.
/// The result can also be set to True through
/// the <see cref="DataObjectFieldAttribute">DataObjectField</see>
/// attribute on the property.
/// </remarks>
public bool Nullable
{
get
{ return _nullable; }
}
/// <summary>
/// Gets the property's numeric precision.
/// </summary>
/// <returns>Always returns -1.</returns>
public int Precision
{
get { return -1; }
}
/// <summary>
/// Gets a value indicating whether the property
/// is a primary key value.
/// </summary>
/// <remarks>
/// Returns the optional value provided through
/// the <see cref="DataObjectFieldAttribute">DataObjectField</see>
/// attribute on the property.
/// </remarks>
public bool PrimaryKey
{
get { return _primaryKey; }
}
/// <summary>
/// Gets the property's scale.
/// </summary>
/// <returns>Always returns -1.</returns>
public int Scale
{
get { return -1; }
}
}
}

View File

@@ -0,0 +1,46 @@
using System.Web.UI;
using System.Web.UI.Design;
using System.ComponentModel;
using System.Reflection;
namespace Csla.Web.Design
{
/// <summary>
/// Object providing access to schema information for
/// a business object.
/// </summary>
/// <remarks>
/// This object returns only one view, which corresponds
/// to the business object used by data binding.
/// </remarks>
public class ObjectSchema : IDataSourceSchema
{
private string _typeName = "";
private CslaDataSourceDesigner _designer;
/// <summary>
/// Creates an instance of the object.
/// </summary>
/// <param name="designer">Data source designer object.</param>
/// <param name="typeName">Type name for
/// which the schema should be generated.</param>
public ObjectSchema(CslaDataSourceDesigner designer, string typeName)
{
_typeName = typeName;
_designer = designer;
}
/// <summary>
/// Returns a single element array containing the
/// schema for the CSLA .NET business object.
/// </summary>
public System.Web.UI.Design.IDataSourceViewSchema[] GetViews()
{
IDataSourceViewSchema[] result = null;
result = new IDataSourceViewSchema[] { new ObjectViewSchema(_designer, _typeName) };
return result;
}
}
}

View File

@@ -0,0 +1,104 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Web.UI;
using System.Web.UI.Design;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Reflection;
using Csla;
using Csla.Web.Design;
namespace Csla.Web.Design
{
/// <summary>
/// Object providing schema information for a
/// business object.
/// </summary>
[Serializable()]
public class ObjectViewSchema : IDataSourceViewSchema
{
private string _typeName = "";
private CslaDataSourceDesigner _designer;
/// <summary>
/// Create an instance of the object.
/// </summary>
/// <param name="site">Site containing the control.</param>
/// <param name="typeName">The business class for
/// which to generate the schema.</param>
public ObjectViewSchema(CslaDataSourceDesigner site, string typeName)
{
_typeName = typeName;
_designer = site;
}
/// <summary>
/// Returns a list of child schemas belonging to the
/// object.
/// </summary>
/// <remarks>This schema object only returns
/// schema for the object itself, so GetChildren will
/// always return Nothing (null in C#).</remarks>
public System.Web.UI.Design.IDataSourceViewSchema[] GetChildren()
{
return null;
}
/// <summary>
/// Returns schema information for each property on
/// the object.
/// </summary>
/// <remarks>All public properties on the object
/// will be reflected in this schema list except
/// for those properties where the
/// <see cref="BrowsableAttribute">Browsable</see> attribute
/// is False.
/// </remarks>
public System.Web.UI.Design.IDataSourceFieldSchema[] GetFields()
{
ITypeResolutionService typeService = null;
List<ObjectFieldInfo> result = new List<ObjectFieldInfo>();
if (_designer != null)
{
Type objectType = null;
try
{
typeService = (ITypeResolutionService)(_designer.Site.GetService(typeof(ITypeResolutionService)));
objectType = typeService.GetType(_typeName, true, false);
if (typeof(IEnumerable).IsAssignableFrom(objectType))
{
// this is a list so get the item type
objectType = Utilities.GetChildItemType(objectType);
}
PropertyDescriptorCollection props = TypeDescriptor.GetProperties(objectType);
foreach (PropertyDescriptor item in props)
{
if (item.IsBrowsable)
{
result.Add(new ObjectFieldInfo(item));
}
}
}
catch
{ /* do nothing - just swallow exception */ }
}
return result.ToArray();
}
/// <summary>
/// Returns the name of the schema.
/// </summary>
public string Name
{
get
{
return "Default";
}
}
}
}

View File

@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Csla.Web
{
/// <summary>
/// Argument object used in the InsertObject event.
/// </summary>
public class InsertObjectArgs : EventArgs
{
private System.Collections.IDictionary _values;
private int _rowsAffected;
/// <summary>
/// Gets or sets the number of rows affected
/// while handling this event.
/// </summary>
/// <value></value>
/// <returns></returns>
/// <remarks>
/// The code handling the event should set this
/// value to indicate the number of rows affected
/// by the operation.
/// </remarks>
public int RowsAffected
{
get { return _rowsAffected; }
set { _rowsAffected = value; }
}
/// <summary>
/// The list of data values entered by the user.
/// </summary>
/// <remarks>It is up to the event handler in the
/// web page to take the list of values, put them
/// into a business object and to save that object
/// into the database.</remarks>
public System.Collections.IDictionary Values
{
get { return _values; }
}
/// <summary>
/// Create an instance of the object.
/// </summary>
public InsertObjectArgs(System.Collections.IDictionary values)
{
_values = values;
}
}
}

View File

@@ -0,0 +1,157 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
namespace Csla.Web
{
/// <summary>
/// Argument object used in the SelectObject event.
/// </summary>
[Serializable]
public class SelectObjectArgs : EventArgs
{
private object _businessObject;
private string _sortExpression;
private string _sortProperty;
private ListSortDirection _sortDirection;
private int _startRowIndex;
private int _maximumRows;
private bool _retrieveTotalRowCount;
/// <summary>
/// Get or set a reference to the business object
/// that is created and populated by the SelectObject
/// event handler in the web page.
/// </summary>
/// <value>A reference to a CSLA .NET business object.</value>
public object BusinessObject
{
get { return _businessObject; }
set { _businessObject = value; }
}
/// <summary>
/// Gets the sort expression that should be used to
/// sort the data being returned to the data source
/// control.
/// </summary>
public string SortExpression
{
get
{
return _sortExpression;
}
}
/// <summary>
/// Gets the property name for the sort if only one
/// property/column name is specified.
/// </summary>
/// <remarks>
/// If multiple properties/columns are specified
/// for the sort, you must parse the value from
/// <see cref="SortExpression"/> to find all the
/// property names and sort directions for the sort.
/// </remarks>
public string SortProperty
{
get
{
return _sortProperty;
}
}
/// <summary>
/// Gets the sort direction for the sort if only
/// one property/column name is specified.
/// </summary>
/// <remarks>
/// If multiple properties/columns are specified
/// for the sort, you must parse the value from
/// <see cref="SortExpression"/> to find all the
/// property names and sort directions for the sort.
/// </remarks>
public ListSortDirection SortDirection
{
get
{
return _sortDirection;
}
}
/// <summary>
/// Gets the index for the first row that will be
/// displayed. This should be the first row in
/// the resulting collection set into the
/// <see cref="BusinessObject"/> property.
/// </summary>
public int StartRowIndex
{
get
{
return _startRowIndex;
}
}
/// <summary>
/// Gets the maximum number of rows that
/// should be returned as a result of this
/// query. For paged collections, this is the
/// page size.
/// </summary>
public int MaximumRows
{
get
{
return _maximumRows;
}
}
/// <summary>
/// Gets a value indicating whether the
/// query should return the total row count
/// through the
/// <see cref="Csla.Core.IReportTotalRowCount"/>
/// interface.
/// </summary>
public bool RetrieveTotalRowCount
{
get
{
return _retrieveTotalRowCount;
}
}
/// <summary>
/// Creates an instance of the object, initializing
/// it with values from data binding.
/// </summary>
/// <param name="args">Values provided from data binding.</param>
public SelectObjectArgs(System.Web.UI.DataSourceSelectArguments args)
{
_startRowIndex = args.StartRowIndex;
_maximumRows = args.MaximumRows;
_retrieveTotalRowCount = args.RetrieveTotalRowCount;
_sortExpression = args.SortExpression;
if (!(string.IsNullOrEmpty(_sortExpression)))
{
if (_sortExpression.Length >= 5 &&
_sortExpression.Substring(_sortExpression.Length - 5) == " DESC")
{
_sortProperty = _sortExpression.Substring(0, _sortExpression.Length - 5);
_sortDirection = ListSortDirection.Descending;
}
else
{
_sortProperty = args.SortExpression;
_sortDirection = ListSortDirection.Ascending;
}
}
}
}
}

View File

@@ -0,0 +1,83 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Csla.Web
{
/// <summary>
/// Argument object used in the UpdateObject event.
/// </summary>
public class UpdateObjectArgs : EventArgs
{
private System.Collections.IDictionary _keys;
private System.Collections.IDictionary _values;
private System.Collections.IDictionary _oldValues;
private int _rowsAffected;
/// <summary>
/// Gets or sets the number of rows affected
/// while handling this event.
/// </summary>
/// <value></value>
/// <returns></returns>
/// <remarks>
/// The code handling the event should set this
/// value to indicate the number of rows affected
/// by the operation.
/// </remarks>
public int RowsAffected
{
get { return _rowsAffected; }
set { _rowsAffected = value; }
}
/// <summary>
/// The list of key values entered by the user.
/// </summary>
/// <remarks>It is up to the event handler in the
/// web page to take the list of values, put them
/// into a business object and to save that object
/// into the database.</remarks>
public System.Collections.IDictionary Keys
{
get { return _keys; }
}
/// <summary>
/// The list of data values entered by the user.
/// </summary>
/// <remarks>It is up to the event handler in the
/// web page to take the list of values, put them
/// into a business object and to save that object
/// into the database.</remarks>
public System.Collections.IDictionary Values
{
get { return _values; }
}
/// <summary>
/// The list of old data values maintained by
/// data binding.
/// </summary>
/// <remarks>It is up to the event handler in the
/// web page to take the list of values, put them
/// into a business object and to save that object
/// into the database.</remarks>
public System.Collections.IDictionary OldValues
{
get { return _oldValues; }
}
/// <summary>
/// Creates an instance of the object.
/// </summary>
public UpdateObjectArgs(System.Collections.IDictionary keys, System.Collections.IDictionary values, System.Collections.IDictionary oldValues)
{
_keys = keys;
_values = values;
_oldValues = oldValues;
}
}
}