Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / DynamicData / DynamicData / SimpleFieldTemplateFactory.cs / 1305376 / SimpleFieldTemplateFactory.cs
namespace System.Web.DynamicData { using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web.UI.WebControls; using System.Web.Hosting; // This FieldTemplateFactory is used for the simple cases where the user doesn't have // a FieldTemplate directory but wants to get basic validation logic. In a sense // it is a smarter version of a BoundField internal class SimpleFieldTemplateFactory : FieldTemplateFactory { private static bool? _directoryExists; public SimpleFieldTemplateFactory() : this(HostingEnvironment.VirtualPathProvider) { } internal SimpleFieldTemplateFactory(VirtualPathProvider vpp) : base(vpp) { VirtualPathProvider = vpp; } internal VirtualPathProvider VirtualPathProvider { get; set; } protected virtual bool DirectoryExists { get { if (!_directoryExists.HasValue) { // This is expensive so cache it. _directoryExists = VirtualPathProvider.DirectoryExists(TemplateFolderVirtualPath); } return _directoryExists.Value; } } public override IFieldTemplate CreateFieldTemplate(MetaColumn column, DataBoundControlMode mode, string uiHint) { // Call Preprocess mode so that we do set the right mode base on the the column's attributes mode = PreprocessMode(column, mode); bool readOnly = (mode == DataBoundControlMode.ReadOnly); // If the folder doesn't exist use the fallback if (!DirectoryExists) { return CreateFieldTemplate(readOnly, column); } // Always see check if the base found anything first then fall back to the simple field template IFieldTemplate fieldTemplate = base.CreateFieldTemplate(column, mode, uiHint); // If there was no field template found and the user specified a uiHint then use the default behavior if (!String.IsNullOrEmpty(uiHint)) { return fieldTemplate; } return fieldTemplate ?? CreateFieldTemplate(readOnly, column); } private IFieldTemplate CreateFieldTemplate(bool readOnly, MetaColumn column) { // By default we'll support checkbox fields for boolean and a textbox for // everything else if (column.ColumnType == typeof(bool)) { return SimpleFieldTemplateUserControl.CreateBooleanTemplate(readOnly); } return SimpleFieldTemplateUserControl.CreateTextTemplate(column, readOnly); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. namespace System.Web.DynamicData { using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web.UI.WebControls; using System.Web.Hosting; // This FieldTemplateFactory is used for the simple cases where the user doesn't have // a FieldTemplate directory but wants to get basic validation logic. In a sense // it is a smarter version of a BoundField internal class SimpleFieldTemplateFactory : FieldTemplateFactory { private static bool? _directoryExists; public SimpleFieldTemplateFactory() : this(HostingEnvironment.VirtualPathProvider) { } internal SimpleFieldTemplateFactory(VirtualPathProvider vpp) : base(vpp) { VirtualPathProvider = vpp; } internal VirtualPathProvider VirtualPathProvider { get; set; } protected virtual bool DirectoryExists { get { if (!_directoryExists.HasValue) { // This is expensive so cache it. _directoryExists = VirtualPathProvider.DirectoryExists(TemplateFolderVirtualPath); } return _directoryExists.Value; } } public override IFieldTemplate CreateFieldTemplate(MetaColumn column, DataBoundControlMode mode, string uiHint) { // Call Preprocess mode so that we do set the right mode base on the the column's attributes mode = PreprocessMode(column, mode); bool readOnly = (mode == DataBoundControlMode.ReadOnly); // If the folder doesn't exist use the fallback if (!DirectoryExists) { return CreateFieldTemplate(readOnly, column); } // Always see check if the base found anything first then fall back to the simple field template IFieldTemplate fieldTemplate = base.CreateFieldTemplate(column, mode, uiHint); // If there was no field template found and the user specified a uiHint then use the default behavior if (!String.IsNullOrEmpty(uiHint)) { return fieldTemplate; } return fieldTemplate ?? CreateFieldTemplate(readOnly, column); } private IFieldTemplate CreateFieldTemplate(bool readOnly, MetaColumn column) { // By default we'll support checkbox fields for boolean and a textbox for // everything else if (column.ColumnType == typeof(bool)) { return SimpleFieldTemplateUserControl.CreateBooleanTemplate(readOnly); } return SimpleFieldTemplateUserControl.CreateTextTemplate(column, readOnly); } } } // 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
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- SoapIncludeAttribute.cs
- Stack.cs
- WorkflowInstanceQuery.cs
- FlowDocumentFormatter.cs
- IconConverter.cs
- TableDesigner.cs
- InlinedAggregationOperatorEnumerator.cs
- CompilationSection.cs
- SymmetricKeyWrap.cs
- SchemaNotation.cs
- HostingEnvironmentSection.cs
- AuthenticationService.cs
- StylusPlugin.cs
- RIPEMD160.cs
- WindowsEditBox.cs
- TextRenderer.cs
- PreloadedPackages.cs
- ComboBox.cs
- PageTheme.cs
- WmlListAdapter.cs
- RoutingExtensionElement.cs
- RemotingException.cs
- PositiveTimeSpanValidator.cs
- ProviderIncompatibleException.cs
- ShapingEngine.cs
- QilBinary.cs
- CodeSpit.cs
- SqlConnection.cs
- HelloMessageApril2005.cs
- MenuItemCollectionEditorDialog.cs
- ListViewUpdatedEventArgs.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- ListenerElementsCollection.cs
- AssemblyFilter.cs
- DataSysAttribute.cs
- RsaElement.cs
- WebServiceResponseDesigner.cs
- ConfigurationValidatorBase.cs
- XPathDocumentNavigator.cs
- SessionSymmetricMessageSecurityProtocolFactory.cs
- Region.cs
- WebUtility.cs
- OdbcCommandBuilder.cs
- FileStream.cs
- StrongNameUtility.cs
- User.cs
- AsyncOperation.cs
- XmlEnumAttribute.cs
- ReflectionUtil.cs
- ItemContainerGenerator.cs
- SessionIDManager.cs
- WebRequestModuleElement.cs
- FileAuthorizationModule.cs
- BindingContext.cs
- TemplateXamlParser.cs
- UrlPath.cs
- WebPartExportVerb.cs
- HandlerWithFactory.cs
- EventArgs.cs
- Filter.cs
- HtmlMobileTextWriter.cs
- SystemResources.cs
- __ComObject.cs
- DragAssistanceManager.cs
- InheritedPropertyChangedEventArgs.cs
- XmlSiteMapProvider.cs
- DiscoveryDocumentSerializer.cs
- MulticastDelegate.cs
- FamilyMap.cs
- ModelTreeEnumerator.cs
- CachedFontFamily.cs
- Solver.cs
- CreateUserWizardAutoFormat.cs
- AuthenticationModuleElementCollection.cs
- Selection.cs
- PropertyEmitterBase.cs
- TitleStyle.cs
- WSFederationHttpSecurityElement.cs
- SqlBulkCopyColumnMapping.cs
- IdentityValidationException.cs
- BorderGapMaskConverter.cs
- ObjectDataSourceMethodEventArgs.cs
- ConfigurationValidatorAttribute.cs
- StringSource.cs
- ExeConfigurationFileMap.cs
- StatusBarPanelClickEvent.cs
- ComponentRenameEvent.cs
- RawUIStateInputReport.cs
- QueryAccessibilityHelpEvent.cs
- DrawingGroupDrawingContext.cs
- CapabilitiesState.cs
- KeyBinding.cs
- DateTimeParse.cs
- MetaTableHelper.cs
- ColumnResizeUndoUnit.cs
- CaseInsensitiveHashCodeProvider.cs
- SmtpClient.cs
- GridViewRowCollection.cs
- WebServiceEnumData.cs