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
- DataGridItem.cs
- NativeStructs.cs
- KeySpline.cs
- OdbcUtils.cs
- DataBoundControlAdapter.cs
- HierarchicalDataBoundControlAdapter.cs
- SendingRequestEventArgs.cs
- RectConverter.cs
- StorageInfo.cs
- HyperLinkField.cs
- TaskHelper.cs
- CheckBoxList.cs
- ExpressionPrefixAttribute.cs
- AvTraceFormat.cs
- ExtentKey.cs
- CompositeScriptReference.cs
- GridViewItemAutomationPeer.cs
- ProcessProtocolHandler.cs
- SafeFileHandle.cs
- IdentityNotMappedException.cs
- XmlQuerySequence.cs
- TypeNameConverter.cs
- FileIOPermission.cs
- ResourceReferenceExpression.cs
- DataGridViewLinkCell.cs
- DiscoveryDocumentSearchPattern.cs
- PieceNameHelper.cs
- FileDialogCustomPlace.cs
- PriorityQueue.cs
- MsmqChannelFactory.cs
- BamlLocalizableResource.cs
- CollectionConverter.cs
- WinEventTracker.cs
- EncodingNLS.cs
- SettingsContext.cs
- PageStatePersister.cs
- Floater.cs
- EventDescriptor.cs
- MimeTypeMapper.cs
- CollectionConverter.cs
- FileRecordSequenceHelper.cs
- ProcessHostMapPath.cs
- SelectionRange.cs
- EntitySqlQueryCacheKey.cs
- DisplayNameAttribute.cs
- DelegateHelpers.cs
- AppAction.cs
- AttributeData.cs
- NullRuntimeConfig.cs
- KeyInfo.cs
- WebPartActionVerb.cs
- HttpPostedFileBase.cs
- InfoCardClaim.cs
- LineGeometry.cs
- WebControlAdapter.cs
- SectionInput.cs
- CodeTypeParameter.cs
- InertiaRotationBehavior.cs
- XmlElement.cs
- QueryExpr.cs
- OleDbPermission.cs
- X509Chain.cs
- ListManagerBindingsCollection.cs
- HiddenFieldPageStatePersister.cs
- StrongNameIdentityPermission.cs
- SecurityContext.cs
- BaseInfoTable.cs
- CodeTypeDeclarationCollection.cs
- ErrorProvider.cs
- RayMeshGeometry3DHitTestResult.cs
- ComboBoxRenderer.cs
- ButtonRenderer.cs
- LinkUtilities.cs
- WhitespaceSignificantCollectionAttribute.cs
- CharUnicodeInfo.cs
- XmlSerializerFactory.cs
- DynamicRenderer.cs
- Method.cs
- PatternMatcher.cs
- LinqDataSourceValidationException.cs
- DbMetaDataColumnNames.cs
- RegexEditorDialog.cs
- PointHitTestParameters.cs
- DecoderExceptionFallback.cs
- ItemCollection.cs
- MD5HashHelper.cs
- Win32NamedPipes.cs
- HttpRawResponse.cs
- ParenthesizePropertyNameAttribute.cs
- XmlStringTable.cs
- WebPartZone.cs
- BuildDependencySet.cs
- CacheDependency.cs
- StaticResourceExtension.cs
- DocumentPageViewAutomationPeer.cs
- ProbeDuplexAsyncResult.cs
- Vector.cs
- StoreItemCollection.cs
- UpdatePanel.cs
- XPathItem.cs