Ejemplo n.º 1
0
 public static void SaveADXFile(ADIFData data, string outputLocation)
 {
     var serializer = new XmlSerializer(typeof(ADIFData));
     var ns = new XmlSerializerNamespaces();
     ns.Add("", "");
     serializer.Serialize(new FileStream(outputLocation, FileMode.Create), data, ns);
 }
Ejemplo n.º 2
0
        public static void SaveADXFile(ADIFData data, string outputLocation)
        {
            var serializer = new XmlSerializer(typeof(ADIFData));
            var ns         = new XmlSerializerNamespaces();

            ns.Add("", "");
            serializer.Serialize(new FileStream(outputLocation, FileMode.Create), data, ns);
        }
Ejemplo n.º 3
0
        public static string ConvertToADX(ADIFData data)
        {
            var serializer = new XmlSerializer(typeof(ADIFData));
            var ns = new XmlSerializerNamespaces();
            ns.Add("", "");

            using (var sw = new Utf8StringWriter())
            {
                serializer.Serialize(sw, data, ns);
                return sw.ToString();
            }
        }
Ejemplo n.º 4
0
        public static string ConvertToADX(ADIFData data)
        {
            var serializer = new XmlSerializer(typeof(ADIFData));
            var ns         = new XmlSerializerNamespaces();

            ns.Add("", "");

            using (var sw = new Utf8StringWriter())
            {
                serializer.Serialize(sw, data, ns);
                return(sw.ToString());
            }
        }
Ejemplo n.º 5
0
        public void CanSerializeSampleFile()
        {
            // serialize sample ADX file from http://www.adif.org/304/ADIF_304.htm#ADX_File_Format 
            var dataObject = new ADIFData();
            dataObject.Header = new ADIFHeader();
            dataObject.Header.ADIFVersion = ADIFIO.ADIFVersion;
            dataObject.Header.ProgramID = "monolog";
            dataObject.Header.UserDefinedFields = new List<ADIFUserDefinedFieldHeader>();
            dataObject.Header.UserDefinedFields.Add(new ADIFUserDefinedFieldHeader { FieldID = 1, Type = "N", Value = "EPC" });
            dataObject.Header.UserDefinedFields.Add(new ADIFUserDefinedFieldHeader { FieldID = 2, Type = "E", Enum = "{S,M,L}", Value = "SWEATERSIZE" });
            dataObject.Header.UserDefinedFields.Add(new ADIFUserDefinedFieldHeader { FieldID = 3, Type = "E", Range = "{5:20}", Value = "SHOESIZE" });

            dataObject.Records = new List<ADIFRecord>();

            var firstRecord = new ADIFRecord();
            firstRecord.QSODate = "19900620";
            firstRecord.TimeOn = "1523";
            firstRecord.Callsign = "VK9NS";
            firstRecord.Band = "20M";
            firstRecord.Mode = "RTTY";

            firstRecord.UserDefinedFields = new List<ADIFUserDefinedFieldRecord>();
            firstRecord.UserDefinedFields.Add(new ADIFUserDefinedFieldRecord("SWEATERSIZE", "M"));
            firstRecord.UserDefinedFields.Add(new ADIFUserDefinedFieldRecord("SHOESIZE", "11"));

            firstRecord.AppDefinedFields = new List<ADIFAppDefinedFieldRecord>();
            firstRecord.AppDefinedFields.Add(new ADIFAppDefinedFieldRecord("MONOLOG", "Compression", "s", "off"));

            var secondRecord = new ADIFRecord();
            secondRecord.QSODate = "20101022";
            secondRecord.TimeOn = "0111";
            secondRecord.Callsign = "ON4UN";
            secondRecord.Band = "40M";
            secondRecord.Mode = "PSK";
            secondRecord.Submode = "PSK63";

            secondRecord.UserDefinedFields = new List<ADIFUserDefinedFieldRecord>();
            secondRecord.UserDefinedFields.Add(new ADIFUserDefinedFieldRecord("EPC", "32123"));

            secondRecord.AppDefinedFields = new List<ADIFAppDefinedFieldRecord>();
            secondRecord.AppDefinedFields.Add(new ADIFAppDefinedFieldRecord("MONOLOG", "COMPRESSION", "s", "off"));

            dataObject.Records.Add(firstRecord);
            dataObject.Records.Add(secondRecord);

            var adx = ADIFIO.ConvertToADX(dataObject);
            ADIFIO.SaveADXFile(dataObject, "C:\\data.xml");
        }
Ejemplo n.º 6
0
        public void CanSerializeHeaderAndNoRecords()
        {
            var dataObject = new ADIFData();
            dataObject.Header = new ADIFHeader
            {
                ADIFVersion = ADIFIO.ADIFVersion,
                CreatedTimestamp = "20150118 234500",
                ProgramID = "Test Program",
                ProgramVersion = "0.1 alpha"
            };
            dataObject.Records = new List<ADIFRecord>();

            var adx = ADIFIO.ConvertToADX(dataObject);

            var rgx = new Regex(@"<\?xml.+\?>\s*<ADX>\s*<HEADER>[\s\S]*<\/HEADER>\s*<RECORDS \/>\s*<\/ADX>");
            Assert.IsTrue(rgx.IsMatch(adx));
        }
Ejemplo n.º 7
0
 public static void Save(ADIFData data, string outputLocation)
 {
     //TODO determine if ADX or ADI from file ext, or error out
     throw new NotImplementedException();
 }
Ejemplo n.º 8
0
 public static void Save(ADIFData data, string outputLocation)
 {
     //TODO determine if ADX or ADI from file ext, or error out
     throw new NotImplementedException();
 }