.NET Fiddle

CSharp · Console

/Program.cs

using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
using System.Xml.Serialization;
using System.Threading.Tasks;
using System.Diagnostics;


[XmlRoot("BaseSyncOneWayInput")]
public class BaseSyncOneWayInput<TPrimaryKey>
{
	//public Dictionary<string, object> RemoteParameters { get; set; }
	
	public String Filter { get; set; }
	
	public Object[] Parameters { get; set; }
	
	public List<TPrimaryKey> ExistingIds { get; set; }
}


public abstract class XmlParser<T> where T : new()
{
	public static string ObjectToXML(T obj)
	{
		MemoryStream stream = new MemoryStream();
		
		using (StreamWriter reader = new StreamWriter(stream))
		{
			XmlRootAttribute xRoot = new XmlRootAttribute();
			//xRoot.ElementName = (typeof(T).ToString()).Split('.').Last();
			xRoot.ElementName = typeof(T).Name;
			xRoot.IsNullable = true;
			XmlSerializer serializer = new XmlSerializer(typeof(T),xRoot);
			serializer.Serialize(stream, obj);
			return ToString(stream);
		}
	}
	private static String ToString(Stream s)
	{
		s.Position = 0;
		using (StreamReader reader = new StreamReader(s, Encoding.UTF8))
		{
			return reader.ReadToEnd();
		}
	}

}
public class Program
{
	public static string Pull<TPrimaryKey>(string apiUrl = null, string filter = null, object[] parameters = null, Dictionary<string, object> remoteParameters = null)
        {
            try
            {
                var baseSyncInput = new BaseSyncOneWayInput<TPrimaryKey>()
                {
                    Filter = filter, Parameters = parameters, //RemoteParameters = remoteParameters, 
                    ExistingIds = new List<TPrimaryKey>()
                };
                var xml = XmlParser<BaseSyncOneWayInput<TPrimaryKey>>.ObjectToXML(baseSyncInput);
                return xml;

            }
            catch (Exception ex)
            {
#if DEBUG
                Debugger.Break();
#endif

                return null;
            }

        }
	
	
	public static void Main()
	{
		Console.WriteLine(Pull<string>());
	}
	
}
;