CSLA.NET 6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
CslaDataSourceDesigner.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="CslaDataSourceDesigner.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>Implements designer support for CslaDataSource.</summary>
7//-----------------------------------------------------------------------
8using System;
9using System.Web.UI;
10using System.Web.UI.Design;
11using System.ComponentModel;
12using System.Windows.Forms.Design;
13using Csla.Web;
14
15namespace Csla.Web.Design
16{
20 public class CslaDataSourceDesigner : DataSourceDesigner
21 {
22
23 private DataSourceControl _control = null;
24 private CslaDesignerDataSourceView _view = null;
25
31 public override void Initialize(IComponent component)
32 {
33 base.Initialize(component);
34 _control = (DataSourceControl)component;
35 }
36
37 internal System.ComponentModel.ISite Site
38 {
39 get
40 {
41 return _control.Site;
42 }
43 }
52 public override DesignerDataSourceView GetView(string viewName)
53 {
54 if (_view == null)
55 {
56 _view = new CslaDesignerDataSourceView(this, "Default");
57 }
58 return _view;
59 }
60
67 public override string[] GetViewNames()
68 {
69 return new string[] { "Default" };
70 }
71
77 public override void RefreshSchema(bool preferSilent)
78 {
79 this.OnSchemaRefreshed(EventArgs.Empty);
80 }
81
86 public override bool CanRefreshSchema
87 {
88 get
89 {
90 return true;
91 }
92 }
93
98 public override void Configure()
99 {
100 InvokeTransactedChange(_control, ConfigureCallback, null, "ConfigureDataSource");
101 }
102
103 private bool ConfigureCallback(object context)
104 {
105 bool result = false;
106
107 string oldTypeName;
108 if (string.IsNullOrEmpty(((CslaDataSource)DataSourceControl).TypeAssemblyName))
109 oldTypeName = ((CslaDataSource)DataSourceControl).TypeName;
110 else
111 oldTypeName = string.Format("{0}, {1}",
112 ((CslaDataSource)DataSourceControl).TypeName, ((CslaDataSource)DataSourceControl).TypeAssemblyName);
113
114 IUIService uiService = (IUIService)_control.Site.GetService(typeof(IUIService));
115 CslaDataSourceConfiguration cfg = new CslaDataSourceConfiguration(_control, oldTypeName);
116 if (uiService.ShowDialog(cfg) == System.Windows.Forms.DialogResult.OK)
117 {
118 SuppressDataSourceEvents();
119 try
120 {
121 ((CslaDataSource)DataSourceControl).TypeAssemblyName = string.Empty;
122 ((CslaDataSource)DataSourceControl).TypeName = cfg.TypeName;
123 OnDataSourceChanged(EventArgs.Empty);
124 result = true;
125 }
126 finally
127 {
128 ResumeDataSourceEvents();
129 }
130 }
131 cfg.Dispose();
132 return result;
133 }
134
139 public override bool CanConfigure
140 {
141 get
142 {
143 return true;
144 }
145 }
146
151 public override bool AllowResize
152 {
153 get
154 {
155 return false;
156 }
157 }
158
163 internal CslaDataSource DataSourceControl
164 {
165 get
166 {
167 return (CslaDataSource)_control;
168 }
169 }
170 }
171}
A Web Forms data binding control designed to support CSLA .NET business objects as data sources.
string TypeName
Gets the type name entered by the user.
override void Dispose(bool disposing)
Clean up any resources being used.
Implements designer support for CslaDataSource.
override bool CanRefreshSchema
Get a value indicating whether the control can refresh its schema.
override void RefreshSchema(bool preferSilent)
Refreshes the schema for the data.
override bool AllowResize
Get a value indicating whether the control can be resized.
override string[] GetViewNames()
Return a list of available views.
override void Configure()
Invoke the design time configuration support provided by the control.
override bool CanConfigure
Get a value indicating whether this control supports design time configuration.
override void Initialize(IComponent component)
Initialize the designer component.
override DesignerDataSourceView GetView(string viewName)
Returns the default view for this designer.
Object responsible for providing details about data binding to a specific CSLA .NET object.