Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WebForms / System / Web / UI / Design / TemplateDefinition.cs / 1 / TemplateDefinition.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.UI.Design {
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Design;
using System.Diagnostics;
using System.Web.UI.WebControls;
///
public class TemplateDefinition : DesignerObject {
private Style _style;
private string _templatePropertyName;
private object _templatedObject;
private PropertyDescriptor _templateProperty;
private bool _serverControlsOnly;
private bool _supportsDataBinding;
///
public TemplateDefinition(ControlDesigner designer, string name, object templatedObject, string templatePropertyName) : this(designer, name, templatedObject, templatePropertyName, false) {
}
///
public TemplateDefinition(ControlDesigner designer, string name, object templatedObject, string templatePropertyName, Style style) : this(designer, name, templatedObject, templatePropertyName, style, false) {
}
///
public TemplateDefinition(ControlDesigner designer, string name, object templatedObject, string templatePropertyName, bool serverControlsOnly) : this(designer, name, templatedObject, templatePropertyName, null, serverControlsOnly) {
}
///
public TemplateDefinition(ControlDesigner designer, string name, object templatedObject, string templatePropertyName, Style style, bool serverControlsOnly) : base(designer, name) {
if ((templatePropertyName == null) || (templatePropertyName.Length == 0)) {
throw new ArgumentNullException("templatePropertyName");
}
if (templatedObject == null) {
throw new ArgumentNullException("templatedObject");
}
_serverControlsOnly = serverControlsOnly;
_style = style;
_templatedObject = templatedObject;
_templatePropertyName = templatePropertyName;
}
public virtual bool AllowEditing {
get {
return true;
}
}
///
public virtual string Content {
get {
ITemplate template = (ITemplate)TemplateProperty.GetValue(TemplatedObject);
IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));
return ControlPersister.PersistTemplate(template, host);
}
set {
IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));
ITemplate template = ControlParser.ParseTemplate(host, value);
TemplateProperty.SetValue(TemplatedObject, template);
}
}
///
///
public bool ServerControlsOnly {
get {
return _serverControlsOnly;
}
}
///
///
public bool SupportsDataBinding {
get {
return _supportsDataBinding;
}
set {
_supportsDataBinding = value;
}
}
///
///
///
public Style Style {
get {
return _style;
}
}
///
public object TemplatedObject {
get {
return _templatedObject;
}
}
private PropertyDescriptor TemplateProperty {
get {
if (_templateProperty == null) {
_templateProperty = TypeDescriptor.GetProperties(TemplatedObject)[TemplatePropertyName];
if ((_templateProperty == null) || !typeof(ITemplate).IsAssignableFrom(_templateProperty.PropertyType)) {
throw new InvalidOperationException(SR.GetString(SR.TemplateDefinition_InvalidTemplateProperty, TemplatePropertyName));
}
}
return _templateProperty;
}
}
///
public string TemplatePropertyName {
get {
return _templatePropertyName;
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- Relationship.cs
- FlowLayoutPanel.cs
- WebServiceData.cs
- EventLogPermissionEntry.cs
- DataStreamFromComStream.cs
- XmlAttributes.cs
- WebPartManager.cs
- DrawTreeNodeEventArgs.cs
- ButtonColumn.cs
- WeakReference.cs
- FlowDecision.cs
- IntSecurity.cs
- Task.cs
- RemotingService.cs
- Compiler.cs
- x509utils.cs
- ServerIdentity.cs
- Substitution.cs
- EventInfo.cs
- LogExtent.cs
- DocumentationServerProtocol.cs
- SystemBrushes.cs
- VisualStateGroup.cs
- PolyLineSegmentFigureLogic.cs
- InputDevice.cs
- WebPartVerbCollection.cs
- Point3DAnimationUsingKeyFrames.cs
- VariableAction.cs
- CancelRequestedRecord.cs
- TableLayoutPanelBehavior.cs
- SoapHeaders.cs
- DbProviderFactories.cs
- Button.cs
- DependencyPropertyValueSerializer.cs
- CanExecuteRoutedEventArgs.cs
- Pen.cs
- ObjectManager.cs
- ConfigurationElement.cs
- PointConverter.cs
- XmlObjectSerializerWriteContextComplexJson.cs
- ConnectionManagementElement.cs
- Bezier.cs
- SqlNotificationEventArgs.cs
- XmlSerializerAssemblyAttribute.cs
- InstanceLockException.cs
- XamlInterfaces.cs
- ListenUriMode.cs
- WorkItem.cs
- dsa.cs
- Table.cs
- JavaScriptSerializer.cs
- XslTransform.cs
- ScaleTransform.cs
- ResXFileRef.cs
- SQLResource.cs
- RadialGradientBrush.cs
- LZCodec.cs
- DataObjectPastingEventArgs.cs
- GPPOINTF.cs
- _AcceptOverlappedAsyncResult.cs
- DataSourceIDConverter.cs
- HealthMonitoringSectionHelper.cs
- InfoCardKeyedHashAlgorithm.cs
- HierarchicalDataSourceControl.cs
- WebPartZoneBase.cs
- ScrollBarRenderer.cs
- SoundPlayer.cs
- AutoGeneratedField.cs
- _ChunkParse.cs
- PrivateFontCollection.cs
- PrintDialog.cs
- ProtocolsConfigurationHandler.cs
- ProjectionPathSegment.cs
- GetImportFileNameRequest.cs
- SocketPermission.cs
- SoapIgnoreAttribute.cs
- DataGridTablesFactory.cs
- VirtualizedContainerService.cs
- HtmlShim.cs
- AnchorEditor.cs
- CookieParameter.cs
- DocumentViewerBase.cs
- Baml2006KnownTypes.cs
- Oci.cs
- FocusChangedEventArgs.cs
- AuthenticationServiceManager.cs
- metrodevice.cs
- HttpSysSettings.cs
- ListParagraph.cs
- Int64KeyFrameCollection.cs
- NumericUpDownAccelerationCollection.cs
- BamlLocalizabilityResolver.cs
- XmlDataSourceView.cs
- ModuleBuilder.cs
- XmlSerializationWriter.cs
- EpmTargetPathSegment.cs
- Monitor.cs
- DataControlCommands.cs
- DetailsViewUpdateEventArgs.cs
- CompilerError.cs