Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Markup / Baml2006 / WpfSharedXamlSchemaContext.cs / 1305600 / WpfSharedXamlSchemaContext.cs
using System; using System.Collections.Generic; using System.Text; using System.Xaml; namespace System.Windows.Baml2006 { ////// This schema context is shared between all the WPF XAML loads in an AppDomain, including both /// full and partial trust callers. To be safe for sharing, it must be idempotent and order-independent. /// See the SecurityNote on XamlSchemaContext for more details. /// internal class WpfSharedXamlSchemaContext : WpfSharedBamlSchemaContext { // V3 Rules are: // Simple Collection rules: We only lookup IList & IDictionary (no add methods) (The MarkupCompiler doesn't support this) // No Deferring Loader lookup on XamlMember (The MarkupCompiler doesn't support this) public WpfSharedXamlSchemaContext(XamlSchemaContextSettings settings, bool useV3Rules) : base(settings) { _useV3Rules = useV3Rules; } public override XamlType GetXamlType(Type type) { if (type == null) { throw new ArgumentNullException("type"); } XamlType xType; lock (_syncObject) { if (!_masterTypeTable.TryGetValue(type, out xType)) { RequireRuntimeType(type); xType = CreateKnownBamlType(type.Name, false, _useV3Rules); if (xType == null || xType.UnderlyingType != type) { xType = new WpfXamlType(type, this, false /* isBamlType */, _useV3Rules); } _masterTypeTable.Add(type, xType); } } return xType; } internal static void RequireRuntimeType(Type type) { // To avoid injection of derived System.Types that lie about their identity // (and spoof other types), only allow RuntimeTypes. // S.W.M.XamlReader only supports live reflection, anyway. Type runtimeType = typeof(object).GetType(); if (!runtimeType.IsAssignableFrom(type.GetType())) { throw new ArgumentException(SR.Get(SRID.RuntimeTypeRequired, type), "type"); } } // Allow wrapping SchemaContexts a way to call into the protected overload of GetXamlType internal XamlType GetXamlTypeInternal(string xamlNamespace, string name, params XamlType[] typeArguments) { return base.GetXamlType(xamlNamespace, name, typeArguments); } private Dictionary_masterTypeTable = new Dictionary (); private object _syncObject = new Object(); private bool _useV3Rules; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. using System; using System.Collections.Generic; using System.Text; using System.Xaml; namespace System.Windows.Baml2006 { /// /// This schema context is shared between all the WPF XAML loads in an AppDomain, including both /// full and partial trust callers. To be safe for sharing, it must be idempotent and order-independent. /// See the SecurityNote on XamlSchemaContext for more details. /// internal class WpfSharedXamlSchemaContext : WpfSharedBamlSchemaContext { // V3 Rules are: // Simple Collection rules: We only lookup IList & IDictionary (no add methods) (The MarkupCompiler doesn't support this) // No Deferring Loader lookup on XamlMember (The MarkupCompiler doesn't support this) public WpfSharedXamlSchemaContext(XamlSchemaContextSettings settings, bool useV3Rules) : base(settings) { _useV3Rules = useV3Rules; } public override XamlType GetXamlType(Type type) { if (type == null) { throw new ArgumentNullException("type"); } XamlType xType; lock (_syncObject) { if (!_masterTypeTable.TryGetValue(type, out xType)) { RequireRuntimeType(type); xType = CreateKnownBamlType(type.Name, false, _useV3Rules); if (xType == null || xType.UnderlyingType != type) { xType = new WpfXamlType(type, this, false /* isBamlType */, _useV3Rules); } _masterTypeTable.Add(type, xType); } } return xType; } internal static void RequireRuntimeType(Type type) { // To avoid injection of derived System.Types that lie about their identity // (and spoof other types), only allow RuntimeTypes. // S.W.M.XamlReader only supports live reflection, anyway. Type runtimeType = typeof(object).GetType(); if (!runtimeType.IsAssignableFrom(type.GetType())) { throw new ArgumentException(SR.Get(SRID.RuntimeTypeRequired, type), "type"); } } // Allow wrapping SchemaContexts a way to call into the protected overload of GetXamlType internal XamlType GetXamlTypeInternal(string xamlNamespace, string name, params XamlType[] typeArguments) { return base.GetXamlType(xamlNamespace, name, typeArguments); } private Dictionary_masterTypeTable = new Dictionary (); private object _syncObject = new Object(); private bool _useV3Rules; } } // 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
- DataControlField.cs
- EntityContainerRelationshipSetEnd.cs
- UnsafeNetInfoNativeMethods.cs
- ConfigLoader.cs
- SqlUDTStorage.cs
- CompressStream.cs
- CompositionTarget.cs
- DataServiceKeyAttribute.cs
- StringSorter.cs
- LookupBindingPropertiesAttribute.cs
- CaretElement.cs
- QueueSurrogate.cs
- MultiView.cs
- TypedRowHandler.cs
- SqlDelegatedTransaction.cs
- SqlClientWrapperSmiStream.cs
- UiaCoreApi.cs
- updatecommandorderer.cs
- WebPartTransformerCollection.cs
- JavascriptCallbackBehaviorAttribute.cs
- CodeObject.cs
- BinaryExpression.cs
- DiscoveryMessageSequence.cs
- ListMarkerSourceInfo.cs
- Walker.cs
- TextContainerChangeEventArgs.cs
- SessionChannels.cs
- UserPrincipalNameElement.cs
- StrokeCollectionDefaultValueFactory.cs
- NamespaceCollection.cs
- SetterBaseCollection.cs
- HttpResponse.cs
- MdiWindowListStrip.cs
- HttpConfigurationContext.cs
- BinaryQueryOperator.cs
- DataTableReader.cs
- X509DefaultServiceCertificateElement.cs
- ResourceDictionary.cs
- BaseCollection.cs
- GeneralTransform.cs
- BreakSafeBase.cs
- WebPartConnectionsDisconnectVerb.cs
- HttpModuleActionCollection.cs
- PropertyStore.cs
- RuleInfoComparer.cs
- ImageSource.cs
- AtomicFile.cs
- Geometry3D.cs
- Panel.cs
- ContextMenuStrip.cs
- HostSecurityManager.cs
- localization.cs
- CodeArgumentReferenceExpression.cs
- PerfService.cs
- IPAddressCollection.cs
- StandardToolWindows.cs
- SEHException.cs
- XXXInfos.cs
- _CommandStream.cs
- SmiConnection.cs
- BrowserInteropHelper.cs
- LoginName.cs
- DataGridViewRowHeaderCell.cs
- LongValidatorAttribute.cs
- MessagePropertyAttribute.cs
- WpfKnownMember.cs
- ExpressionBinding.cs
- Debug.cs
- Html32TextWriter.cs
- Tuple.cs
- DataObject.cs
- SizeKeyFrameCollection.cs
- MetabaseReader.cs
- SchemaEntity.cs
- DataGridViewRowDividerDoubleClickEventArgs.cs
- IteratorDescriptor.cs
- ISAPIRuntime.cs
- RegionIterator.cs
- ValidationEventArgs.cs
- GrammarBuilderBase.cs
- IPipelineRuntime.cs
- RadioButtonFlatAdapter.cs
- XMLSchema.cs
- TextRangeEditLists.cs
- Configuration.cs
- AssemblyBuilder.cs
- SkinBuilder.cs
- SymbolEqualComparer.cs
- MarkupCompilePass1.cs
- OAVariantLib.cs
- InvokeMethod.cs
- IPEndPoint.cs
- CrossContextChannel.cs
- WebPartConnectionsConfigureVerb.cs
- XmlSchemaImport.cs
- CollectionCodeDomSerializer.cs
- HtmlHead.cs
- WorkflowRuntimeServiceElementCollection.cs
- assemblycache.cs
- ConfigurationElementCollection.cs