private async void ConversionType_SelectedIndexChangedAsync(object sender, EventArgs e) { await _dataPopulator.EnsureDataPopulationAsync(); if (!_dataPopulator.IsPopulated()) { MessageBox.Show("An error has occured!"); return; } ClearInput(); conversionDirection = ConversionType.SelectedIndex == 0 ? ConversionDirection.ToWindows : ConversionDirection.ToIana; switch (conversionDirection) { case ConversionDirection.ToWindows: _dataPopulator.DataEntries.OrderBy(x => x.IANATimeZoneID) .ToList() .ForEach(entry => comboBox2.Items.Add(entry.IANATimeZoneID)); break; case ConversionDirection.ToIana: var distinctEntries = _dataPopulator.DataEntries.Select(x => x.WinTimeZoneID) .Distinct() .OrderBy(x => x).ToList(); distinctEntries.ForEach(entry => comboBox2.Items.Add(entry)); break; } }
public static AbstractConverter Instance(ConversionDirection transformDirection) { switch (transformDirection) { case ConversionDirection.DocxToOdt: case ConversionDirection.OdtToDocx: if (wordInstance == null) { wordInstance = new Wordprocessing.Converter(); } return(wordInstance); case ConversionDirection.PptxToOdp: case ConversionDirection.OdpToPptx: if (presentationInstance == null) { presentationInstance = new Sonata.OdfConverter.Presentation.Converter(); } return(presentationInstance); case ConversionDirection.XlsxToOds: case ConversionDirection.OdsToXlsx: if (spreadsheetInstance == null) { spreadsheetInstance = new CleverAge.OdfConverter.Spreadsheet.Converter(); } return(spreadsheetInstance); default: throw new ArgumentException("Invalid transform direction type"); } }
/// <summary> /// Invert this conversion direction /// </summary> /// <param name="value"></param> /// <returns></returns> public static ConversionDirection Invert(this ConversionDirection value) { if (value == ConversionDirection.AtoB) { return(ConversionDirection.BtoA); } else if (value == ConversionDirection.BtoA) { return(ConversionDirection.AtoB); } else { return(ConversionDirection.Both); } }
public string GetColumnExpression(Func <string, string> outsideFormat, ConversionDirection direction) { if (_hasConversion && direction != ConversionDirection.None) { SqlDbType target = TargetDataType; if (direction == ConversionDirection.Original) { target = SqlDataType; } return(Config.Global.DefaultSqlProvider.FormulateConversionExpression( target, outsideFormat(AssociatedProperty.Name))); } return(outsideFormat(AssociatedProperty.Name)); }
private bool validateFile(string input, string output, ConversionDirection transformDirection) { try { if (transformDirection == ConversionDirection.OdtToDocx || transformDirection == ConversionDirection.OdsToXlsx || transformDirection == ConversionDirection.OdpToPptx) { if (this._ooxValidator == null) { this._report.AddComment("Instantiating OpenXML validator, please wait..."); this._ooxValidator = new OoxValidator(this._report); this._report.AddComment("Validator instanciated"); } this._ooxValidator.validate(output); } else { if (this._odfValidator == null) { this._report.AddComment("Instantiating ODF validator, please wait..."); this._odfValidator = new OdfValidator(this._report); this._report.AddComment("Validator instanciated"); } this._odfValidator.validate(output); } this._report.LogInfo(input, "Converted file {0} is valid", output); return(true); } catch (ValidationException e) { this._report.LogWarning(input, "Converted file {0} is not valid", output); this._report.LogDebug(input, e.Message + "(" + e.StackTrace + ")"); return(false); } catch (Exception e) { this._report.LogError(input, "An unexpected exception occurred when trying to validate {0}", output); this._report.LogDebug(input, e.Message + "(" + e.StackTrace + ")"); return(false); } }
public bool CanConvert(Type fromType, Type toType, ConversionDirection direction) { IPipeConverter childConv; bool hasConversionDelegate; if (direction == ConversionDirection.ToPipe) { childConv = GetToPipeConverter(fromType, toType); hasConversionDelegate = _toPipeConversionDelegate != null; } else if (direction == ConversionDirection.FromPipe) { childConv = GetFromPipeConverter(fromType, toType); hasConversionDelegate = _fromPipeConversionDelegate != null; } else { return(false); } bool hasValidChild = childConv != null && childConv.CanConvert(fromType, toType, direction); return(hasValidChild || hasConversionDelegate); }
public JSONPropertyAttribute(ConversionDirection customconversiondirection) => CustomConverterDirection = customconversiondirection;
public JSONPropertyAttribute(IgnoreDirection ignore, ConversionDirection customconversiondirection, string alias) { Ignore = ignore; CustomConverterDirection = customconversiondirection; Alias = alias; }
/// <summary> /// Path and direction constructor /// </summary> /// <param name="pathA"></param> /// <param name="pathB"></param> /// <param name="direction"></param> public PropertyMapping(string pathA, string pathB, ConversionDirection direction) : this(pathA, pathB) { Direction = direction; }
private static void Main(string[] args) // hacky code, sorry if you read this but it does the job, feel free to improve it :) { if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "option.sav")) { Console.WriteLine("BOTW_SaveConv" + Environment.NewLine); Console.WriteLine("Make sure you made a backup of your save files in case the conversion fail." + Environment.NewLine); Console.WriteLine("Press Y to continue, press any other key to abort."); if (Console.ReadKey().Key != ConsoleKey.Y) { Environment.Exit(0); } else { ClearLine(); } foreach (string file in Directory.EnumerateFiles(Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory), "*.sav", SearchOption.AllDirectories)) { FileStream fs = new FileStream(file, FileMode.Open); BinaryReader br = new BinaryReader(fs); FileInfo f = new FileInfo(file); if (Path.GetFileName(file) == "option.sav") { br.BaseStream.Position = 0; byte[] check = br.ReadBytes(Convert.ToInt32(1)); Direction = ByteArrayToString(check) == "00" ? ConversionDirection.WiiUToSwitch : ConversionDirection.SwitchToWiiU; Console.WriteLine(Environment.NewLine + From + " version of BOTW detected, starting conversion to the " + To + " version..." + Environment.NewLine); } using (var progress = new ProgressBar()) { Console.WriteLine(Environment.NewLine + "Processing " + Path.GetFileName(Path.GetDirectoryName(file)) + "/" + Path.GetFileName(file)); for (int h = 0; h < f.Length / 4; h++) { br.BaseStream.Position = h * 4; byte[] EndianConv = br.ReadBytes(Convert.ToInt32(4)); if (Hash.Contains(ByteArrayToString(EndianConv))) // skip strings { Array.Reverse(EndianConv); BinaryWriter EndianUpd = new BinaryWriter(fs); fs.Position = h * 4; EndianUpd.Write(EndianConv); h++; Skip = true; } else { Skip = false; } if (CheckString(EndianConv) == false && Skip == false) // make sure we don't convert strings { Array.Reverse(EndianConv); BinaryWriter EndianUpd = new BinaryWriter(fs); fs.Position = h * 4; EndianUpd.Write(EndianConv); } else if (Skip == false) { h++; for (int i = 0; i < 16; i++) { br.BaseStream.Position = (h + (i * 2)) * 4; byte[] EndianHash = br.ReadBytes(Convert.ToInt32(4)); Array.Reverse(EndianHash); BinaryWriter EndianUpd = new BinaryWriter(fs); fs.Position = (h + (i * 2)) * 4; EndianUpd.Write(EndianHash); } h = h + 0x1E; } progress.Report((double)h * 4 / f.Length); } ClearLine(); ClearLine(); Console.WriteLine(Path.GetFileName(Path.GetDirectoryName(file)) + "/" + Path.GetFileName(file) + " processed."); } br.Close(); } Console.WriteLine(Environment.NewLine + "Conversion " + From + "->" + To + " done!"); } else { Console.WriteLine("BOTW_SaveConv"); Console.WriteLine("by WemI0" + Environment.NewLine); Console.WriteLine("Converts WiiU <-> Switch BOTW Savegame" + Environment.NewLine); Console.WriteLine("Usage: Put 'BOTW_SaveConv.exe' into the folder that contains option.sav, and run it"); Console.ReadLine(); Environment.Exit(0); } Console.ReadLine(); }