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
- BindingMemberInfo.cs
- dataobject.cs
- TranslateTransform.cs
- ListViewItemMouseHoverEvent.cs
- WebCategoryAttribute.cs
- EventPrivateKey.cs
- RsaElement.cs
- IPAddressCollection.cs
- AspCompat.cs
- FixedPosition.cs
- DataGridViewButtonCell.cs
- ListControlStringCollectionEditor.cs
- DataObjectMethodAttribute.cs
- SubMenuStyle.cs
- TimerElapsedEvenArgs.cs
- RMPermissions.cs
- DescendentsWalker.cs
- LambdaCompiler.Unary.cs
- InternalMappingException.cs
- ResourceManagerWrapper.cs
- ServiceDefaults.cs
- AssemblyResourceLoader.cs
- _Events.cs
- ToggleProviderWrapper.cs
- ParenthesizePropertyNameAttribute.cs
- DataListCommandEventArgs.cs
- Matrix.cs
- XmlCollation.cs
- Frame.cs
- InstanceStoreQueryResult.cs
- ZoomPercentageConverter.cs
- WebScriptMetadataMessage.cs
- SystemResourceKey.cs
- MetricEntry.cs
- ApplyTemplatesAction.cs
- XamlFilter.cs
- WorkflowRuntimeServiceElementCollection.cs
- AttributeQuery.cs
- TextEffect.cs
- EntityContainer.cs
- ScriptResourceInfo.cs
- CryptoHandle.cs
- PageCatalogPartDesigner.cs
- SharedConnectionInfo.cs
- RegexRunner.cs
- LocalTransaction.cs
- EventLogEntryCollection.cs
- ArraySet.cs
- FileEnumerator.cs
- OperationContractAttribute.cs
- BrowserCapabilitiesCompiler.cs
- SmtpCommands.cs
- ListDictionary.cs
- ScrollProperties.cs
- InitializationEventAttribute.cs
- SchemaImporterExtensionsSection.cs
- DateTimeFormatInfo.cs
- SecurityIdentifierElement.cs
- PathSegmentCollection.cs
- CreateParams.cs
- BinaryReader.cs
- EntityDataSourceSelectingEventArgs.cs
- ResourceContainer.cs
- TableLayoutPanelResizeGlyph.cs
- HttpHandlerAction.cs
- ObjectCloneHelper.cs
- _AcceptOverlappedAsyncResult.cs
- BitmapCache.cs
- ReversePositionQuery.cs
- categoryentry.cs
- AdCreatedEventArgs.cs
- DesignerDataSourceView.cs
- PrintDialog.cs
- EUCJPEncoding.cs
- DebuggerAttributes.cs
- NetMsmqSecurityMode.cs
- ThrowHelper.cs
- JapaneseLunisolarCalendar.cs
- WindowsStatusBar.cs
- VisualTreeHelper.cs
- ApplicationServiceManager.cs
- ConfigXmlAttribute.cs
- PointHitTestParameters.cs
- ZipIOExtraField.cs
- OracleNumber.cs
- HttpListenerResponse.cs
- DesignerOptionService.cs
- KeysConverter.cs
- BeginStoryboard.cs
- ToolStripCodeDomSerializer.cs
- CollectionChangedEventManager.cs
- InternalUserCancelledException.cs
- LinkLabel.cs
- PassportAuthentication.cs
- ConfigXmlDocument.cs
- CacheAxisQuery.cs
- RawStylusInputReport.cs
- ScalarType.cs
- TypeBuilderInstantiation.cs
- Matrix.cs