Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / xsp / System / Web / UI / WebParts / WebPartUtil.cs / 1 / WebPartUtil.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.UI.WebControls.WebParts {
using System;
using System.Diagnostics;
using System.Reflection;
using System.Web.Compilation;
internal static class WebPartUtil {
// Called from WebPartManagerInternals and ConnectionsZone.
internal static object CreateObjectFromType(Type type) {
return HttpRuntime.FastCreatePublicInstance(type);
}
// We use BuildManager.GetType() instead of Type.GetType() so we can load types from the
// Code directory, even if no assembly is specified.
internal static Type DeserializeType(string typeName, bool throwOnError) {
return BuildManager.GetType(typeName, throwOnError);
}
internal static Type[] GetTypesForConstructor(ConstructorInfo constructor) {
Debug.Assert(constructor != null);
ParameterInfo[] parameters = constructor.GetParameters();
Type[] types = new Type[parameters.Length];
for (int i = 0; i < parameters.Length; i++) {
types[i] = parameters[i].ParameterType;
}
return types;
}
internal static bool IsConnectionPointTypeValid(Type connectionPointType, bool isConsumer) {
if (connectionPointType == null) {
return true;
}
if (!(connectionPointType.IsPublic || connectionPointType.IsNestedPublic)) {
return false;
}
Type baseType = isConsumer ? typeof(ConsumerConnectionPoint) : typeof(ProviderConnectionPoint);
if (!connectionPointType.IsSubclassOf(baseType)) {
return false;
}
Type[] constructorTypes = isConsumer ? ConsumerConnectionPoint.ConstructorTypes :
ProviderConnectionPoint.ConstructorTypes;
ConstructorInfo constructor = connectionPointType.GetConstructor(constructorTypes);
if (constructor == null) {
return false;
}
return true;
}
// This helper method used to be needed to resolve types in the Code directory. Since this
// was fixed in VSWhidbey 380793, we can just use Type.AssemblyQualifiedName instead of
// Type.FullName. However, I am leaving this helper method in place in case we need to make
// another fix in the future.
internal static string SerializeType(Type type) {
if (type.Assembly.GlobalAssemblyCache) {
return type.AssemblyQualifiedName;
}
else {
return type.FullName;
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.UI.WebControls.WebParts {
using System;
using System.Diagnostics;
using System.Reflection;
using System.Web.Compilation;
internal static class WebPartUtil {
// Called from WebPartManagerInternals and ConnectionsZone.
internal static object CreateObjectFromType(Type type) {
return HttpRuntime.FastCreatePublicInstance(type);
}
// We use BuildManager.GetType() instead of Type.GetType() so we can load types from the
// Code directory, even if no assembly is specified.
internal static Type DeserializeType(string typeName, bool throwOnError) {
return BuildManager.GetType(typeName, throwOnError);
}
internal static Type[] GetTypesForConstructor(ConstructorInfo constructor) {
Debug.Assert(constructor != null);
ParameterInfo[] parameters = constructor.GetParameters();
Type[] types = new Type[parameters.Length];
for (int i = 0; i < parameters.Length; i++) {
types[i] = parameters[i].ParameterType;
}
return types;
}
internal static bool IsConnectionPointTypeValid(Type connectionPointType, bool isConsumer) {
if (connectionPointType == null) {
return true;
}
if (!(connectionPointType.IsPublic || connectionPointType.IsNestedPublic)) {
return false;
}
Type baseType = isConsumer ? typeof(ConsumerConnectionPoint) : typeof(ProviderConnectionPoint);
if (!connectionPointType.IsSubclassOf(baseType)) {
return false;
}
Type[] constructorTypes = isConsumer ? ConsumerConnectionPoint.ConstructorTypes :
ProviderConnectionPoint.ConstructorTypes;
ConstructorInfo constructor = connectionPointType.GetConstructor(constructorTypes);
if (constructor == null) {
return false;
}
return true;
}
// This helper method used to be needed to resolve types in the Code directory. Since this
// was fixed in VSWhidbey 380793, we can just use Type.AssemblyQualifiedName instead of
// Type.FullName. However, I am leaving this helper method in place in case we need to make
// another fix in the future.
internal static string SerializeType(Type type) {
if (type.Assembly.GlobalAssemblyCache) {
return type.AssemblyQualifiedName;
}
else {
return type.FullName;
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ReferentialConstraint.cs
- IdentityModelStringsVersion1.cs
- MenuItem.cs
- Trace.cs
- BindingList.cs
- Environment.cs
- XPathMultyIterator.cs
- RightsManagementEncryptionTransform.cs
- KnownTypesHelper.cs
- ResourcesBuildProvider.cs
- WindowsComboBox.cs
- ToRequest.cs
- PropertySourceInfo.cs
- AttachedPropertyMethodSelector.cs
- XmlSubtreeReader.cs
- HScrollProperties.cs
- InfoCardRequestException.cs
- AnnotationStore.cs
- AsymmetricCryptoHandle.cs
- Permission.cs
- HttpCookieCollection.cs
- FixUpCollection.cs
- SHA256.cs
- PagedDataSource.cs
- PresentationTraceSources.cs
- TextCompositionEventArgs.cs
- VectorAnimationBase.cs
- HttpRequestTraceRecord.cs
- PeerApplicationLaunchInfo.cs
- DrawListViewColumnHeaderEventArgs.cs
- HttpDebugHandler.cs
- ZoomPercentageConverter.cs
- WindowsEditBoxRange.cs
- PartialCachingAttribute.cs
- KnownAssemblyEntry.cs
- WebEventTraceProvider.cs
- PersonalizationProvider.cs
- EdmPropertyAttribute.cs
- DescendantOverDescendantQuery.cs
- ReachFixedPageSerializer.cs
- DbProviderConfigurationHandler.cs
- ServiceConfigurationTraceRecord.cs
- RSAPKCS1KeyExchangeFormatter.cs
- ToolStripPanelDesigner.cs
- RelationshipManager.cs
- SqlParameterizer.cs
- TypeBuilderInstantiation.cs
- RegexInterpreter.cs
- MsmqIntegrationOutputChannel.cs
- HttpBindingExtension.cs
- ScrollPattern.cs
- Propagator.cs
- ExtenderControl.cs
- ControlType.cs
- PageThemeCodeDomTreeGenerator.cs
- ProcessHostFactoryHelper.cs
- UserPersonalizationStateInfo.cs
- PenContexts.cs
- GraphicsPath.cs
- MsmqAppDomainProtocolHandler.cs
- DataRelation.cs
- ErrorTableItemStyle.cs
- ToolboxItemCollection.cs
- PauseStoryboard.cs
- HttpHandlerActionCollection.cs
- IncrementalCompileAnalyzer.cs
- XmlNodeWriter.cs
- TextTreeDeleteContentUndoUnit.cs
- SemaphoreFullException.cs
- PhysicalAddress.cs
- X509SecurityTokenProvider.cs
- XmlReaderSettings.cs
- Property.cs
- FigureHelper.cs
- DockProviderWrapper.cs
- CounterSample.cs
- OracleBoolean.cs
- SqlNodeTypeOperators.cs
- OdbcConnectionHandle.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- ParallelTimeline.cs
- ObjectNavigationPropertyMapping.cs
- TextBox.cs
- PagerSettings.cs
- TextSelectionHelper.cs
- BuilderInfo.cs
- HitTestParameters.cs
- CaseExpr.cs
- PathParser.cs
- ParameterReplacerVisitor.cs
- ForeignKeyConstraint.cs
- PluralizationService.cs
- VarInfo.cs
- EncodingDataItem.cs
- LocalizationComments.cs
- StackOverflowException.cs
- LOSFormatter.cs
- NamedPipeTransportManager.cs
- InstanceData.cs
- ParallelActivityDesigner.cs