public XamlWriterInternalBase (XamlSchemaContext schemaContext, XamlWriterStateManager manager) { this.sctx = schemaContext; this.manager = manager; var p = new PrefixLookup (sctx) { IsCollectingNamespaces = true }; // it does not raise unknown namespace error. service_provider = new ValueSerializerContext (p, schemaContext, AmbientProvider, this, this); }
void Initialize(PrefixLookup prefixLookup, XamlSchemaContext schemaContext, IAmbientProvider ambientProvider, IProvideValueTarget provideValue, IRootObjectProvider rootProvider, IDestinationTypeProvider destinationProvider, IXamlObjectWriterFactory objectWriterFactory) { prefix_lookup = prefixLookup ?? throw new ArgumentNullException("prefixLookup"); sctx = schemaContext ?? throw new ArgumentNullException("schemaContext"); ambient_provider = ambientProvider; this.provideValue = provideValue; this.rootProvider = rootProvider; this.destinationProvider = destinationProvider; this.objectWriterFactory = objectWriterFactory; }
void LookupNamespacesInType(XamlType xt) { PrefixLookup.LookupPrefix(xt.PreferredXamlNamespace); if (xt.TypeArguments != null) { // It is for x:TypeArguments PrefixLookup.LookupPrefix(XamlLanguage.Xaml2006Namespace); foreach (var targ in xt.TypeArguments) { LookupNamespacesInType(targ); } } }
public ValueSerializerContext (PrefixLookup prefixLookup, XamlSchemaContext schemaContext, IAmbientProvider ambientProvider, IProvideValueTarget provideValue, IRootObjectProvider rootProvider) { if (prefixLookup == null) throw new ArgumentNullException ("prefixLookup"); if (schemaContext == null) throw new ArgumentNullException ("schemaContext"); prefix_lookup = prefixLookup; namespace_resolver = new NamespaceResolver (prefix_lookup.Namespaces); type_resolver = new XamlTypeResolver (namespace_resolver, schemaContext); sctx = schemaContext; ambient_provider = ambientProvider; this.provideValue = provideValue; this.rootProvider = rootProvider; }
public ValueSerializerContext(PrefixLookup prefixLookup, XamlSchemaContext schemaContext, IAmbientProvider ambientProvider, IProvideValueTarget provideValue, IRootObjectProvider rootProvider, IDestinationTypeProvider destinationProvider, IXamlObjectWriterFactory objectWriterFactory) { if (prefixLookup == null) { throw new ArgumentNullException("prefixLookup"); } if (schemaContext == null) { throw new ArgumentNullException("schemaContext"); } prefix_lookup = prefixLookup; sctx = schemaContext; ambient_provider = ambientProvider; this.provideValue = provideValue; this.rootProvider = rootProvider; this.destinationProvider = destinationProvider; this.objectWriterFactory = objectWriterFactory; }
public ValueSerializerContext(PrefixLookup prefixLookup, XamlSchemaContext schemaContext, IAmbientProvider ambientProvider, IProvideValueTarget provideValue, IRootObjectProvider rootProvider, IDestinationTypeProvider destinationProvider) { if (prefixLookup == null) { throw new ArgumentNullException("prefixLookup"); } if (schemaContext == null) { throw new ArgumentNullException("schemaContext"); } prefix_lookup = prefixLookup; namespace_resolver = new NamespaceResolver(prefix_lookup.Namespaces); type_resolver = new XamlTypeResolver(namespace_resolver, schemaContext); sctx = schemaContext; ambient_provider = ambientProvider; this.provideValue = provideValue; this.rootProvider = rootProvider; this.destinationProvider = destinationProvider; }
public static ValueSerializerContext Create(PrefixLookup prefixLookup, XamlSchemaContext schemaContext, IAmbientProvider ambientProvider, IProvideValueTarget provideValue, IRootObjectProvider rootProvider, IDestinationTypeProvider destinationProvider, IXamlObjectWriterFactory objectWriterFactory) { #if !HAS_TYPE_CONVERTER ValueSerializerContext context; var type = GetValueSerializerType(); if (type != null) { context = Activator.CreateInstance(type) as ValueSerializerContext; } else { context = new ValueSerializerContext(); } #else var context = new ValueSerializerContext(); #endif context.Initialize(prefixLookup, schemaContext, ambientProvider, provideValue, rootProvider, destinationProvider, objectWriterFactory); return(context); }
// Namespace and Reference retrieval. // It is iterated before iterating the actual object nodes, // and results are cached for use in XamlObjectReader. public void PrepareReading() { PrefixLookup.IsCollectingNamespaces = true; NameResolver.IsCollectingReferences = true; foreach (var xn in GetNodes()) { if (xn.NodeType == XamlNodeType.GetObject) { continue; // it is out of consideration here. } if (xn.NodeType == XamlNodeType.StartObject) { foreach (var ns in NamespacesInType(xn.Object.Type)) { PrefixLookup.LookupPrefix(ns); } } else if (xn.NodeType == XamlNodeType.StartMember) { var xm = xn.Member.Member; // This filtering is done as a black list so far. There does not seem to be any usable property on XamlDirective. if (xm == XamlLanguage.Items || xm == XamlLanguage.PositionalParameters || xm == XamlLanguage.Initialization) { continue; } PrefixLookup.LookupPrefix(xn.Member.Member.PreferredXamlNamespace); } else { if (xn.NodeType == XamlNodeType.Value && xn.Value is Type) { // this tries to lookup existing prefix, and if there isn't any, then adds a new declaration. TypeExtensionMethods.GetStringValue(XamlLanguage.Type, xn.Member.Member, xn.Value, value_serializer_ctx); } continue; } } PrefixLookup.Namespaces.Sort((nd1, nd2) => String.CompareOrdinal(nd1.Prefix, nd2.Prefix)); PrefixLookup.IsCollectingNamespaces = false; NameResolver.IsCollectingReferences = false; NameResolver.NameScopeInitializationCompleted(this); }