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
- AnnotationService.cs
- PrimarySelectionAdorner.cs
- _SslSessionsCache.cs
- SignatureHelper.cs
- util.cs
- ButtonAutomationPeer.cs
- EntityViewGenerationAttribute.cs
- MessagingDescriptionAttribute.cs
- UInt16Storage.cs
- Native.cs
- GenericNameHandler.cs
- AddInProcess.cs
- MenuItemStyle.cs
- ComAdminWrapper.cs
- EntityParameter.cs
- GraphicsPath.cs
- TextEditorParagraphs.cs
- BitmapEffectvisualstate.cs
- LayoutSettings.cs
- FocusManager.cs
- _NegotiateClient.cs
- ConstNode.cs
- TextDecorationCollectionConverter.cs
- Blend.cs
- CodeTypeReferenceCollection.cs
- PreProcessor.cs
- SafeProcessHandle.cs
- ApplicationHost.cs
- ProcessRequestArgs.cs
- XmlDataCollection.cs
- cookiecontainer.cs
- CompilerErrorCollection.cs
- coordinatorscratchpad.cs
- SimpleType.cs
- OrCondition.cs
- TickBar.cs
- SqlReorderer.cs
- XsltQilFactory.cs
- DataGridViewDataErrorEventArgs.cs
- AttributeSetAction.cs
- DesignTimeTemplateParser.cs
- propertyentry.cs
- HwndSubclass.cs
- DispatcherEventArgs.cs
- HttpHandlersSection.cs
- SqlGenericUtil.cs
- BCryptHashAlgorithm.cs
- OleDbConnectionInternal.cs
- PermissionAttributes.cs
- Triplet.cs
- XPathDocumentNavigator.cs
- EditorOptionAttribute.cs
- ProcessHostConfigUtils.cs
- IgnoreFileBuildProvider.cs
- BindingMemberInfo.cs
- ToolboxDataAttribute.cs
- BamlRecordHelper.cs
- BasePropertyDescriptor.cs
- DesignerCalendarAdapter.cs
- loginstatus.cs
- GeometryHitTestResult.cs
- PathGradientBrush.cs
- UnsettableComboBox.cs
- ResXResourceReader.cs
- ProfilePropertySettingsCollection.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- SessionPageStatePersister.cs
- PngBitmapDecoder.cs
- DBSqlParser.cs
- InputLanguageSource.cs
- MeshGeometry3D.cs
- PermissionAttributes.cs
- SizeAnimation.cs
- PeerNameRegistration.cs
- PreProcessor.cs
- CapiSafeHandles.cs
- DbProviderSpecificTypePropertyAttribute.cs
- DynamicField.cs
- LayoutEditorPart.cs
- XmlSchemaInclude.cs
- basecomparevalidator.cs
- WorkflowRuntimeSection.cs
- XpsStructure.cs
- Size.cs
- InteropTrackingRecord.cs
- CurrentChangingEventArgs.cs
- CfgSemanticTag.cs
- TextSelection.cs
- FormViewCommandEventArgs.cs
- DataGridViewTextBoxEditingControl.cs
- ThemeableAttribute.cs
- HitTestDrawingContextWalker.cs
- TemplatedMailWebEventProvider.cs
- DockPatternIdentifiers.cs
- CollectionConverter.cs
- IpcPort.cs
- SafeTimerHandle.cs
- XMLSchema.cs
- CanExecuteRoutedEventArgs.cs
- DoubleAnimationUsingPath.cs