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
- WebScriptMetadataMessage.cs
- PropertyChangeTracker.cs
- LayoutEngine.cs
- SafeRightsManagementEnvironmentHandle.cs
- TableCellCollection.cs
- DataBindingList.cs
- ProcessHostMapPath.cs
- Debug.cs
- ConstraintStruct.cs
- BinarySecretSecurityToken.cs
- BufferedResponseStream.cs
- IDReferencePropertyAttribute.cs
- Transform3DGroup.cs
- OrderingExpression.cs
- ReadOnlyHierarchicalDataSource.cs
- XmlDocumentViewSchema.cs
- PanningMessageFilter.cs
- DocumentPageViewAutomationPeer.cs
- CollectionViewSource.cs
- EncoderReplacementFallback.cs
- ParseChildrenAsPropertiesAttribute.cs
- _AutoWebProxyScriptWrapper.cs
- ButtonChrome.cs
- TableProviderWrapper.cs
- GcHandle.cs
- PropertyToken.cs
- TabControl.cs
- RequestStatusBarUpdateEventArgs.cs
- Vector3DKeyFrameCollection.cs
- UnionCodeGroup.cs
- ToolboxItemAttribute.cs
- EntitySqlQueryState.cs
- DetailsViewUpdatedEventArgs.cs
- DefinitionUpdate.cs
- TypeLibConverter.cs
- FlowchartDesigner.xaml.cs
- CellPartitioner.cs
- DataColumnSelectionConverter.cs
- ComponentCodeDomSerializer.cs
- CodeMemberField.cs
- PtsCache.cs
- FileUtil.cs
- FramingFormat.cs
- Property.cs
- CellTreeNodeVisitors.cs
- StatusBarPanel.cs
- DataServiceRequestException.cs
- DescriptionAttribute.cs
- RewritingValidator.cs
- ImageListStreamer.cs
- Helpers.cs
- TextOutput.cs
- DrawingContextWalker.cs
- _TLSstream.cs
- BitmapEffectGeneralTransform.cs
- ExpressionTextBox.xaml.cs
- WorkflowApplicationUnloadedException.cs
- XmlSchemaInclude.cs
- AutomationPatternInfo.cs
- AnonymousIdentificationModule.cs
- XmlSerializerFactory.cs
- CommandConverter.cs
- DecimalAnimation.cs
- System.Data_BID.cs
- hresults.cs
- OperationContractGenerationContext.cs
- AnimationStorage.cs
- OleDbConnectionInternal.cs
- DataPagerFieldItem.cs
- ContainerControl.cs
- RelationshipDetailsCollection.cs
- DbConnectionFactory.cs
- DBConcurrencyException.cs
- CuspData.cs
- FontStyles.cs
- DbConnectionPoolCounters.cs
- AspNetHostingPermission.cs
- WmpBitmapDecoder.cs
- ExpressionBinding.cs
- AstNode.cs
- HandleTable.cs
- Process.cs
- listviewsubitemcollectioneditor.cs
- DescendentsWalker.cs
- StylusPointPropertyInfo.cs
- ComboBoxDesigner.cs
- IisTraceListener.cs
- SamlEvidence.cs
- ToolBarTray.cs
- PixelShader.cs
- DeleteCardRequest.cs
- documentsequencetextview.cs
- PropertyInformationCollection.cs
- ConfigurationSettings.cs
- AppDomainAttributes.cs
- ControlPaint.cs
- DeferredTextReference.cs
- OperationCanceledException.cs
- EdmMember.cs
- ExpressionBuilderContext.cs