Inheritance: IValueSerializerContext, IXamlSchemaContextProvider
コード例 #1
0
        public static ValueSerializerContext Create(PrefixLookup prefixLookup, XamlSchemaContext schemaContext, Func <IAmbientProvider> ambientProvider, IProvideValueTarget provideValue, IRootObjectProvider rootProvider, IDestinationTypeProvider destinationProvider, IXamlObjectWriterFactory objectWriterFactory)
        {
            var context = new ValueSerializerContext();

            context.Initialize(prefixLookup, schemaContext, ambientProvider, provideValue, rootProvider, destinationProvider, objectWriterFactory);
            return(context);
        }
コード例 #2
0
ファイル: XamlWriterInternalBase.cs プロジェクト: nobled/mono
		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);
		}
コード例 #3
0
ファイル: XamlObjectWriter.cs プロジェクト: davidwaters/mono
		public XamlObjectWriter (XamlSchemaContext schemaContext, XamlObjectWriterSettings settings)
		{
			if (schemaContext == null)
				throw new ArgumentNullException ("schemaContext");
			this.sctx = schemaContext;
			this.settings = settings ?? new XamlObjectWriterSettings ();

			var p = new PrefixLookup (sctx);
			service_provider = new ValueSerializerContext (p, sctx);
			namespaces = p.Namespaces;
		}
コード例 #4
0
        protected XamlWriterInternalBase(XamlSchemaContext schemaContext, XamlWriterStateManager manager, IAmbientProvider parentAmbientProvider = null)
        {
            this.object_states = new ObjectStateStack(parentAmbientProvider);
            this.sctx          = schemaContext;
            this.manager       = manager;
            var p = new PrefixLookup(sctx)
            {
                IsCollectingNamespaces = true
            };                                                                            // it does not raise unknown namespace error.

            service_provider = ValueSerializerContext.Create(p, schemaContext, object_states.GetAmbientProvider, this, this, this, this as IXamlObjectWriterFactory);
        }
コード例 #5
0
        public static ValueSerializerContext Create(PrefixLookup prefixLookup, XamlSchemaContext schemaContext, Func <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);
        }
コード例 #6
0
ファイル: XamlObjectReader.cs プロジェクト: spencerhakim/mono
		public XamlObjectReader (object instance, XamlSchemaContext schemaContext, XamlObjectReaderSettings settings)
		{
			if (schemaContext == null)
				throw new ArgumentNullException ("schemaContext");
			// FIXME: special case? or can it be generalized? In .NET, For Type instance Instance returns TypeExtension at root StartObject, while for Array it remains to return Array.
			if (instance is Type)
				instance = new TypeExtension ((Type) instance);

			// See also Instance property for this weirdness.
			this.root_raw = instance;
			instance = TypeExtensionMethods.GetExtensionWrapped (instance);
			this.root = instance;

			sctx = schemaContext;
//			this.settings = settings;

			// check type validity. Note that some checks also needs done at Read() phase. (it is likely FIXME:)
			if (instance != null) {
				var type = new InstanceContext (instance).GetRawValue ().GetType ();
				if (!type.IsPublic)
					throw new XamlObjectReaderException (String.Format ("instance type '{0}' must be public and non-nested.", type));
				var xt = SchemaContext.GetXamlType (type);
				if (xt.ConstructionRequiresArguments && !xt.GetConstructorArguments ().Any () && xt.TypeConverter == null)
					throw new XamlObjectReaderException (String.Format ("instance type '{0}' has no default constructor.", type));
			}

			value_serializer_context = new ValueSerializerContext (new PrefixLookup (sctx), sctx, null);
			new XamlObjectNodeIterator (instance, sctx, value_serializer_context).PrepareReading ();
		}
コード例 #7
0
		public XamlObjectNodeIterator (object root, XamlSchemaContext schemaContext, PrefixLookup prefixLookup)
		{
			ctx = schemaContext;
			this.root = root;
			value_serializer_ctx = new ValueSerializerContext (prefixLookup, ctx);
		}