/// <summary> /// Initializes a new instance of the <see cref="CsvParser"/> class. /// </summary> /// <param name="reader">The reader.</param> /// <param name="configuration">The configuration.</param> public CsvParser(TextReader reader, CsvConfiguration configuration) { this.reader = reader; Configuration = configuration; Context = new CsvContext(this); allowComments = configuration.AllowComments; badDataFound = configuration.BadDataFound; bufferSize = configuration.BufferSize; cacheFields = configuration.CacheFields; comment = configuration.Comment; countBytes = configuration.CountBytes; delimiter = configuration.Delimiter; delimiterFirstChar = configuration.Delimiter[0]; encoding = configuration.Encoding; escape = configuration.Escape; ignoreBlankLines = configuration.IgnoreBlankLines; isNewLineSet = configuration.IsNewLineSet; leaveOpen = configuration.LeaveOpen; lineBreakInQuotedFieldIsBadData = configuration.LineBreakInQuotedFieldIsBadData; newLine = configuration.NewLine; newLineFirstChar = configuration.NewLine[0]; mode = configuration.Mode; processFieldBufferSize = 1024; quote = configuration.Quote; whiteSpaceChars = configuration.WhiteSpaceChars; trimOptions = configuration.TrimOptions; buffer = ArrayPool <char> .Shared.Rent(bufferSize); processFieldBuffer = ArrayPool <char> .Shared.Rent(processFieldBufferSize); fields = new Field[128]; }
private void trimCloneButton_Click(object sender, EventArgs e) { _options = TrimOptions.Clone; if (removeVertices.Checked) { _options |= TrimOptions.Vertex; } if (removeTriangles.Checked) { _options |= TrimOptions.Triangle; } if (removeBones.Checked) { _options |= TrimOptions.Bone; } if (removeRigidbodies.Checked) { _options |= TrimOptions.Rigidbody; } if (removeJoints.Checked) { _options |= TrimOptions.Joint; } Close(); }
/// <summary> /// Initializes a new instance of the <see cref="CsvWriter"/> class. /// </summary> /// <param name="writer">The writer.</param> /// <param name="configuration">The configuration.</param> public CsvWriter(TextWriter writer, CsvConfiguration configuration) { this.writer = writer; Configuration = configuration; context = new CsvContext(this); typeConverterCache = context.TypeConverterCache; recordManager = new Lazy <RecordManager>(() => ObjectResolver.Current.Resolve <RecordManager>(this)); comment = configuration.Comment; bufferSize = configuration.BufferSize; delimiter = configuration.Delimiter; cultureInfo = configuration.CultureInfo; doubleQuoteString = configuration.DoubleQuoteString; dynamicPropertySort = configuration.DynamicPropertySort; hasHeaderRecord = configuration.HasHeaderRecord; includePrivateMembers = configuration.IncludePrivateMembers; injectionCharacters = configuration.InjectionCharacters; injectionEscapeCharacter = configuration.InjectionEscapeCharacter; leaveOpen = configuration.LeaveOpen; newLine = configuration.NewLine; quote = configuration.Quote; quoteString = configuration.QuoteString; sanitizeForInjection = configuration.SanitizeForInjection; shouldQuote = configuration.ShouldQuote; trimOptions = configuration.TrimOptions; buffer = new char[bufferSize]; }
/// <summary> /// Initializes a new instance of the <see cref="CsvWriter"/> class. /// </summary> /// <param name="writer">The writer.</param> /// <param name="configuration">The configuration.</param> public CsvWriter(TextWriter writer, CsvConfiguration configuration) { configuration.Validate(); this.writer = writer; Configuration = configuration; context = new CsvContext(this); typeConverterCache = context.TypeConverterCache; recordManager = new Lazy <RecordManager>(() => ObjectResolver.Current.Resolve <RecordManager>(this)); comment = configuration.Comment; bufferSize = configuration.BufferSize; delimiter = configuration.Delimiter; cultureInfo = configuration.CultureInfo; dynamicPropertySort = configuration.DynamicPropertySort; escapeDelimiterString = new string(configuration.Delimiter.SelectMany(c => new[] { configuration.Escape, c }).ToArray()); escapeNewlineString = new string(configuration.NewLine.SelectMany(c => new[] { configuration.Escape, c }).ToArray()); escapeQuoteString = new string(new[] { configuration.Escape, configuration.Quote }); hasHeaderRecord = configuration.HasHeaderRecord; includePrivateMembers = configuration.IncludePrivateMembers; injectionCharacters = configuration.InjectionCharacters; injectionEscapeCharacter = configuration.InjectionEscapeCharacter; leaveOpen = configuration.LeaveOpen; mode = configuration.Mode; newLine = configuration.NewLine; quote = configuration.Quote; quoteString = configuration.Quote.ToString(); sanitizeForInjection = configuration.SanitizeForInjection; shouldQuote = configuration.ShouldQuote; trimOptions = configuration.TrimOptions; buffer = new char[bufferSize]; }
/// <summary> /// Checks the value of the supplied string <paramref name="value"/> and throws an /// <see cref="System.ArgumentException"/> if it is <see langword="null"/> or empty. /// </summary> /// <param name="value">The string value to check.</param> /// <param name="variableName">The argument name.</param> /// <param name="options">The value trimming options.</param> /// <exception cref="System.ArgumentException"> /// If the supplied <paramref name="value"/> is <see langword="null"/> or empty. /// </exception> public static void AgainstNullOrEmpty(String value, String variableName, TrimOptions options = TrimOptions.DoTrim) { var message = String.Format( CultureInfo.InvariantCulture, "'{0}' cannot be null or resolve to an empty string", variableName); AgainstNullOrEmpty(value, variableName, message, options); }
/// <summary> /// Checks the value of the supplied string <paramref name="value"/> and throws an /// <see cref="System.ArgumentException"/> if it is <see langword="null"/> or empty. /// </summary> /// <param name="value">The string value to check.</param> /// <param name="variableName">The argument name.</param> /// <param name="options">The value trimming options.</param> /// <exception cref="System.ArgumentException"> /// If the supplied <paramref name="value"/> is <see langword="null"/> or empty. /// </exception> public static void NotNullOrEmpty(string value, string variableName, TrimOptions options) { string message = string.Format( CultureInfo.InvariantCulture, "'{0}' cannot be null or resolve to an empty string : '{1}'.", variableName, value); NotNullOrEmpty(value, variableName, message, options); }
protected static ISignValue CreateSignValue(byte[] signature, Action <TrimOptions> optionsAct = null) { TrimOptions options = new TrimOptions(); optionsAct?.Invoke(options); return(new SignValue(signature, options)); }
public CsvImportOptions(string delimiter, char quote, TrimOptions trim, bool allowComments, char comment) { Delimiter = delimiter; Quote = quote; TrimOptions = trim; Comment = comment; AllowComments = allowComments; }
public static void AgainstNullOrEmpty(this string value, [InvokerParameterName] string variableName, TrimOptions options) { var message = string.Format( CultureInfo.InvariantCulture, "'{0}' cannot be null or resolve to an empty string : '{1}'.", variableName, value); AgainstNullOrEmpty(value, variableName, message, options); }
/// <summary> /// Checks the actual value of the supplied <paramref name="selector"/> and throws an /// <see cref="System.ArgumentNullException"/> if it is <see langword="null"/> or empty. /// </summary> /// <param name="selector">The expression which should return argument value.</param> /// <param name="options">The value trimming options.</param> /// <exception cref="System.ArgumentNullException"> /// If the supplied value of <paramref name="selector"/> is <see langword="null"/> or empty string. /// </exception> public static void AgainstNullOrEmpty(Expression <Func <string> > selector, TrimOptions options = TrimOptions.DoTrim) { var memberSelector = (MemberExpression)selector.Body; var constantSelector = (ConstantExpression)memberSelector.Expression; var value = ((FieldInfo)memberSelector.Member).GetValue(constantSelector.Value); var name = ((MemberExpression)selector.Body).Member.Name; var message = string.Format(CultureInfo.InvariantCulture, "'{0}' cannot be null or resolve to an empty string", name); AgainstNullOrEmpty(value as string, name, message, options); }
public static void AgainstNullOrEmpty(this string value, [InvokerParameterName] string variableName, string message, TrimOptions options) { if (value != null && options == TrimOptions.DoTrim) { value = value.Trim(); } if (string.IsNullOrEmpty(value)) { throw new ArgumentException(message, variableName); } }
// Pass the options, then call ShowDialog public TrimOptions Display(TrimOptions options) { _options = options; keepVertices.Checked = !(removeVertices.Checked = _options.HasFlag(TrimOptions.Vertex)); keepTriangles.Checked = !(removeTriangles.Checked = _options.HasFlag(TrimOptions.Triangle)); keepBones.Checked = !(removeBones.Checked = _options.HasFlag(TrimOptions.Bone)); keepRigidbodies.Checked = !(removeRigidbodies.Checked = _options.HasFlag(TrimOptions.Rigidbody)); keepJoints.Checked = !(removeJoints.Checked = _options.HasFlag(TrimOptions.Joint)); ShowDialog(); // This thread should be blocked at this point. // Control returns here when the form is closed. return(_options); }
public async Task <IActionResult> TrimInitialVideo(string id, [FromBody] TrimOptions options) { try { var(complete, filePaths) = await _videoManager.TrimVideoAsync(id, options.Video, options.Start, options.End); if (complete) { return(Ok(filePaths)); } } catch (Exception e) { _logger.LogError(e.Message); } return(BadRequest("Failed To Trim Video")); }
public void Trim() { Sox sox = new Sox { SoxDirectory = Path.Combine(TestHelper.GetSolutionDirectory(), @"libs\sox-14.3.2\") }; TrimOptions options = new TrimOptions { InputFileInfo = new FileInfo { FileType = FileType.RawUnsignedInteger8, Channels = 1, SampleSizeInBits = 8, SamplingRate = 8000, EncodingType = EncodingType.UnsignedInteger }, OutputFileInfo = new FileInfo { FileType = FileType.RawUnsignedInteger8, Channels = 1, SampleSizeInBits = 8, SamplingRate = 8000, EncodingType = EncodingType.UnsignedInteger }, StartTime = new SoxTimeSamples { Value = 0 }, Length = new SoxTimeSamples { Value = 1000 }, }; int preRunTempDirFileCount = Directory.GetFiles(sox.TempDir).Length; using (Stream input = GetType().Assembly.GetManifestResourceStream("SoxLib.Test.Unit.doh-wav.u8")) using (Stream expected = GetType().Assembly.GetManifestResourceStream("SoxLib.Test.Unit.doh-wav-trim.u8")) using (Stream output = sox.Trim(input, options)) { StreamTestHelper.AssertAreEqual(expected, output, 2); } Assert.AreEqual(preRunTempDirFileCount, Directory.GetFiles(sox.TempDir).Length); }
public MdBlockTransformer(MdConfig config) { _hashSizeInBits = config.HashSizeInBits; _mdType = config.Type; _worker = config.Type switch { MdTypes.Md2 => _worker = new Md2Worker(), MdTypes.Md4 => _worker = new Md4Worker(), MdTypes.Md5 => _worker = new Md5Worker(_mdType), MdTypes.Md5Bit16 => _worker = new Md5Worker(_mdType), MdTypes.Md5Bit32 => _worker = new Md5Worker(_mdType), MdTypes.Md5Bit64 => _worker = new Md5Worker(_mdType), MdTypes.Md6 => _worker = new Md6Worker(config), MdTypes.Md6Bit128 => _worker = new Md6Worker(config), MdTypes.Md6Bit256 => _worker = new Md6Worker(config), MdTypes.Md6Bit512 => _worker = new Md6Worker(config), MdTypes.Md6Custom => _worker = new Md6Worker(config), _ => null }; _trimOptions = config.GetTrimOptions(); }
/// <summary> /// Initializes a new instance of the <see cref="CsvParser"/> class. /// </summary> /// <param name="reader">The reader.</param> /// <param name="configuration">The configuration.</param> public CsvParser(TextReader reader, IParserConfiguration configuration) { configuration.Validate(); this.reader = reader; this.configuration = configuration; Context = new CsvContext(this); allowComments = configuration.AllowComments; badDataFound = configuration.BadDataFound; bufferSize = configuration.BufferSize; cacheFields = configuration.CacheFields; comment = configuration.Comment; countBytes = configuration.CountBytes; delimiter = configuration.Delimiter; delimiterFirstChar = configuration.Delimiter[0]; delimiterValues = configuration.DetectDelimiterValues; detectDelimiter = configuration.DetectDelimiter; encoding = configuration.Encoding; escape = configuration.Escape; ignoreBlankLines = configuration.IgnoreBlankLines; isNewLineSet = configuration.IsNewLineSet; leaveOpen = configuration.LeaveOpen; lineBreakInQuotedFieldIsBadData = configuration.LineBreakInQuotedFieldIsBadData; newLine = configuration.NewLine; newLineFirstChar = configuration.NewLine[0]; mode = configuration.Mode; processFieldBufferSize = configuration.ProcessFieldBufferSize; quote = configuration.Quote; whiteSpaceChars = configuration.WhiteSpaceChars; trimOptions = configuration.TrimOptions; buffer = new char[bufferSize]; processFieldBuffer = new char[processFieldBufferSize]; fields = new Field[128]; processedFields = new string[128]; }
private void cancelButton_Click(object sender, EventArgs e) { _options = TrimOptions.Cancel; Close(); }
/// <summary> /// The fields trimming options. /// </summary> /// <param name="trimOptions">The TrimOptions.</param> public TrimOptionsAttribute(TrimOptions trimOptions) { TrimOptions = trimOptions; }
private void trimButton_Click(object sender, EventArgs e) { if (_trimForm == null) { _trimForm = new TrimForm(); } TrimOptions options = TrimOptions.None; if (!selectiveVertexCheck.Checked) { options |= TrimOptions.Vertex; } if (!selectiveTriangleCheck.Checked) { options |= TrimOptions.Triangle; } if (!selectiveBoneCheck.Checked) { options |= TrimOptions.Bone; } if (!selectiveRigidbodyCheck.Checked) { options |= TrimOptions.Rigidbody; } if (!selectiveJointCheck.Checked) { options |= TrimOptions.Joint; } TrimOptions result = _trimForm.Display(options); if (result.HasFlag(TrimOptions.Cancel)) { return; } foreach (ListViewItem item in storedList.SelectedItems) { Selection sel; if (result.HasFlag(TrimOptions.Clone)) { sel = (Selection)((Selection)item.Tag).Clone(); sel.Name += " trim"; } else { sel = (Selection)item.Tag; } if (result.HasFlag(TrimOptions.Vertex)) { sel.Vertex = new int[0]; item.SubItems[1].Text = "0"; } if (result.HasFlag(TrimOptions.Triangle)) { sel.Triangle = new int[0]; item.SubItems[2].Text = "0"; } if (result.HasFlag(TrimOptions.Bone)) { sel.Bone = new int[0]; item.SubItems[3].Text = "0"; } if (result.HasFlag(TrimOptions.Rigidbody)) { sel.Rigidbody = new int[0]; item.SubItems[4].Text = "0"; } if (result.HasFlag(TrimOptions.Joint)) { sel.Joint = new int[0]; item.SubItems[5].Text = "0"; } if (result.HasFlag(TrimOptions.Clone)) { AddSelection(sel); } } }
private void TrimForm_FormClosing(object sender, FormClosingEventArgs e) { _options = TrimOptions.Cancel; }
/// <summary> /// Checks the value of the supplied string <paramref name="value"/> and throws an /// <see cref="System.ArgumentException"/> if it is <see langword="null"/> or empty. /// </summary> /// <param name="value">The string value to check.</param> /// <param name="variableName">The variable name.</param> /// <param name="message">The message to include in exception description</param> /// <param name="options">The value trimming options.</param> /// <exception cref="System.ArgumentException"> /// If the supplied <paramref name="value"/> is <see langword="null"/> or empty. /// </exception> public static void NotNullOrEmpty(string value, string variableName, string message, TrimOptions options) { if (value != null && options == TrimOptions.DoTrim) { value = value.Trim(); } if (string.IsNullOrEmpty(value)) { throw new ArgumentException(message, variableName); } }