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
- VirtualizedContainerService.cs
- Query.cs
- XNodeValidator.cs
- SelectorItemAutomationPeer.cs
- CustomPopupPlacement.cs
- CreateSequenceResponse.cs
- Calendar.cs
- XamlNamespaceHelper.cs
- XmlChildNodes.cs
- SendParametersContent.cs
- Expression.cs
- SoapObjectInfo.cs
- ScriptingProfileServiceSection.cs
- DesignerAdapterUtil.cs
- BoundColumn.cs
- SelectiveScrollingGrid.cs
- ArraySortHelper.cs
- XmlDigitalSignatureProcessor.cs
- HostedBindingBehavior.cs
- DefaultParameterValueAttribute.cs
- XmlAttribute.cs
- ObjectQueryProvider.cs
- LinqDataSourceContextEventArgs.cs
- SvcMapFile.cs
- AssemblyName.cs
- MatrixConverter.cs
- UnsafeNativeMethods.cs
- FixedSOMTableCell.cs
- SQLBytesStorage.cs
- ComponentSerializationService.cs
- RadioButtonStandardAdapter.cs
- VectorValueSerializer.cs
- SmtpDigestAuthenticationModule.cs
- ToolboxService.cs
- HwndStylusInputProvider.cs
- WebPartTransformerAttribute.cs
- RefreshPropertiesAttribute.cs
- RangeValuePattern.cs
- CollectionType.cs
- ExpressionBindingCollection.cs
- MaskDescriptor.cs
- DictionaryBase.cs
- TextServicesContext.cs
- ListViewItemSelectionChangedEvent.cs
- Lock.cs
- MatchingStyle.cs
- XPathScanner.cs
- FixedSOMSemanticBox.cs
- TypeDescriptorContext.cs
- CapabilitiesSection.cs
- RecognitionEventArgs.cs
- CacheMode.cs
- MsmqHostedTransportManager.cs
- XmlNamedNodeMap.cs
- CustomExpressionEventArgs.cs
- Clipboard.cs
- IsolatedStorageFilePermission.cs
- FormCollection.cs
- QueryComponents.cs
- DbProviderServices.cs
- FullTrustAssembliesSection.cs
- Evaluator.cs
- SqlSelectStatement.cs
- CommandBindingCollection.cs
- RefExpr.cs
- StreamAsIStream.cs
- BooleanSwitch.cs
- DirectionalLight.cs
- DiscoveryDocumentReference.cs
- DetailsViewUpdateEventArgs.cs
- COM2Enum.cs
- securitycriticaldata.cs
- HttpResponseWrapper.cs
- ZipIOCentralDirectoryFileHeader.cs
- WindowsScroll.cs
- SapiRecognizer.cs
- PartialCachingControl.cs
- Schema.cs
- QueryInterceptorAttribute.cs
- KnownTypeDataContractResolver.cs
- LogStore.cs
- XmlObjectSerializerWriteContext.cs
- IHttpResponseInternal.cs
- WebBrowserSiteBase.cs
- TogglePattern.cs
- TimeSpan.cs
- DiscoveryServerProtocol.cs
- AttributeQuery.cs
- Evaluator.cs
- AssemblyLoader.cs
- AppDomain.cs
- Translator.cs
- PathSegment.cs
- TextInfo.cs
- TitleStyle.cs
- ReadOnlyMetadataCollection.cs
- ComponentSerializationService.cs
- ChangePassword.cs
- RightNameExpirationInfoPair.cs
- CultureInfo.cs