Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- IPEndPoint.cs
- ExpressionBuilder.cs
- WebException.cs
- WindowsSolidBrush.cs
- ControlBuilder.cs
- ExportFileRequest.cs
- DebugInfo.cs
- RegexReplacement.cs
- XmlBindingWorker.cs
- TaiwanLunisolarCalendar.cs
- SafeLibraryHandle.cs
- NonClientArea.cs
- ProtocolsConfiguration.cs
- PerspectiveCamera.cs
- StdValidatorsAndConverters.cs
- LicenseException.cs
- RelationshipDetailsRow.cs
- Token.cs
- TemplateField.cs
- MediaElementAutomationPeer.cs
- DataRowView.cs
- SplineKeyFrames.cs
- TypeAccessException.cs
- BuildProvider.cs
- NTAccount.cs
- AuthenticationManager.cs
- FlowDocumentPageViewerAutomationPeer.cs
- PerspectiveCamera.cs
- DateRangeEvent.cs
- TypeDescriptionProvider.cs
- AccessDataSourceView.cs
- HierarchicalDataBoundControl.cs
- CustomErrorsSectionWrapper.cs
- SqlDataSourceConnectionPanel.cs
- _ConnectStream.cs
- EncryptedData.cs
- PerspectiveCamera.cs
- ConfigurationValue.cs
- TypeConverterValueSerializer.cs
- CanonicalXml.cs
- PreDigestedSignedInfo.cs
- StylusButton.cs
- DataGridViewHitTestInfo.cs
- IndexExpression.cs
- PathGeometry.cs
- WindowShowOrOpenTracker.cs
- SchemaNamespaceManager.cs
- LoginUtil.cs
- ApplicationSecurityManager.cs
- IsolatedStorageFilePermission.cs
- DocumentApplicationJournalEntry.cs
- List.cs
- FaultHandlingFilter.cs
- ProfileGroupSettings.cs
- OperationResponse.cs
- SmtpNtlmAuthenticationModule.cs
- InternalDispatchObject.cs
- RootCodeDomSerializer.cs
- ListViewAutomationPeer.cs
- BehaviorEditorPart.cs
- PageEventArgs.cs
- _SslState.cs
- DrawingImage.cs
- Vector3DAnimation.cs
- DataGridRowHeader.cs
- PolyQuadraticBezierSegment.cs
- SamlAttribute.cs
- ScaleTransform3D.cs
- FormatVersion.cs
- RtfNavigator.cs
- SocketElement.cs
- Module.cs
- TagPrefixAttribute.cs
- AttachedPropertyBrowsableForTypeAttribute.cs
- PenCursorManager.cs
- WebPartVerb.cs
- AddInIpcChannel.cs
- FocusManager.cs
- HttpCacheVaryByContentEncodings.cs
- SoapReflectionImporter.cs
- ToolStripRendererSwitcher.cs
- BrowserDefinitionCollection.cs
- DocumentPageHost.cs
- BamlTreeNode.cs
- sqlnorm.cs
- DesignerLoader.cs
- SqlCaseSimplifier.cs
- XmlEncoding.cs
- SQLDouble.cs
- SoapSchemaExporter.cs
- EntityDataSourceMemberPath.cs
- CodeGotoStatement.cs
- ProtocolState.cs
- VirtualizingPanel.cs
- _NegoState.cs
- DataSysAttribute.cs
- HyperlinkAutomationPeer.cs
- TextPenaltyModule.cs
- Cloud.cs
- RepeatButtonAutomationPeer.cs