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
- WebServiceMethodData.cs
- Vector3DAnimationUsingKeyFrames.cs
- Inline.cs
- InheritanceRules.cs
- PasswordBoxAutomationPeer.cs
- _IPv4Address.cs
- SqlSupersetValidator.cs
- UniqueIdentifierService.cs
- GenericEnumerator.cs
- SqlTrackingService.cs
- InkCanvasInnerCanvas.cs
- MetadataHelper.cs
- NetSectionGroup.cs
- ComponentCollection.cs
- ProcessHostFactoryHelper.cs
- EntitySetBaseCollection.cs
- GACIdentityPermission.cs
- PageContentAsyncResult.cs
- ProfileProvider.cs
- InternalResources.cs
- SMSvcHost.cs
- HandleValueEditor.cs
- SettingsProperty.cs
- UriExt.cs
- Variant.cs
- SelectedGridItemChangedEvent.cs
- SortedList.cs
- EdmConstants.cs
- XmlValidatingReaderImpl.cs
- UriParserTemplates.cs
- CrossContextChannel.cs
- InputQueue.cs
- FormViewRow.cs
- FactoryMaker.cs
- SamlAuthorityBinding.cs
- DropShadowEffect.cs
- IPHostEntry.cs
- FormViewInsertedEventArgs.cs
- _FtpControlStream.cs
- NameTable.cs
- ConnectionOrientedTransportElement.cs
- Certificate.cs
- PingReply.cs
- ReceiveErrorHandling.cs
- EntityCodeGenerator.cs
- PrtTicket_Base.cs
- LockRecoveryTask.cs
- Visual3D.cs
- TreeNode.cs
- CacheOutputQuery.cs
- Point3DAnimation.cs
- DataServiceConfiguration.cs
- ModifierKeysConverter.cs
- MembershipSection.cs
- BulletDecorator.cs
- SqlFlattener.cs
- RequiredAttributeAttribute.cs
- XmlWriterTraceListener.cs
- DbCommandDefinition.cs
- mediaclock.cs
- InteropTrackingRecord.cs
- AutomationPeer.cs
- RenderData.cs
- DataColumn.cs
- PageBuildProvider.cs
- CountAggregationOperator.cs
- Psha1DerivedKeyGenerator.cs
- StringCollectionMarkupSerializer.cs
- IndependentAnimationStorage.cs
- QueryTaskGroupState.cs
- DropDownButton.cs
- XmlQualifiedName.cs
- FileLevelControlBuilderAttribute.cs
- RSAProtectedConfigurationProvider.cs
- MenuCommand.cs
- ThreadStateException.cs
- EFColumnProvider.cs
- SHA256Managed.cs
- XmlElement.cs
- SqlDependencyListener.cs
- AnnotationComponentChooser.cs
- Int32Rect.cs
- BitmapEffectInput.cs
- RegistryKey.cs
- LeaseManager.cs
- TreeViewImageKeyConverter.cs
- File.cs
- Triangle.cs
- TreeNode.cs
- MimeFormImporter.cs
- COM2IVsPerPropertyBrowsingHandler.cs
- ListViewCancelEventArgs.cs
- UriSection.cs
- Knowncolors.cs
- ReachPrintTicketSerializerAsync.cs
- SelectionEditor.cs
- HtmlHistory.cs
- RecordConverter.cs
- CatchDesigner.xaml.cs
- ExtensionsSection.cs