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
- SecurityHelper.cs
- Inline.cs
- ListItem.cs
- SkewTransform.cs
- RecommendedAsConfigurableAttribute.cs
- XamlTypeMapper.cs
- TextFormatterImp.cs
- IfJoinedCondition.cs
- DrawingCollection.cs
- Solver.cs
- x509store.cs
- ExpandButtonVisibilityConverter.cs
- HtmlObjectListAdapter.cs
- SingleStorage.cs
- _CookieModule.cs
- MustUnderstandBehavior.cs
- HierarchicalDataSourceDesigner.cs
- ThreadAbortException.cs
- QilInvoke.cs
- XmlSerializerSection.cs
- EntityCommandDefinition.cs
- CollectionBuilder.cs
- XmlObjectSerializerReadContextComplexJson.cs
- EmissiveMaterial.cs
- ILGenerator.cs
- FontDialog.cs
- FileDataSourceCache.cs
- SqlCommandAsyncResult.cs
- cookieexception.cs
- ProvidersHelper.cs
- ACL.cs
- UserThread.cs
- Number.cs
- DataTableReader.cs
- ClipboardProcessor.cs
- EventMemberCodeDomSerializer.cs
- WorkflowLayouts.cs
- dataobject.cs
- Base64Stream.cs
- StreamReader.cs
- SerializableTypeCodeDomSerializer.cs
- Vector3DAnimationUsingKeyFrames.cs
- GraphicsState.cs
- TextClipboardData.cs
- KeyConverter.cs
- SocketException.cs
- DataGridViewImageColumn.cs
- MouseButton.cs
- PauseStoryboard.cs
- SchemaImporter.cs
- ComplexPropertyEntry.cs
- XmlWriter.cs
- ServerValidateEventArgs.cs
- TextDecorationCollection.cs
- ProxyGenerationError.cs
- ContainsRowNumberChecker.cs
- NativeMethods.cs
- LocalValueEnumerator.cs
- SchemaTypeEmitter.cs
- BrushValueSerializer.cs
- ChannelManagerService.cs
- ExtensionQuery.cs
- TableParagraph.cs
- BrowserTree.cs
- DataSourceXmlClassAttribute.cs
- ContentFilePart.cs
- StoreItemCollection.cs
- MetadataConversionError.cs
- ExpandableObjectConverter.cs
- ResourceWriter.cs
- FileDialogCustomPlace.cs
- SchemaImporterExtensionsSection.cs
- HandoffBehavior.cs
- DocumentViewer.cs
- basenumberconverter.cs
- SeparatorAutomationPeer.cs
- PackWebRequest.cs
- IgnoreFileBuildProvider.cs
- XmlChoiceIdentifierAttribute.cs
- PropertyGrid.cs
- TextWriterEngine.cs
- Menu.cs
- SystemIcmpV4Statistics.cs
- BuildProvidersCompiler.cs
- SyntaxCheck.cs
- SpinWait.cs
- ButtonBase.cs
- DefaultDialogButtons.cs
- LayoutSettings.cs
- ElementsClipboardData.cs
- HtmlAnchor.cs
- GridViewCommandEventArgs.cs
- AlternationConverter.cs
- ScrollPatternIdentifiers.cs
- xdrvalidator.cs
- ListMarkerSourceInfo.cs
- XmlTextWriter.cs
- Thumb.cs
- DesignerCategoryAttribute.cs
- OptimizedTemplateContent.cs