System.Xaml.XamlObjectReader.XamlObjectReader C# (CSharp) Method

XamlObjectReader() public method

public XamlObjectReader ( object instance, XamlSchemaContext schemaContext, System.Xaml.XamlObjectReaderSettings settings ) : System
instance object
schemaContext XamlSchemaContext
settings System.Xaml.XamlObjectReaderSettings
return System
		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);
			new XamlObjectNodeIterator (instance, sctx, value_serializer_context).PrepareReading ();
		}
		

Same methods

XamlObjectReader::XamlObjectReader ( object instance ) : System
XamlObjectReader::XamlObjectReader ( object instance, System.Xaml.XamlObjectReaderSettings settings ) : System
XamlObjectReader::XamlObjectReader ( object instance, XamlSchemaContext schemaContext ) : System
XamlObjectReader