Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / Compilation / ClientBuildManagerTypeDescriptionProviderBridge.cs / 1305376 / ClientBuildManagerTypeDescriptionProviderBridge.cs
using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Reflection; using System.Web.Util; ////// This is a helper class lives in the VS appdomain where the CBM is created, and passed into the CBM-hosted appdomain /// to allow cross-appdomain calls to get filtered runtime member information. /// internal class ClientBuildManagerTypeDescriptionProviderBridge : MarshalByRefObject { private TypeDescriptionProvider _targetFrameworkProvider; internal ClientBuildManagerTypeDescriptionProviderBridge(TypeDescriptionProvider typeDescriptionProvider) { _targetFrameworkProvider = typeDescriptionProvider; } public override Object InitializeLifetimeService() { return null; // never expire lease } private Type GetReflectionType(Type type) { Debug.Assert(_targetFrameworkProvider != null, "_targetFrameworkProvider should not be null"); if (type == null) { return null; } return _targetFrameworkProvider.GetReflectionType(type); } internal bool HasProperty(Type type, string name, BindingFlags bindingAttr) { if (_targetFrameworkProvider == null) { PropertyInfo runtimePropInfo = type.GetProperty(name, bindingAttr); return runtimePropInfo != null; } Type reflectionType = GetReflectionType(type); PropertyInfo reflectionPropertyInfo = reflectionType.GetProperty(name, bindingAttr); return reflectionPropertyInfo != null; } internal bool HasField(Type type, string name, BindingFlags bindingAttr) { if (_targetFrameworkProvider == null) { FieldInfo runtimeFieldInfo = type.GetField(name, bindingAttr); return runtimeFieldInfo != null; } Type reflectionType = _targetFrameworkProvider.GetReflectionType(type); FieldInfo reflectionFieldInfo = reflectionType.GetField(name, bindingAttr); return reflectionFieldInfo != null; } internal bool HasEvent(Type type, string name) { if (_targetFrameworkProvider == null) { EventInfo runtimeEventInfo = type.GetEvent(name); return runtimeEventInfo != null; } Type reflectionType = _targetFrameworkProvider.GetReflectionType(type); EventInfo reflectionEventInfo = reflectionType.GetEvent(name); return reflectionEventInfo != null; } private string[] GetMemberNames(MemberInfo[] members) { var names = from m in members select m.Name; return names.ToArray(); } internal bool HasMethod(Type type, string name, BindingFlags bindingAttr) { Type reflectionType = type; if (_targetFrameworkProvider != null) { reflectionType = GetReflectionType(type); } MethodInfo methodInfo = reflectionType.GetMethod(name, bindingAttr); return methodInfo != null; } internal string[] GetFilteredProperties(Type type, BindingFlags bindingFlags) { PropertyInfo[] runtimeProperties = type.GetProperties(bindingFlags); if (_targetFrameworkProvider == null) { return GetMemberNames(runtimeProperties); } Type reflectionType = _targetFrameworkProvider.GetReflectionType(type); PropertyInfo[] reflectionProperties = reflectionType.GetProperties(bindingFlags); var reflectionPropertyNames = from p in reflectionProperties select p.Name; return (from p in runtimeProperties where reflectionPropertyNames.Contains(p.Name) select p.Name).ToArray(); } internal string[] GetFilteredEvents(Type type, BindingFlags bindingFlags) { EventInfo[] runtimeEvents= type.GetEvents(bindingFlags); if (_targetFrameworkProvider == null) { return GetMemberNames(runtimeEvents); } Type reflectionType = _targetFrameworkProvider.GetReflectionType(type); EventInfo[] reflectionEvents= reflectionType.GetEvents(bindingFlags); var reflectionEventNames = from e in reflectionEvents select e.Name; return (from e in runtimeEvents where reflectionEventNames.Contains(e.Name) select e.Name).ToArray(); } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Reflection; using System.Web.Util; ////// This is a helper class lives in the VS appdomain where the CBM is created, and passed into the CBM-hosted appdomain /// to allow cross-appdomain calls to get filtered runtime member information. /// internal class ClientBuildManagerTypeDescriptionProviderBridge : MarshalByRefObject { private TypeDescriptionProvider _targetFrameworkProvider; internal ClientBuildManagerTypeDescriptionProviderBridge(TypeDescriptionProvider typeDescriptionProvider) { _targetFrameworkProvider = typeDescriptionProvider; } public override Object InitializeLifetimeService() { return null; // never expire lease } private Type GetReflectionType(Type type) { Debug.Assert(_targetFrameworkProvider != null, "_targetFrameworkProvider should not be null"); if (type == null) { return null; } return _targetFrameworkProvider.GetReflectionType(type); } internal bool HasProperty(Type type, string name, BindingFlags bindingAttr) { if (_targetFrameworkProvider == null) { PropertyInfo runtimePropInfo = type.GetProperty(name, bindingAttr); return runtimePropInfo != null; } Type reflectionType = GetReflectionType(type); PropertyInfo reflectionPropertyInfo = reflectionType.GetProperty(name, bindingAttr); return reflectionPropertyInfo != null; } internal bool HasField(Type type, string name, BindingFlags bindingAttr) { if (_targetFrameworkProvider == null) { FieldInfo runtimeFieldInfo = type.GetField(name, bindingAttr); return runtimeFieldInfo != null; } Type reflectionType = _targetFrameworkProvider.GetReflectionType(type); FieldInfo reflectionFieldInfo = reflectionType.GetField(name, bindingAttr); return reflectionFieldInfo != null; } internal bool HasEvent(Type type, string name) { if (_targetFrameworkProvider == null) { EventInfo runtimeEventInfo = type.GetEvent(name); return runtimeEventInfo != null; } Type reflectionType = _targetFrameworkProvider.GetReflectionType(type); EventInfo reflectionEventInfo = reflectionType.GetEvent(name); return reflectionEventInfo != null; } private string[] GetMemberNames(MemberInfo[] members) { var names = from m in members select m.Name; return names.ToArray(); } internal bool HasMethod(Type type, string name, BindingFlags bindingAttr) { Type reflectionType = type; if (_targetFrameworkProvider != null) { reflectionType = GetReflectionType(type); } MethodInfo methodInfo = reflectionType.GetMethod(name, bindingAttr); return methodInfo != null; } internal string[] GetFilteredProperties(Type type, BindingFlags bindingFlags) { PropertyInfo[] runtimeProperties = type.GetProperties(bindingFlags); if (_targetFrameworkProvider == null) { return GetMemberNames(runtimeProperties); } Type reflectionType = _targetFrameworkProvider.GetReflectionType(type); PropertyInfo[] reflectionProperties = reflectionType.GetProperties(bindingFlags); var reflectionPropertyNames = from p in reflectionProperties select p.Name; return (from p in runtimeProperties where reflectionPropertyNames.Contains(p.Name) select p.Name).ToArray(); } internal string[] GetFilteredEvents(Type type, BindingFlags bindingFlags) { EventInfo[] runtimeEvents= type.GetEvents(bindingFlags); if (_targetFrameworkProvider == null) { return GetMemberNames(runtimeEvents); } Type reflectionType = _targetFrameworkProvider.GetReflectionType(type); EventInfo[] reflectionEvents= reflectionType.GetEvents(bindingFlags); var reflectionEventNames = from e in reflectionEvents select e.Name; return (from e in runtimeEvents where reflectionEventNames.Contains(e.Name) select e.Name).ToArray(); } } // 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
- DefaultValueTypeConverter.cs
- ManualResetEventSlim.cs
- RegularExpressionValidator.cs
- VisualTreeUtils.cs
- VerificationException.cs
- HttpRequestWrapper.cs
- AnimationClock.cs
- CompilerError.cs
- DBConcurrencyException.cs
- SparseMemoryStream.cs
- DesignTimeVisibleAttribute.cs
- _AuthenticationState.cs
- XmlSchemaAny.cs
- NegotiateStream.cs
- XmlSchemaChoice.cs
- AssemblyBuilderData.cs
- CurrentTimeZone.cs
- GifBitmapDecoder.cs
- ToolStripRenderer.cs
- GuidelineSet.cs
- FileRecordSequence.cs
- SchemaLookupTable.cs
- MetafileHeader.cs
- KeyGestureConverter.cs
- EmbeddedMailObjectsCollection.cs
- FormsAuthenticationEventArgs.cs
- ConfigurationLoaderException.cs
- MULTI_QI.cs
- ContentIterators.cs
- RadioButtonAutomationPeer.cs
- TemplateBaseAction.cs
- SecurityAttributeGenerationHelper.cs
- InkCanvasAutomationPeer.cs
- StrokeSerializer.cs
- ComboBoxAutomationPeer.cs
- XmlSchemaImporter.cs
- SimpleHandlerBuildProvider.cs
- DataGridBeginningEditEventArgs.cs
- CodeDirectoryCompiler.cs
- EncoderParameter.cs
- OdbcConnectionHandle.cs
- WebPartConnectionsConfigureVerb.cs
- DataRecordObjectView.cs
- UnsafeNativeMethodsPenimc.cs
- UIElement.cs
- JsonDataContract.cs
- DataDocumentXPathNavigator.cs
- NavigationEventArgs.cs
- PathSegmentCollection.cs
- DateTimeSerializationSection.cs
- SessionEndingEventArgs.cs
- GridViewUpdateEventArgs.cs
- DES.cs
- DynamicDataRouteHandler.cs
- HWStack.cs
- DBPropSet.cs
- Configuration.cs
- DaylightTime.cs
- Paragraph.cs
- DependencyStoreSurrogate.cs
- MailAddressParser.cs
- DocumentViewerAutomationPeer.cs
- WebPartCatalogCloseVerb.cs
- XmlDataImplementation.cs
- CustomErrorsSectionWrapper.cs
- TextElementEnumerator.cs
- FragmentNavigationEventArgs.cs
- DataServiceRequest.cs
- SoapIgnoreAttribute.cs
- DataGridViewCellStyle.cs
- CompressedStack.cs
- StylusButton.cs
- HtmlInputCheckBox.cs
- StorageMappingFragment.cs
- CqlErrorHelper.cs
- XsdDataContractExporter.cs
- TextEffect.cs
- ItemMap.cs
- SecurityPermission.cs
- DetailsViewPagerRow.cs
- ToolStripDesigner.cs
- ButtonColumn.cs
- DataObjectMethodAttribute.cs
- EllipseGeometry.cs
- MessageDecoder.cs
- WebServiceErrorEvent.cs
- PropertyChangedEventArgs.cs
- LogicalExpressionTypeConverter.cs
- UdpChannelFactory.cs
- OdbcErrorCollection.cs
- WpfWebRequestHelper.cs
- DataGridViewRow.cs
- HotSpot.cs
- ResourceDictionary.cs
- CopyCodeAction.cs
- FontStretches.cs
- DrawingGroupDrawingContext.cs
- Win32SafeHandles.cs
- InstanceDescriptor.cs
- PerformanceCounterLib.cs