/// <summary> /// Set object to send as custom object /// </summary> /// <returns></returns> private static object CreateCustomObject() { int intValue = 0; string stringValue = "blank"; //Need user input Console.WriteLine("Please enter a number to store in intValue:"); while (true) { bool parseSucces = int.TryParse(Console.ReadLine(), out intValue); if (parseSucces) { break; } Console.WriteLine("Invalid value entered. Please try again."); } Console.WriteLine("\nPlease enter a string to store in stringValue:"); stringValue = Console.ReadLine(); if (NetworkComms.DefaultSendReceiveOptions.DataSerializer.GetType() == typeof(ProtobufSerializer)) { ProtobufCustomObject customObject = new ProtobufCustomObject(intValue, stringValue); return(customObject); } else if (NetworkComms.DefaultSendReceiveOptions.DataSerializer.GetType() == typeof(BinaryFormaterSerializer)) { BinaryFormatterCustomObject customObject = new BinaryFormatterCustomObject(intValue, stringValue); return(customObject); } else { JSONSerializerCustomObject customObject = new JSONSerializerCustomObject(intValue, stringValue); return(customObject); } }
/// <summary> /// Set object to send as custom object /// </summary> /// <returns></returns> private static object CreateCustomObject() { int intValue = 0; string stringValue = "blank"; //Need user input Console.WriteLine("Please enter a number to store in intValue:"); while (true) { bool parseSucces = int.TryParse(Console.ReadLine(), out intValue); if (parseSucces) break; Console.WriteLine("Invalid value entered. Please try again."); } Console.WriteLine("\nPlease enter a string to store in stringValue:"); stringValue = Console.ReadLine(); if (NetworkComms.DefaultSendReceiveOptions.DataSerializer.GetType() == typeof(ProtobufSerializer)) { ProtobufCustomObject customObject = new ProtobufCustomObject(intValue, stringValue); return customObject; } else if (NetworkComms.DefaultSendReceiveOptions.DataSerializer.GetType() == typeof(BinaryFormaterSerializer)) { BinaryFormatterCustomObject customObject = new BinaryFormatterCustomObject(intValue, stringValue); return customObject; } else { JSONSerializerCustomObject customObject = new JSONSerializerCustomObject(intValue, stringValue); return customObject; } }