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
- PropertyValidationContext.cs
- Exception.cs
- NotSupportedException.cs
- VerticalAlignConverter.cs
- PersistenceTypeAttribute.cs
- CompositeActivityTypeDescriptorProvider.cs
- CacheForPrimitiveTypes.cs
- AmbientLight.cs
- SQLInt64Storage.cs
- CachingHintValidation.cs
- ApplicationHost.cs
- SafeBitVector32.cs
- AssemblyCache.cs
- DefaultCommandConverter.cs
- LiteralLink.cs
- SystemIPInterfaceProperties.cs
- DragCompletedEventArgs.cs
- TileBrush.cs
- OptimalTextSource.cs
- ByteAnimationUsingKeyFrames.cs
- StateMachineHistory.cs
- ListViewGroupCollectionEditor.cs
- PageCache.cs
- _FixedSizeReader.cs
- DescendantOverDescendantQuery.cs
- Image.cs
- MetadataSource.cs
- XmlSchemaSimpleContentRestriction.cs
- Base64Encoder.cs
- LexicalChunk.cs
- LiteralTextParser.cs
- WebPartVerb.cs
- CultureInfoConverter.cs
- DataGridLength.cs
- XPathPatternParser.cs
- SessionEndingEventArgs.cs
- Trace.cs
- QueryExpr.cs
- cryptoapiTransform.cs
- ParameterCollection.cs
- FormClosedEvent.cs
- RadioButtonList.cs
- AddToCollection.cs
- WaitHandleCannotBeOpenedException.cs
- SessionState.cs
- SocketInformation.cs
- DesignColumn.cs
- ObjectStateFormatter.cs
- XmlHierarchicalDataSourceView.cs
- ComAdminWrapper.cs
- Tokenizer.cs
- DataGridViewCellValueEventArgs.cs
- DrawingState.cs
- CompositeControl.cs
- KeyGestureValueSerializer.cs
- EventLogConfiguration.cs
- TextureBrush.cs
- X509Certificate2.cs
- AuthorizationBehavior.cs
- XpsFilter.cs
- IPHostEntry.cs
- IndicShape.cs
- DescendantOverDescendantQuery.cs
- TaiwanLunisolarCalendar.cs
- ISAPIApplicationHost.cs
- RichTextBox.cs
- AbandonedMutexException.cs
- XamlWriter.cs
- NavigationEventArgs.cs
- SqlCommandSet.cs
- CommandSet.cs
- XmlSchemaSimpleContentRestriction.cs
- IList.cs
- QueryContinueDragEventArgs.cs
- EventListenerClientSide.cs
- BookmarkNameHelper.cs
- RuntimeConfigurationRecord.cs
- DesignerActionKeyboardBehavior.cs
- Activator.cs
- DependencyObjectProvider.cs
- ContextMenuService.cs
- SelectionPattern.cs
- WCFBuildProvider.cs
- ColumnTypeConverter.cs
- DBConcurrencyException.cs
- DLinqColumnProvider.cs
- figurelengthconverter.cs
- SiteMapNode.cs
- Substitution.cs
- TextMarkerSource.cs
- PropertyStore.cs
- NegotiateStream.cs
- ThreadStaticAttribute.cs
- ChangeNode.cs
- HealthMonitoringSection.cs
- CopyNodeSetAction.cs
- AliasedExpr.cs
- PageAsyncTaskManager.cs
- SystemColorTracker.cs
- TargetControlTypeCache.cs