throw new ArgumentOutOfRangeException ("maxItemsInObjectGraph");
this.type = type;
- known_types = new ReadOnlyCollection<Type> (knownTypes != null ? knownTypes.ToArray () : Type.EmptyTypes);
+
+ var knownTypesFromAttributes = new List<Type> ();
+
+ foreach (var attr in type.GetCustomAttributes (typeof (KnownTypeAttribute), false))
+ knownTypesFromAttributes.Add ((attr as KnownTypeAttribute).Type);
+
+ if (knownTypes != null)
+ knownTypesFromAttributes.AddRange (knownTypes);
+
+ known_types = new ReadOnlyCollection<Type> (knownTypesFromAttributes);
+
root = rootName;
max_items = maxItemsInObjectGraph;
ignore_extension = ignoreExtensionDataObject;
{
}
+ public DataContractJsonSerializer (Type type, DataContractJsonSerializerSettings settings)
+ : this (type, settings.RootName, settings.KnownTypes, settings.MaxItemsInObjectGraph, settings.IgnoreExtensionDataObject,
+ settings.DataContractSurrogate, false)
+ {
+ }
+
#endregion
Type type;
public bool IgnoreExtensionDataObject {
get { return ignore_extension; }
}
-
- [MonoTODO]
public ReadOnlyCollection<Type> KnownTypes {
get { return known_types; }
}
return new JsonSerializationReader (this, reader, type, verifyObjectName).ReadRoot ();
} catch (SerializationException) {
throw;
+ } catch (InvalidDataContractException) {
+ throw;
+ } catch (System.Reflection.TargetInvocationException ex) {
+ throw ex.InnerException;
} catch (Exception ex) {
throw new SerializationException ("Deserialization has failed", ex);
}
throw new ArgumentNullException ("writer");
writer.WriteEndElement ();
}
+
+ [MonoTODO]
+ public DateTimeFormat DateTimeFormat {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public EmitTypeInformation EmitTypeInformation {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public bool SerializeReadOnlyTypes {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public bool UseSimpleDictionaryFormat {
+ get { throw new NotImplementedException (); }
+ }
+
}
}