Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / TemplateContentLoader.cs / 1305600 / TemplateContentLoader.cs
using System;
using System.ComponentModel;
using System.Xaml;
namespace System.Windows
{
public class TemplateContentLoader : XamlDeferringLoader
{
public override object Load(XamlReader xamlReader, IServiceProvider serviceProvider)
{
if (serviceProvider == null)
{
throw new ArgumentNullException("serviceProvider");
}
else if (xamlReader == null)
{
throw new ArgumentNullException("xamlReader");
}
IXamlObjectWriterFactory factory = RequireService(serviceProvider);
return new TemplateContent(xamlReader, factory, serviceProvider);
}
private static T RequireService(IServiceProvider provider) where T : class
{
T result = provider.GetService(typeof(T)) as T;
if (result == null)
{
throw new InvalidOperationException(SR.Get(SRID.DeferringLoaderNoContext,typeof(TemplateContentLoader).Name, typeof(T).Name));
}
return result;
}
public override XamlReader Save(object value, IServiceProvider serviceProvider)
{
throw new NotSupportedException(SR.Get(SRID.DeferringLoaderNoSave, typeof(TemplateContentLoader).Name));
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
using System;
using System.ComponentModel;
using System.Xaml;
namespace System.Windows
{
public class TemplateContentLoader : XamlDeferringLoader
{
public override object Load(XamlReader xamlReader, IServiceProvider serviceProvider)
{
if (serviceProvider == null)
{
throw new ArgumentNullException("serviceProvider");
}
else if (xamlReader == null)
{
throw new ArgumentNullException("xamlReader");
}
IXamlObjectWriterFactory factory = RequireService(serviceProvider);
return new TemplateContent(xamlReader, factory, serviceProvider);
}
private static T RequireService(IServiceProvider provider) where T : class
{
T result = provider.GetService(typeof(T)) as T;
if (result == null)
{
throw new InvalidOperationException(SR.Get(SRID.DeferringLoaderNoContext,typeof(TemplateContentLoader).Name, typeof(T).Name));
}
return result;
}
public override XamlReader Save(object value, IServiceProvider serviceProvider)
{
throw new NotSupportedException(SR.Get(SRID.DeferringLoaderNoSave, typeof(TemplateContentLoader).Name));
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- LoggedException.cs
- SafeNativeMethods.cs
- Literal.cs
- EmptyImpersonationContext.cs
- CreateUserWizardAutoFormat.cs
- ActivationArguments.cs
- Lease.cs
- SqlConnectionPoolGroupProviderInfo.cs
- AuthorizationRuleCollection.cs
- SystemWebSectionGroup.cs
- FontNameEditor.cs
- Metadata.cs
- FileIOPermission.cs
- DbProviderFactoriesConfigurationHandler.cs
- WebPartZoneBase.cs
- XPathAncestorQuery.cs
- CssClassPropertyAttribute.cs
- PropertyPushdownHelper.cs
- VolatileEnlistmentMultiplexing.cs
- ObjectListGeneralPage.cs
- DataGridColumnReorderingEventArgs.cs
- ProfileEventArgs.cs
- ParserContext.cs
- SqlFacetAttribute.cs
- ImportCatalogPart.cs
- SqlDataSource.cs
- NameNode.cs
- AsnEncodedData.cs
- OracleCommand.cs
- DecimalAnimation.cs
- SuppressMergeCheckAttribute.cs
- DesignerActionPanel.cs
- IResourceProvider.cs
- MultiAsyncResult.cs
- GridViewHeaderRowPresenter.cs
- IconBitmapDecoder.cs
- RequestCachePolicy.cs
- NextPreviousPagerField.cs
- ConnectionStringSettingsCollection.cs
- XsltException.cs
- PasswordPropertyTextAttribute.cs
- EntityExpressionVisitor.cs
- FixedSOMPageConstructor.cs
- XmlHelper.cs
- hresults.cs
- TransportConfigurationTypeElement.cs
- DataGridViewColumnCollectionEditor.cs
- ObjectMemberMapping.cs
- SerializationStore.cs
- ActiveDocumentEvent.cs
- Attachment.cs
- RawAppCommandInputReport.cs
- CommandConverter.cs
- SizeConverter.cs
- FontNamesConverter.cs
- ToolStripItemRenderEventArgs.cs
- PrintingPermissionAttribute.cs
- VirtualizedContainerService.cs
- StdValidatorsAndConverters.cs
- XmlStringTable.cs
- MimeMapping.cs
- FrameworkElement.cs
- ISSmlParser.cs
- SaveFileDialog.cs
- ListViewInsertedEventArgs.cs
- InternalEnumValidator.cs
- WebPartUtil.cs
- FolderLevelBuildProviderAppliesToAttribute.cs
- Int32Rect.cs
- Panel.cs
- TableSectionStyle.cs
- DataGridViewTopRowAccessibleObject.cs
- MessageHeaderInfoTraceRecord.cs
- VScrollProperties.cs
- SmiContext.cs
- TextElement.cs
- CapabilitiesPattern.cs
- OdbcInfoMessageEvent.cs
- HyperLink.cs
- XmlSchemaInferenceException.cs
- AspNetCacheProfileAttribute.cs
- Variable.cs
- FontDifferentiator.cs
- XmlUtil.cs
- QueryStringParameter.cs
- OracleBoolean.cs
- querybuilder.cs
- RegexNode.cs
- SqlClientWrapperSmiStreamChars.cs
- SoapMessage.cs
- RegexGroupCollection.cs
- DocumentCollection.cs
- XmlSchemaAll.cs
- ObjectItemConventionAssemblyLoader.cs
- BitmapFrameEncode.cs
- DesignTimeTemplateParser.cs
- DataGridToolTip.cs
- SafeNativeMethods.cs
- WorkflowElementDialogWindow.xaml.cs
- WebPartMenu.cs