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
- SiteMapSection.cs
- DivideByZeroException.cs
- Array.cs
- URL.cs
- DataRecordInfo.cs
- RootNamespaceAttribute.cs
- KeyValueSerializer.cs
- EntityDataSourceConfigureObjectContext.cs
- Context.cs
- FtpCachePolicyElement.cs
- HttpCachePolicy.cs
- StylusShape.cs
- ProtectedConfiguration.cs
- Point3DCollection.cs
- TreeBuilderBamlTranslator.cs
- SQLInt16Storage.cs
- ExpandableObjectConverter.cs
- ToolStrip.cs
- ToggleButtonAutomationPeer.cs
- ServiceProviders.cs
- MediaScriptCommandRoutedEventArgs.cs
- StrokeRenderer.cs
- ListViewGroupItemCollection.cs
- UseAttributeSetsAction.cs
- x509store.cs
- Types.cs
- IndentTextWriter.cs
- SRef.cs
- PreservationFileWriter.cs
- ScriptResourceAttribute.cs
- Single.cs
- StylusPointPropertyId.cs
- FileDialogCustomPlacesCollection.cs
- DataListItemEventArgs.cs
- BaseDataListActionList.cs
- FieldNameLookup.cs
- HostedBindingBehavior.cs
- ViewStateException.cs
- OwnerDrawPropertyBag.cs
- Point3D.cs
- Mutex.cs
- securitycriticaldata.cs
- RemoteAsymmetricSignatureFormatter.cs
- Quaternion.cs
- ActivitySurrogateSelector.cs
- AssemblyInfo.cs
- HMAC.cs
- RouteTable.cs
- PropertyBuilder.cs
- Axis.cs
- LinqDataSourceValidationException.cs
- SiteMapNodeItemEventArgs.cs
- GridViewRowCollection.cs
- RegexInterpreter.cs
- RawStylusActions.cs
- ImportContext.cs
- smtpconnection.cs
- EncryptedData.cs
- ForceCopyBuildProvider.cs
- UpdateManifestForBrowserApplication.cs
- CodeTypeParameter.cs
- OutKeywords.cs
- FileDialogPermission.cs
- JapaneseCalendar.cs
- NetNamedPipeSecurityElement.cs
- XmlSchemaImport.cs
- TypefaceMap.cs
- DefaultEventAttribute.cs
- NativeMethods.cs
- OperatingSystem.cs
- Rect3D.cs
- LinkedDataMemberFieldEditor.cs
- XmlNodeChangedEventManager.cs
- RequestSecurityTokenForRemoteTokenFactory.cs
- ValidationService.cs
- CLRBindingWorker.cs
- SafeProcessHandle.cs
- KeyNotFoundException.cs
- SqlRowUpdatingEvent.cs
- TextPenaltyModule.cs
- SequentialOutput.cs
- DataGridRow.cs
- OleDbException.cs
- UriTemplatePathPartiallyEquivalentSet.cs
- SapiRecoInterop.cs
- AsyncResult.cs
- EventRouteFactory.cs
- AspNetCompatibilityRequirementsAttribute.cs
- XmlUtil.cs
- TrustManagerPromptUI.cs
- TemplateBuilder.cs
- NamespaceList.cs
- xmlNames.cs
- DocumentXPathNavigator.cs
- HitTestWithGeometryDrawingContextWalker.cs
- LinkDesigner.cs
- TextEncodedRawTextWriter.cs
- OrderedDictionaryStateHelper.cs
- SparseMemoryStream.cs
- Container.cs