Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Xaml.Hosting / System / Xaml / Hosting / XamlBuildProvider.cs / 1305376 / XamlBuildProvider.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.Xaml.Hosting { using System; using System.Xml; using System.Web; using System.Web.Hosting; using System.Web.Compilation; using System.CodeDom.Compiler; using System.Collections.Generic; using System.IO; using System.Xaml; using System.Diagnostics.CodeAnalysis; using System.Runtime; using System.Reflection; using System.Text; [BuildProviderAppliesTo(BuildProviderAppliesTo.Web)] public class XamlBuildProvider : BuildProvider { [Fx.Tag.Throws(typeof(TypeLoadException), "The type resolution of the root element failed.")] public override Type GetGeneratedType(CompilerResults results) { try { using (Stream xamlStream = base.OpenStream()) { XmlReader xmlReader = XmlReader.Create(xamlStream); XamlXmlReader xamlReader = new XamlXmlReader(xmlReader); // Read to the root object while (xamlReader.Read()) { if (xamlReader.NodeType == XamlNodeType.StartObject) { if (xamlReader.Type.IsUnknown) { StringBuilder typeName = new StringBuilder(); AppendTypeName(xamlReader.Type, typeName); throw FxTrace.Exception.AsError(new TypeLoadException(SR.CouldNotResolveType(typeName))); } return xamlReader.Type.UnderlyingType; } } throw FxTrace.Exception.AsError(new HttpCompileException(SR.UnexpectedEof)); } } catch (XamlParseException ex) { throw FxTrace.Exception.AsError(new HttpCompileException(ex.Message, ex)); } } public override BuildProviderResultFlags GetResultFlags(CompilerResults results) { return BuildProviderResultFlags.ShutdownAppDomainOnChange; } private void AppendTypeName(XamlType xamlType, StringBuilder sb) { if (!string.IsNullOrEmpty(xamlType.PreferredXamlNamespace)) { sb.Append("{"); sb.Append(xamlType.PreferredXamlNamespace); sb.Append("}"); } sb.Append(xamlType.Name); if (xamlType.IsGeneric) { sb.Append("("); for (int i = 0; i < xamlType.TypeArguments.Count; i++) { AppendTypeName(xamlType.TypeArguments[i], sb); if (i < xamlType.TypeArguments.Count - 1) { sb.Append(", "); } } sb.Append(")"); } } } } // 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
- ImageClickEventArgs.cs
- ResourceDisplayNameAttribute.cs
- KeyedHashAlgorithm.cs
- OuterGlowBitmapEffect.cs
- TextTreeTextNode.cs
- GridViewRowPresenter.cs
- SchemaElement.cs
- AccessedThroughPropertyAttribute.cs
- Emitter.cs
- MethodAccessException.cs
- RegularExpressionValidator.cs
- ListComponentEditorPage.cs
- ImageBrush.cs
- SecurityUtils.cs
- Tool.cs
- DoubleCollectionConverter.cs
- PopupRootAutomationPeer.cs
- DataPagerCommandEventArgs.cs
- HTTPAPI_VERSION.cs
- SplitContainer.cs
- ConstructorArgumentAttribute.cs
- TextBreakpoint.cs
- AssemblySettingAttributes.cs
- x509store.cs
- ToolStripItemCollection.cs
- SubMenuStyle.cs
- TextTreeInsertUndoUnit.cs
- DataRelation.cs
- MultiSelectRootGridEntry.cs
- MulticastIPAddressInformationCollection.cs
- ContentElementAutomationPeer.cs
- Mouse.cs
- EntityDataSourceState.cs
- SiteMapHierarchicalDataSourceView.cs
- hresults.cs
- WebServicesDescriptionAttribute.cs
- WebPartCloseVerb.cs
- TextServicesLoader.cs
- Literal.cs
- PolyLineSegment.cs
- LazyTextWriterCreator.cs
- HierarchicalDataBoundControlAdapter.cs
- XmlEncoding.cs
- CompositeFontInfo.cs
- ServiceSettingsResponseInfo.cs
- ExpandCollapsePatternIdentifiers.cs
- WebPartVerb.cs
- ProcessHostFactoryHelper.cs
- DefaultPropertiesToSend.cs
- UriScheme.cs
- DataGridSortCommandEventArgs.cs
- OrderedHashRepartitionEnumerator.cs
- OletxTransactionManager.cs
- UidManager.cs
- CapabilitiesPattern.cs
- HwndTarget.cs
- CategoryGridEntry.cs
- AppSettingsReader.cs
- TabPanel.cs
- DiagnosticEventProvider.cs
- ImageField.cs
- IUnknownConstantAttribute.cs
- SiteMapHierarchicalDataSourceView.cs
- SoapProcessingBehavior.cs
- DbConnectionPoolGroupProviderInfo.cs
- IPAddressCollection.cs
- InfoCardRSAPKCS1KeyExchangeFormatter.cs
- TextBoxDesigner.cs
- UnsafeNativeMethods.cs
- ControllableStoryboardAction.cs
- Axis.cs
- XmlSchemaSimpleContent.cs
- Path.cs
- ExceptionValidationRule.cs
- APCustomTypeDescriptor.cs
- DataGridRow.cs
- UiaCoreTypesApi.cs
- DesignRelationCollection.cs
- CodeIterationStatement.cs
- EntityTransaction.cs
- compensatingcollection.cs
- coordinatorfactory.cs
- DesignSurface.cs
- TextLineResult.cs
- ShaderRenderModeValidation.cs
- ObjectStorage.cs
- HttpWrapper.cs
- EncodingDataItem.cs
- XmlSchemaDocumentation.cs
- TableHeaderCell.cs
- TimeManager.cs
- Rfc2898DeriveBytes.cs
- SmuggledIUnknown.cs
- FocusManager.cs
- DifferencingCollection.cs
- BindingList.cs
- SimpleMailWebEventProvider.cs
- AtlasWeb.Designer.cs
- RegistrationServices.cs
- CacheOutputQuery.cs