private static string EmptyInstanceString(this IWireSerialization serializer, Type target, HttpContext context) { try { return(SerializeToString(serializer, TemporaryResources.CreateRandomObject(target), context)); } catch (Exception ex) { return(Exceptions.DebugMode ? "Error creating instance example: " + ex.Message : "Error creating instance example ;("); } }
private static TFormat CreateExampleArgument <TFormat>(ISerialization <TFormat> serializer, Type rootType) { try { var array = Array.CreateInstance(rootType, 1); var element = TemporaryResources.CreateRandomObject(rootType); array.SetValue(element, 0); return(serializer.Serialize(new Argument <TFormat> { RootName = rootType.FullName, ToInsert = serializer.Serialize((dynamic)array) })); } catch { //fallback to simple example since sometimes calculated properties will throw exception during serialization return(CreateExampleArgument(serializer)); } }
private static TFormat CreateExampleArgument <TFormat>(ISerialization <TFormat> serializer, Type rootType) { try { return (serializer.Serialize( new Argument <TFormat> { Name = rootType.FullName, Data = serializer.Serialize((dynamic)TemporaryResources.CreateRandomObject(rootType)) })); } catch { //fallback to simple example since sometimes calculated properties will throw exception during serialization return(CreateExampleArgument(serializer)); } }