public XDocument Convert(IConvertibleModel model) { SpektrumModel newModel = new SpektrumModel(); newModel.Spektrum.Name = model.StandardizedModelInformation.ModelName; newModel.Spektrum.VCode = " 1.05"; string serializedModelString = SerializationHelper <SpektrumModel> .Serialize(newModel); return(XDocument.Parse(serializedModelString));// }
public XDocument Convert(IConvertibleModel model) { _Logger.Info("Converting model to a Spektrum DX8 radio type."); SpektrumModel newDX8Model = new SpektrumModel(); _Logger.Debug("Model: {0}", model.StandardizedModelInformation.ModelName); _Logger.Debug("Converting the model information."); newDX8Model.Spektrum.Name = model.StandardizedModelInformation.ModelName; newDX8Model.Spektrum.VCode = model.StandardizedModelInformation.Version; _Logger.Debug("Converting the configuration information."); newDX8Model.Config.FrameRate = model.StandardizedConfiguration.FrameRate; newDX8Model.Config.trimMode = model.StandardizedConfiguration.TrimMode; newDX8Model.Config.TrimType = model.StandardizedConfiguration.TrimType; _Logger.Debug("Converting the trainer information."); newDX8Model.Trainer.Type = model.StandardizedTrainer.Type; _Logger.Debug("Converting FMode."); newDX8Model.FMode.switch_a = model.StandardizedFlightMode.SwitchA; newDX8Model.FMode.switch_b = model.StandardizedFlightMode.SwitchB; newDX8Model.FMode.switch_c = model.StandardizedFlightMode.SwitchC; newDX8Model.FMode.size = model.StandardizedFlightMode.Size; DateTime start = DateTime.Now; _Logger.Debug("Starting serialization..."); string serializedModelString = SerializationHelper <SpektrumModel> .Serialize(newDX8Model); _Logger.Debug("Serialization complete. It took: {0}", DateTime.Now - start); StreamReader sReader = new StreamReader(new MemoryStream(System.Text.UTF8Encoding.Default.GetBytes(serializedModelString))); XmlReader reader = XmlReader.Create(sReader); return(XDocument.Load(reader)); }
public static SpektrumModel CreateTestModel() { SpektrumModel model = new SpektrumModel() { ModelDescription = new ModelDescription() { EOFMarkerText = "*EOF*", NewLineMarker = "
" }, Spektrum = new SpektrumInformation() { Generator = "DX18", VCode = " 1.00", PosIndex = "5", Type = "Acro", curveIndex = "7", enabXPLUS = "Disabled", Name = "DHC-6 Twin Otter", AttributeDescriptors = new Descriptor[] { new Descriptor() { AttributeName = "Generator", IsString = true, SeparatorStyle = "=", ValueHasPreceedingSpace = false }, new Descriptor() { AttributeName = "VCode", IsString = true, SeparatorStyle = "=", ValueHasPreceedingSpace = false }, new Descriptor() { AttributeName = "PosIndex", IsString = false, SeparatorStyle = "=", ValueHasPreceedingSpace = true }, new Descriptor() { AttributeName = "Type", IsString = false, SeparatorStyle = "=", ValueHasPreceedingSpace = false } } }, Trainer = new Trainer() { Type = "Disabled", conditionID = "92", MOverride = "Disabled", activePositions = "0", AttributeDescriptors = new Descriptor[] { } } }; return(model); }