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
- QilLoop.cs
- TextBlock.cs
- EventArgs.cs
- SQLGuid.cs
- PrintControllerWithStatusDialog.cs
- ObjectStateManager.cs
- X509Utils.cs
- ValidatorCompatibilityHelper.cs
- OrderByLifter.cs
- ChannelDispatcher.cs
- ThreadAttributes.cs
- MailMessageEventArgs.cs
- LookupBindingPropertiesAttribute.cs
- MergePropertyDescriptor.cs
- EmptyQuery.cs
- DataTableClearEvent.cs
- SqlRecordBuffer.cs
- StylusOverProperty.cs
- TagPrefixCollection.cs
- NonSerializedAttribute.cs
- DesignerTransactionCloseEvent.cs
- HttpServerProtocol.cs
- WrapPanel.cs
- ClientType.cs
- CatchBlock.cs
- TextDecorationUnitValidation.cs
- TimeSpanStorage.cs
- PriorityBindingExpression.cs
- InputMethodStateChangeEventArgs.cs
- KeyGestureValueSerializer.cs
- filewebresponse.cs
- HyperlinkAutomationPeer.cs
- CellTreeNode.cs
- RowToFieldTransformer.cs
- ReadOnlyDictionary.cs
- SourceItem.cs
- InternalSafeNativeMethods.cs
- XamlInt32CollectionSerializer.cs
- DataGridViewCellStateChangedEventArgs.cs
- NavigationFailedEventArgs.cs
- ServiceProviders.cs
- SecUtil.cs
- FusionWrap.cs
- dataobject.cs
- ObjectListDesigner.cs
- _IPv4Address.cs
- PageThemeCodeDomTreeGenerator.cs
- CqlIdentifiers.cs
- RunWorkerCompletedEventArgs.cs
- SqlParameterizer.cs
- String.cs
- SymmetricCryptoHandle.cs
- PropertyReference.cs
- CharKeyFrameCollection.cs
- ISO2022Encoding.cs
- HttpDigestClientElement.cs
- PeerEndPoint.cs
- ImageKeyConverter.cs
- HostedHttpRequestAsyncResult.cs
- BindingMemberInfo.cs
- StaticResourceExtension.cs
- SQLInt16.cs
- UIElementParaClient.cs
- BrowserCapabilitiesCompiler.cs
- SoapMessage.cs
- EastAsianLunisolarCalendar.cs
- ChannelManager.cs
- Expression.cs
- ConstrainedDataObject.cs
- DataKeyArray.cs
- NTAccount.cs
- SubqueryTrackingVisitor.cs
- HttpHeaderCollection.cs
- PreviewKeyDownEventArgs.cs
- ZipFileInfoCollection.cs
- SessionEndingCancelEventArgs.cs
- AttachedAnnotationChangedEventArgs.cs
- ApplicationBuildProvider.cs
- BooleanSwitch.cs
- ProjectionNode.cs
- CalendarAutoFormatDialog.cs
- ISAPIWorkerRequest.cs
- Help.cs
- DecoderNLS.cs
- GenericEnumConverter.cs
- Separator.cs
- SqlGenericUtil.cs
- XmlChildEnumerator.cs
- DesignerObjectListAdapter.cs
- ComponentGuaranteesAttribute.cs
- SecurityManager.cs
- XmlSignificantWhitespace.cs
- CorePropertiesFilter.cs
- IncomingWebRequestContext.cs
- ObjectSet.cs
- PackageRelationship.cs
- DynamicAttribute.cs
- RecipientInfo.cs
- XhtmlBasicValidationSummaryAdapter.cs
- ColorTransformHelper.cs