public ArchiveUpdateCallback(Formats format, string basePath, List<string> fileNames) { this.format = format; this.basePath = basePath; this.fileNames = fileNames; Success = true; }
/// <summary> /// The method create a Base64 encoded string from a normal string. /// </summary> /// <param name="toEncode">The String containing the characters to encode.</param> /// <returns>The Base64 encoded string.</returns> public static string EncodeTo64(string toEncode, Formats f) { try { byte[] toEncodeAsBytes = null; switch (f) { case Formats.UNICODE: toEncodeAsBytes = System.Text.Encoding.Unicode.GetBytes(toEncode); break; case Formats.UTF7: toEncodeAsBytes = System.Text.Encoding.UTF7.GetBytes(toEncode); break; case Formats.UTF8: toEncodeAsBytes = System.Text.Encoding.UTF8.GetBytes(toEncode); break; case Formats.UTF32: toEncodeAsBytes = System.Text.Encoding.UTF32.GetBytes(toEncode); break; case Formats.ASCII: default: toEncodeAsBytes = System.Text.Encoding.ASCII.GetBytes(toEncode); break; } string returnValue = System.Convert.ToBase64String(toEncodeAsBytes); return returnValue; } catch (Exception e) { throw new Exception("Error in EncodeTo64: " + e.Message); } }
/// <summary> /// Creates a new instance of the reflector /// </summary> /// <param name="config">The current NServiceMVC configuration</param> /// <param name="formatter">The current NServiceMVC FormatManager</param> public MetadataReflector(NServiceMVC.NsConfiguration config, Formats.FormatManager formatter) { Configuration = config; Formatter = formatter; // note: must initialize model before route ModelTypes = FindModelTypes(); BasicModelTypes = FindBasicModelTypes(); RouteDetails = FindRouteDetails(); }
/// <summary> /// Создать новый экземпляр класса Log /// </summary> protected Log() { format = Formats.Simple; writer = null; fileInfo = null; writeLock = new object(); FileName = ""; Encoding = Encoding.Default; Capacity = DefCapacity; CompName = Environment.MachineName; UserName = Environment.UserName; Break = new string('-', 80); DateTimeFormat = "yyyy'-'MM'-'dd' 'HH':'mm':'ss"; }
internal Engine(Configuration configuration) { Contract.Requires(configuration != null); _logger.EnterFunction(); _configuration = configuration; _books = new BlockingCollection<BookDescriptor>(); _removedBooks = new ConcurrentDictionary<BookDescriptor, BookDescriptor>(); _inputFormats = new InputFormats(); _outputFormats = new OutputFormats(); List<ExecutionContext> contexts = new List<ExecutionContext>(); for (int i = 0; i < Environment.ProcessorCount; i++) { contexts.Add(new ExecutionContext(_configuration, _books, _removedBooks)); } _contexts = contexts.AsReadOnly(); ValidateConverterPath(); _logger.LeaveFunction(); }
private StreamWriter writer; // объект для записи в файл #endregion Fields #region Constructors /// <summary> /// Создать новый экземпляр класса Log с заданным форматом записи /// </summary> public Log(Formats logFormat) : this() { format = logFormat; }
public override String Show(int col, int row, Formats fo) { return "{" + caf.Show(caf.formulaCol, caf.formulaRow, fo) + "}"; }
public Base64Service(Formats f) { m_Format = f; }
public String Show(int col, int row, Formats fo) { return formula.Show(col, row, fo); }
public static byte[] Standardize(byte[] Image, Formats DumpFormat) { if (Image == null) throw new ArgumentNullException(); switch (DumpFormat) { case Formats.SMD: // Assume this data has already been verified as a super magicdrive dump // so start by ignoring the 512 byte header, then divide the remainder by 16k chunks // (check for modulus to see if the rom is an odd size) //if(Data.Length % 0x4000 != 0) //modulus is not zero, file is an unexpected size, add a comment byte[] _out = new byte[Image.Length - 0x200]; int totalchunks = Image.Length / 0x4000; // outer loop through the total number of 16k chunks var thischunk = new byte[0x4000]; int outoffset = 0, outcount = 0; for (int chunkloop = 0; chunkloop < totalchunks; chunkloop++) { Buffer.BlockCopy(Image, 0x200 + (chunkloop * 0x4000), thischunk, 0, 0x4000); outoffset = chunkloop * 0x4000; outcount = 0; // decode the 16k block: the odd digit is from the low end of the block, the even digit is from the high end for (int deint = 0; deint < 0x2000; deint++) { _out[outoffset + outcount + 1] = thischunk[deint]; _out[outoffset + outcount] = thischunk[deint + 0x2000]; outcount += 2; } } return _out; default: return Image; } }
private static int CompressHuff(string infile, MemoryStream output, out Formats actualFormat) { return CompressBest(infile, output, out actualFormat, Formats.HUFF4, Formats.HUFF8); }
private static int CompressBest(string infile, MemoryStream output, out Formats actualFormat, params Formats[] formats) { // only read the input data once from the file. byte[] inputData; using (FileStream inStream = File.OpenRead(infile)) { inputData = new byte[inStream.Length]; inStream.Read(inputData, 0, inputData.Length); } MemoryStream bestOutput = null; int minCompSize = int.MaxValue; actualFormat = Formats.GBA; foreach (Formats format in formats) { #region compress the file in each format, and save the best one MemoryStream currentOutput = new MemoryStream(); CompressionFormat realFormat = null; switch (format) { case Formats.HUFF4: realFormat = new Huffman4(); break; case Formats.HUFF8: realFormat = new Huffman8(); break; case Formats.LZ10: realFormat = new LZ10(); break; case Formats.LZ11: realFormat = new LZ11(); break; case Formats.LZOVL: realFormat = new LZOvl(); break; case Formats.RLE: realFormat = new RLE(); break; default: Console.WriteLine("Unsupported single format: "+format); continue; } int currentOutSize; try { using (MemoryStream inStream = new MemoryStream(inputData)) { currentOutSize = realFormat.Compress(inStream, inStream.Length, currentOutput); } } catch (InputTooLargeException i) { Console.WriteLine(i.Message); actualFormat = format; return -1; } catch (Exception) { continue; } if (currentOutSize < minCompSize) { bestOutput = currentOutput; minCompSize = currentOutSize; actualFormat = format; } #endregion } if (bestOutput == null) { Console.WriteLine("The file could not be compressed in any format."); return -1; } bestOutput.WriteTo(output); return minCompSize; }
private static void Compress(string input, string output, Formats format, bool guessExtension) { if (!File.Exists(input) && !Directory.Exists(input)) { Console.WriteLine("Cannot compress a file or directory that does not exist (" + input + ")"); return; } // set the default value of the output if (string.IsNullOrEmpty(output)) { if (Directory.Exists(input)) { string newDir = Path.GetFullPath(input) + "_cmp"; if (!Directory.Exists(newDir)) Directory.CreateDirectory(newDir); foreach (string file in Directory.GetFiles(input)) { Compress(file, newDir, format, guessExtension); } return; } else { if (!guessExtension) output = input; // the .cdat extension is added automatically else output = Path.GetDirectoryName(input); } } if (Directory.Exists(input)) { if (!Directory.Exists(output)) Directory.CreateDirectory(output); foreach (string file in Directory.GetFiles(input)) { Compress(file, output, format, guessExtension); } return; } // compress the input MemoryStream compressedData = new MemoryStream(); Formats compressedFormat; int outsize = DoCompress(input, compressedData, format, out compressedFormat); if (outsize < 0) return; bool mustAppendExt = !Directory.Exists(output) && !File.Exists(output); if (Directory.Exists(output)) { output = CombinePaths(output, Path.GetFileName(input)); } if (mustAppendExt && Path.GetExtension(output) == ".dat") output = RemoveExtension(output); if (guessExtension) output += "." + compressedFormat.ToString().ToLower(); else if (mustAppendExt) output += ".cdat"; using (FileStream outStream = File.Create(output)) { compressedData.WriteTo(outStream); Console.WriteLine(compressedFormat.ToString() + "-compressed " + input + " to " + output); } }
public override String Show(int col, int row, Formats fo) { return "\"" + value.value + "\""; }
public override String Show(int col, int row, Formats fo) { return value.value.ToString(); }
public override String Show(int col, int row, Formats fo) { return "=" + e.Show(col, row, 0, fo); }
public static string Convert(string rtfText, Formats format) { if (rtfText == null || rtfText.Length == 0) { return ""; } if (htmltypestypes == null) { Initialize(); } bool bullets = false; bool liOpen = false; string txtHTML = ""; StringBuilder htmlString = new StringBuilder(); StringBuilder plainTextString = new StringBuilder(); ArrayList htmltypes = new ArrayList(); foreach (Type t in htmltypestypes) { HtmlType ht = (HtmlType) Activator.CreateInstance(t); ht.sb = htmlString; htmltypes.Add(ht); } int ir; //these are consts, kept in consts to make them ui-editable at some point //const string borderstyle="solid"; //const bool usecopy = true; const int tabindent = 20; //moved from const to editable :) string bordercolor = inttohex(0), backcolor = inttohex(Color.White.ToArgb()); //divcount keeps track of the number of open <div> blocks to ensure they are all closed at the end int divcount = 0 /*, // startas=0*/; #region Margin/border, start //start div with margins and border htmlString.Append(@"<" + block + " style='"); htmlString.Append("'>"); divcount++; #endregion #region start of actual text-section htmlString.Append("<" + block + " style=\"overflow:auto;"); //get the font info //Font settings (size and font-family are set only once in this version) htmlString.Append("font-size:"); htmlString.Append(((int) (GDIConstants.UIStandardFont.Size*1.5)).ToString()); htmlString.Append(";font-family:'" + GDIConstants.UIStandardFont.FontFamily.Name + "'"); //Backcolor htmlString.Append("\">"); divcount++; #endregion FontTable.LoadRTF(rtfText); string txt = rtfText; int spacecount = 0, len = txt.Length - 2, pstep = len/5; Tabber tab = new Tabber(tabindent, htmlString, plainTextString); try { #region code int k = 1; if (txt[0] != '{') { k = 0; len = txt.Length; } for (int i = k; i < len; i++) //Start from first position, skip first "{", len is one less then length: skip last "}" { char c = txt[i]; if (IgnoreList.IndexOf(c) != -1) { continue; } if (c == '\\') { //keyword? c = txt[++i]; if (c == '\'' && txt[i + 1] != 'B') //umlaut? { //flush all waiting spaces if (spacecount > 0) { if (spacecount == 1) { htmlString.Append(" "); plainTextString.Append(" "); spacecount = 0; } else { for (; spacecount > 0; spacecount--) { htmlString.Append(space); plainTextString.Append(" "); } } } string hex = txt[++i] + txt[++i].ToString(); string umlaut = hex2dec(hex); htmlString.Append("&#" + umlaut + ";"); int umlautCode = int.Parse(umlaut); plainTextString.Append((char) umlautCode); continue; } if (@"\{}".IndexOf(c) == -1) //check for escape sequence { //no escape sequence->keyword #region keywords int kwstart = i; while (++i < len && " {\\\r\n};".IndexOf(txt[i]) == -1) { // Debug.WriteLine(i + "test"); } string kw = txt.Substring(kwstart, i - kwstart); if (kw == "par") { if (tab.NewLine) { htmlString.Append("<br/>"); plainTextString.Append("\n"); } else { tab.NewLine = true; } if (bullets && liOpen) { liOpen = false; htmlString.Append("</li>"); } spacecount = 0; } // else if (kw == "tab") // { // tab.Add(); // } else if (kw == "pnlvlblt") { // htmlString.Append("<li>"); bullets = true; } else if (kw == "pard") { bullets = false; } else if (kw == "pntext") //skip section {\\pntext\\f1\\'B7\\tab} { while (txt[i] != '}') { i++; } } else if (kw == "colortbl") { //colourtable-> read out cols. ArrayList al = new ArrayList(); i += 2; Regex rx = new Regex(@"\\red(\d+)\\green(\d+)\\blue(\d+)"); while (txt[i] != '}') { kwstart = i; while (txt[++i] != ';') { ; } Match m = rx.Match(txt, kwstart, i - kwstart); if (!m.Success) { throw new Exception("Unexpected error: Could not parse colors"); } al.Add(Color.FromArgb( int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value), int.Parse(m.Groups[3].Value))); i++; } foreach (HtmlType ht in htmltypes) { if (ht is FontColor) { ((FontColor) ht).Schema = (Color[]) al.ToArray(typeof (Color)); } } } else if (txt[i] == '{' && (kw.IndexOf("fs") == -1 && kw.IndexOf("cf") == -1)) //sa nu imi ignore sectiuni de {} dupa anumite tag-uri { int cnt = 1; for (i++; cnt > 0; i++) { if (txt[i] == '{') { cnt++; } else if (txt[i] == '}') { cnt--; } } i--; } else { foreach (HtmlType ht in htmltypes) { if (ht.CheckChanged(ref kw)) { //tab.Check(); break; } } } if (txt[i] == '\\') { i--; } continue; #endregion } } tab.Check(); #region space (one space is used normally (' '), more than one as a collection of   ) if (c == ' ') { spacecount++; continue; } else if (spacecount > 0) { if (spacecount == 1) { htmlString.Append(" "); plainTextString.Append(" "); spacecount = 0; } else { if (spacecount > 100) { spacecount = 100; // limit the number of consecutive spaces in the text. It might be a bug } for (; spacecount > 0; spacecount--) { htmlString.Append(space); plainTextString.Append(" "); } } } #endregion if (bullets && liOpen == false) { liOpen = true; htmlString.Append("<li>"); } ir = Array.IndexOf(ToReplace, c); if (ir != -1) { htmlString.Append(ReplaceWith[ir]); plainTextString.Append(" "); } else { htmlString.Append(c); plainTextString.Append(c); } } #endregion if (bullets && liOpen) { liOpen = false; htmlString.Append("</li>"); } //Close all open html-tags foreach (HtmlType ht in htmltypes) { ht.Close(); } //Close all open div tags divcount += tab.OpenDivs; for (; divcount > 0; divcount--) { htmlString.Append("</" + block + ">"); } switch (format) { case Formats.Html: txtHTML = htmlString.ToString(); txtHTML = UmlautsHelper.ReplaceUmlautsForHtml(txtHTML); break; case Formats.PlainText: txtHTML = plainTextString.ToString(); break; } if (txtHTML.Length > 70) { List<char> newTextWithSpaces = new List<char>(); int ci = 0; for (int i = 0; i < txtHTML.Length;i++) { if (txtHTML[i] != ' ') ci++; else ci = 0; if(ci > 69) { newTextWithSpaces.Add(' '); ci = 0; } newTextWithSpaces.Add(txtHTML[i]); } txtHTML = new string(newTextWithSpaces.ToArray()); } return txtHTML; } catch (Exception ex) { Debug.WriteLine(ex.Message + "\n\n" + ex.StackTrace); return ""; } }
public static string GetDumpInfo(Formats DumpFormat) { switch (DumpFormat) { case Formats.SMD: return "Super MagicDrive format - Interleaved, 512 byte header"; case Formats.RAW: return "Raw format"; default: return "Unknown dump format"; } }
private static int CompressNDS(string infile, MemoryStream output, out Formats actualFormat) { return CompressBest(infile, output, out actualFormat, Formats.HUFF4, Formats.HUFF8, Formats.LZ10, Formats.LZ11, Formats.RLE); }
public void setMonochrome(bool monochrome) { this.monochrome = monochrome; if (monochrome) { formats = new MonochromeFormats(); } else { formats = new AnsiFormats(); } }
public static string GetDumpInfo(Formats DumpFormat) { switch (DumpFormat) { case Formats.FIG: return "Pro Fighter format - 512 byte header"; case Formats.SMC: return "Super Magicom format - 512 byte header"; case Formats.SWC: return "Super Wild Card format - 512 byte header"; case Formats.RAW: return "Raw format"; default: return "Unknown dump format"; } }
private static int DoCompress(string infile, MemoryStream output, Formats format, out Formats actualFormat) { CompressionFormat fmt = null; switch (format) { case Formats.LZ10: fmt = new LZ10(); break; case Formats.LZ11: fmt = new LZ11(); break; case Formats.LZOVL: fmt = new LZOvl(); break; case Formats.RLE: fmt = new RLE(); break; case Formats.HUFF4: fmt = new Huffman4(); break; case Formats.HUFF8: fmt = new Huffman8(); break; case Formats.HUFF: return CompressHuff(infile, output, out actualFormat); case Formats.GBA: return CompressGBA(infile, output, out actualFormat); case Formats.NDS: return CompressNDS(infile, output, out actualFormat); default: throw new Exception("Unhandled compression format " + format); } actualFormat = format; using (FileStream inStream = File.OpenRead(infile)) { try { return fmt.Compress(inStream, inStream.Length, output); } catch (Exception s) { // any exception generated by compression is a fatal exception Console.WriteLine(s.Message); return -1; } } }
public override String Show(int col, int row, Formats fo) { return ""; }
/* PRIVATE UTILITIES */ private Texture2DDescription CreateTextureDescription(int height, int width, Formats format) { return new Texture2DDescription() { ArraySize = 1, BindFlags = BindFlags.ShaderResource, CpuAccessFlags = CpuAccessFlags.None, Format = (Format)format, Height = height, MipLevels = 1, OptionFlags = ResourceOptionFlags.None, SampleDescription = new SampleDescription(1, 0), Usage = ResourceUsage.Default, Width = width, }; }
/// <summary> /// Adds a new input element to the vertex layout. /// <para> </para> /// Using this method, input elements are added sequentially to the default buffer slot (zero). Offsets are determined <para/> /// automatically using the format parameter. /// </summary> /// <param name="format">The format of the vertex data element.</param> /// <param name="name">The semantic name (with the semantic index, if applicable) of the vertex data element.</param> public void Add(Formats format, string name) { Add(format, false, name, 0); }
public static byte[] Standardize(byte[] Image, Formats DumpFormat) { if (Image == null) throw new ArgumentNullException(); byte[] _out; switch (DumpFormat) { case Formats.FIG: case Formats.SMC: case Formats.SWC: _out = new byte[Image.Length - 512]; Buffer.BlockCopy(Image, 512, _out, 0, _out.Length); return _out; default: return Image; } }
/// <summary> /// Adds a new input element to the vertex layout. /// <para> </para> /// New input elements are added sequentially to the buffer in the designated slot index. The byte offsets for elements of <para/> /// each buffer slot are calculated automatically using the format parameter. Additionally, new vertex data elements may be <para/> /// designated as instanced values. /// </summary> /// <param name="format">The formatm of the vertex data element.</param> /// <param name="isInstanced">Whether or not the element represents a value that changes per rendered instance of the vertex.</param> /// <param name="name">The semantic name (with the semantic index, if applicable) of the vertex data element.</param> /// <param name="slot">The buffer slot index.</param> public void Add(Formats format, bool isInstanced, string name, int slot) { if (slot > (NumSlots - 1)) { Sizes.AddRange(new int[slot - NumSlots + 1]); Sizes[slot] = 0; NumSlots++; } int idx = SplitSemanticIndex(ref name); Layout.Add(new InputElement ( name, idx, (Format)format, Sizes[slot], slot, isInstanced ? InputClassification.PerInstanceData : InputClassification.PerVertexData, isInstanced ? 1 : 0 )); Sizes[slot] += GetFormatSize(format); }
/* UTILITIES */ private int GetFormatSize(Formats format) { switch (format) { case Formats.Float2: return 8; case Formats.Float3: return 12; case Formats.Float4: return 16; default: throw new FormatException(); } }
// Show constant or formula or array formula public abstract String Show(int col, int row, Formats fo);