Ejemplo n.º 1
0
 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 ;(");
     }
 }
Ejemplo n.º 2
0
 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));
     }
 }
Ejemplo n.º 3
0
 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));
     }
 }