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
- CodeDomLoader.cs
- CompilerState.cs
- FragmentQueryProcessor.cs
- ColorContext.cs
- KeyedHashAlgorithm.cs
- ObjectViewFactory.cs
- DataReaderContainer.cs
- DependencyPropertyValueSerializer.cs
- SymbolType.cs
- DtrList.cs
- ParserStreamGeometryContext.cs
- CompiledQueryCacheEntry.cs
- XmlElementAttributes.cs
- ContentFileHelper.cs
- HttpServerProtocol.cs
- Window.cs
- SynchronizingStream.cs
- _AutoWebProxyScriptWrapper.cs
- GeometryModel3D.cs
- MethodCallExpression.cs
- ProtocolsConfigurationHandler.cs
- NameHandler.cs
- FunctionGenerator.cs
- WindowsListViewItemCheckBox.cs
- SqlDataAdapter.cs
- SelectionProviderWrapper.cs
- QueryOutputWriter.cs
- SQLString.cs
- FormatterConverter.cs
- ResourceProviderFactory.cs
- PopupControlService.cs
- DocumentPageView.cs
- AVElementHelper.cs
- MetadataCollection.cs
- HttpModulesSection.cs
- DelegatedStream.cs
- BitmapEffectInputConnector.cs
- WebSysDisplayNameAttribute.cs
- UTF32Encoding.cs
- NativeMethods.cs
- SchemaObjectWriter.cs
- FieldNameLookup.cs
- AmbientLight.cs
- COM2IPerPropertyBrowsingHandler.cs
- SqlStatistics.cs
- _WinHttpWebProxyDataBuilder.cs
- ValueQuery.cs
- DayRenderEvent.cs
- TextBoxBase.cs
- SizeAnimationClockResource.cs
- ListenerPerfCounters.cs
- ColorIndependentAnimationStorage.cs
- ParallelDesigner.cs
- BmpBitmapDecoder.cs
- COAUTHINFO.cs
- DataBindingHandlerAttribute.cs
- ArithmeticException.cs
- TextContainerChangeEventArgs.cs
- Connector.xaml.cs
- AudienceUriMode.cs
- DerivedKeySecurityTokenStub.cs
- Vertex.cs
- FontDialog.cs
- MarkedHighlightComponent.cs
- FileChangesMonitor.cs
- LoadMessageLogger.cs
- ScrollBarRenderer.cs
- ProviderCommandInfoUtils.cs
- GlyphCache.cs
- Win32.cs
- ADConnectionHelper.cs
- WebPartConnectionsConnectVerb.cs
- SiteMap.cs
- SortKey.cs
- ColumnCollection.cs
- UrlPath.cs
- XmlHierarchicalDataSourceView.cs
- HttpModuleAction.cs
- PopupEventArgs.cs
- Guid.cs
- SplineQuaternionKeyFrame.cs
- ClaimTypeElementCollection.cs
- TraceLevelStore.cs
- mediaeventshelper.cs
- _NestedSingleAsyncResult.cs
- PopOutPanel.cs
- EndPoint.cs
- ResourceKey.cs
- ValueSerializerAttribute.cs
- ObjectDataSourceEventArgs.cs
- FixedSOMLineCollection.cs
- PersonalizationState.cs
- BinaryEditor.cs
- SourceInterpreter.cs
- DiagnosticTrace.cs
- StringFunctions.cs
- ImageSource.cs
- ToolZone.cs
- DesignerSerializationOptionsAttribute.cs
- StatusBarDrawItemEvent.cs