Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Extensions / UI / WebControls / Expressions / OfTypeExpression.cs / 1305376 / OfTypeExpression.cs
#if ORYX_VNEXT namespace Microsoft.Web.Data.UI.WebControls.Expressions { #else namespace System.Web.UI.WebControls.Expressions { #endif using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Web.Compilation; using System.Web.Resources; using System; using System.Web.UI; public class OfTypeExpression : DataSourceExpression { private MethodInfo _ofTypeMethod; private string _typeName; private MethodInfo OfTypeMethod { get { if (_ofTypeMethod == null) { var type = GetType(TypeName); _ofTypeMethod = GetOfTypeMethod(type); } return _ofTypeMethod; } } [DefaultValue("")] public string TypeName { get { return _typeName ?? String.Empty; } set { if (TypeName != value) { _typeName = value; _ofTypeMethod = null; } } } public OfTypeExpression() { } public OfTypeExpression(Type type) { if (type == null) { throw new ArgumentNullException("type"); } TypeName = type.AssemblyQualifiedName; _ofTypeMethod = GetOfTypeMethod(type); } // internal for unit testing internal OfTypeExpression(Control owner) : base(owner) { } private Type GetType(string typeName) { if (String.IsNullOrEmpty(typeName)) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, AtlasWeb.OfTypeExpression_TypeNameNotSpecified, Owner.ID)); } try { return BuildManager.GetType(typeName, true /* throwOnError */, true /* ignoreCase */); } catch (Exception e) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, AtlasWeb.OfTypeExpression_CannotFindType, typeName, Owner.ID), e); } } private static MethodInfo GetOfTypeMethod(Type type) { Debug.Assert(type != null); return typeof(Queryable).GetMethod("OfType").MakeGenericMethod(new Type[] { type }); } public override IQueryable GetQueryable(IQueryable query) { return query.Provider.CreateQuery(Expression.Call(null, OfTypeMethod, query.Expression)); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. #if ORYX_VNEXT namespace Microsoft.Web.Data.UI.WebControls.Expressions { #else namespace System.Web.UI.WebControls.Expressions { #endif using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Web.Compilation; using System.Web.Resources; using System; using System.Web.UI; public class OfTypeExpression : DataSourceExpression { private MethodInfo _ofTypeMethod; private string _typeName; private MethodInfo OfTypeMethod { get { if (_ofTypeMethod == null) { var type = GetType(TypeName); _ofTypeMethod = GetOfTypeMethod(type); } return _ofTypeMethod; } } [DefaultValue("")] public string TypeName { get { return _typeName ?? String.Empty; } set { if (TypeName != value) { _typeName = value; _ofTypeMethod = null; } } } public OfTypeExpression() { } public OfTypeExpression(Type type) { if (type == null) { throw new ArgumentNullException("type"); } TypeName = type.AssemblyQualifiedName; _ofTypeMethod = GetOfTypeMethod(type); } // internal for unit testing internal OfTypeExpression(Control owner) : base(owner) { } private Type GetType(string typeName) { if (String.IsNullOrEmpty(typeName)) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, AtlasWeb.OfTypeExpression_TypeNameNotSpecified, Owner.ID)); } try { return BuildManager.GetType(typeName, true /* throwOnError */, true /* ignoreCase */); } catch (Exception e) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, AtlasWeb.OfTypeExpression_CannotFindType, typeName, Owner.ID), e); } } private static MethodInfo GetOfTypeMethod(Type type) { Debug.Assert(type != null); return typeof(Queryable).GetMethod("OfType").MakeGenericMethod(new Type[] { type }); } public override IQueryable GetQueryable(IQueryable query) { return query.Provider.CreateQuery(Expression.Call(null, OfTypeMethod, query.Expression)); } } } // 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
- PropertyPathWorker.cs
- UserControl.cs
- ImageAttributes.cs
- UpdateManifestForBrowserApplication.cs
- MsmqUri.cs
- TrackingProfileCache.cs
- DataKeyArray.cs
- DataGridCaption.cs
- CodeDomConfigurationHandler.cs
- DBDataPermissionAttribute.cs
- WizardStepBase.cs
- CommunicationException.cs
- LinqDataSourceInsertEventArgs.cs
- ContextStaticAttribute.cs
- StackSpiller.Bindings.cs
- OutOfMemoryException.cs
- NumberSubstitution.cs
- StatusStrip.cs
- AsyncOperationContext.cs
- ElementHost.cs
- NativeMethods.cs
- DtrList.cs
- Emitter.cs
- RuntimeConfig.cs
- SchemaReference.cs
- DataPointer.cs
- XmlTextReaderImpl.cs
- TableLayoutPanelCodeDomSerializer.cs
- Sorting.cs
- TreeView.cs
- SurrogateEncoder.cs
- XmlCharacterData.cs
- ActiveXHelper.cs
- BasicExpressionVisitor.cs
- SubMenuStyleCollection.cs
- StringAttributeCollection.cs
- CodeThrowExceptionStatement.cs
- UnsafeNativeMethods.cs
- SourceItem.cs
- HtmlEmptyTagControlBuilder.cs
- MouseButton.cs
- IPGlobalProperties.cs
- MenuItemBinding.cs
- DrawingContextDrawingContextWalker.cs
- TextFormatterHost.cs
- WrappedOptions.cs
- LexicalChunk.cs
- ProxyWebPartManager.cs
- SoapTypeAttribute.cs
- SqlNotificationEventArgs.cs
- TemplateControlCodeDomTreeGenerator.cs
- CqlParserHelpers.cs
- SplayTreeNode.cs
- TextDecorations.cs
- WizardSideBarListControlItem.cs
- ResourceProperty.cs
- Signature.cs
- VerificationAttribute.cs
- Vector3DAnimation.cs
- BitConverter.cs
- DataSourceExpression.cs
- TextBounds.cs
- PageCodeDomTreeGenerator.cs
- StaticFileHandler.cs
- UiaCoreTypesApi.cs
- TreeNodeCollection.cs
- MatrixValueSerializer.cs
- WeakReferenceEnumerator.cs
- StylusPointDescription.cs
- ImageIndexConverter.cs
- XPathPatternBuilder.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- RemotingException.cs
- SmtpSection.cs
- TimeIntervalCollection.cs
- DataProtection.cs
- SpellCheck.cs
- PresentationTraceSources.cs
- InvalidPrinterException.cs
- EpmCustomContentSerializer.cs
- DataGridViewComboBoxEditingControl.cs
- ValidatingPropertiesEventArgs.cs
- NumberFunctions.cs
- FrameworkContextData.cs
- XmlWhitespace.cs
- VBCodeProvider.cs
- CTreeGenerator.cs
- ObjRef.cs
- SafeProcessHandle.cs
- ScriptingRoleServiceSection.cs
- TraceSection.cs
- Utils.cs
- ListItemParagraph.cs
- DataGridViewComboBoxEditingControl.cs
- SystemIcmpV4Statistics.cs
- HtmlTextArea.cs
- CodeTypeParameter.cs
- RepeatButton.cs
- TraceData.cs
- Scheduler.cs