Commit for development environment setup
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -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=">>label2.Name" xml:space="preserve">
|
||||
<value>label2</value>
|
||||
</data>
|
||||
<data name=">>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=">>label2.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>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=">>okButton.Name" xml:space="preserve">
|
||||
<value>okButton</value>
|
||||
</data>
|
||||
<data name=">>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=">>okButton.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>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=">>cancelButton.Name" xml:space="preserve">
|
||||
<value>cancelButton</value>
|
||||
</data>
|
||||
<data name=">>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=">>cancelButton.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>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=">>TypeComboBox.Name" xml:space="preserve">
|
||||
<value>TypeComboBox</value>
|
||||
</data>
|
||||
<data name=">>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=">>TypeComboBox.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>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=">>$this.Name" xml:space="preserve">
|
||||
<value>CslaDataSourceConfiguration</value>
|
||||
</data>
|
||||
<data name=">>$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>
|
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -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; }
|
||||
}
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@@ -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";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user