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
- WindowManager.cs
- JsonUriDataContract.cs
- IgnoreDeviceFilterElement.cs
- DiagnosticsElement.cs
- DashStyle.cs
- DataViewListener.cs
- TextEncodedRawTextWriter.cs
- RecipientInfo.cs
- CompressionTracing.cs
- TypeContext.cs
- WebPageTraceListener.cs
- TypeForwardedToAttribute.cs
- RSAPKCS1SignatureFormatter.cs
- HtmlLink.cs
- Itemizer.cs
- ProfileEventArgs.cs
- VirtualPathProvider.cs
- TextTreePropertyUndoUnit.cs
- InstancePersistenceCommandException.cs
- LogEntrySerializationException.cs
- DocumentReference.cs
- DataBinder.cs
- documentsequencetextview.cs
- TextHidden.cs
- GridProviderWrapper.cs
- QilScopedVisitor.cs
- MonthChangedEventArgs.cs
- DataGridColumnCollection.cs
- ListItem.cs
- DataGridViewLayoutData.cs
- NestPullup.cs
- LoadRetryConstantStrategy.cs
- ClientSettings.cs
- DbDataAdapter.cs
- Registration.cs
- _NegotiateClient.cs
- ArglessEventHandlerProxy.cs
- Int32EqualityComparer.cs
- ScrollChrome.cs
- GridViewRow.cs
- EntityClassGenerator.cs
- ResourceProviderFactory.cs
- HotCommands.cs
- RunInstallerAttribute.cs
- ResourceCodeDomSerializer.cs
- SafeCryptoHandles.cs
- SiteMapNode.cs
- HandleRef.cs
- SqlDataSourceFilteringEventArgs.cs
- BindingOperations.cs
- EntitySetBase.cs
- SelectedDatesCollection.cs
- ColumnHeaderConverter.cs
- UrlAuthorizationModule.cs
- TripleDES.cs
- FullTextLine.cs
- TypeBinaryExpression.cs
- ModuleConfigurationInfo.cs
- X509ChainElement.cs
- OutputCacheSection.cs
- DrawingBrush.cs
- StreamAsIStream.cs
- QueryCacheManager.cs
- ValueSerializer.cs
- Sql8ConformanceChecker.cs
- ToolStripItemDesigner.cs
- documentsequencetextview.cs
- FormsAuthenticationCredentials.cs
- ObjectDataSourceDesigner.cs
- GeneralTransform3D.cs
- StorageBasedPackageProperties.cs
- FormsAuthenticationUserCollection.cs
- GridViewRowCollection.cs
- ModelItemKeyValuePair.cs
- XhtmlTextWriter.cs
- DirectionalLight.cs
- RenderOptions.cs
- PointValueSerializer.cs
- SizeFConverter.cs
- HttpResponseHeader.cs
- LayoutTable.cs
- GeneralTransform3DGroup.cs
- NativeWindow.cs
- EntityClientCacheKey.cs
- VoiceInfo.cs
- WebServiceTypeData.cs
- ProfileProvider.cs
- SchemaMapping.cs
- DataContext.cs
- XmlIgnoreAttribute.cs
- FeatureAttribute.cs
- AdornerDecorator.cs
- WhitespaceReader.cs
- DesignTimeParseData.cs
- BackgroundFormatInfo.cs
- SqlAliaser.cs
- StackBuilderSink.cs
- PageAdapter.cs
- Point3DCollectionConverter.cs
- RoleGroup.cs