public HelpCommandEmbeddable(CommandInfo subject, IEnumerable <CallInfo> permitted, string name, ICommandContext context) { Name = name; Command = subject; Permitted = permitted; Context = context; foreach (var call in Permitted) { Usages.Add(new RawString("`{0}{1} {2} {3} {4}` - {5}", Context.Prefix, Name, call.SubCall, string.Join(" ", call.GetParameters()), call.GetFlags(), (LocalisedString)call.Usage)); } if (Usages.Count == 0) { Usage = (LocalisedString)SINGLE_NOUSAGE; } else { Usage = new DynamicString(tr => string.Join("\n", Usages.Select(u => u.Localise(tr).RegexReplace(" +", " ")))); } Notes = (LocalisedString)Command.Note; NotesFooter = (LocalisedString)SINGLE_USAGE_FOOTER; Aliases = Command.Alias.Length == 0 ? "" : string.Join(", ", Command.Alias.ToList()); Group = (RawString)Command.Group ?? (LocalisedString)SINGLE_NOGROUP; Flags.AddRange(Permitted.SelectMany(c => c.Flags) .GroupBy(f => f.ShortKey) .Select(g => g.First())); Flag = LocalisedString.JoinEnumerable("\n", Flags); }
/// <summary> /// Creates a <see cref="ArchiveInitializer{TKey,TValue}"/> that will reside in memory. /// </summary> /// <param name="encodingMethod">the encoding method to use for the archive file.</param> /// <param name="flags">flags to include in the archive that is created.</param> /// <returns></returns> public void ConfigureInMemory(EncodingDefinition encodingMethod, params Guid[] flags) { TestForEditable(); Initialize(); IsMemoryArchive = true; Flags.AddRange(flags); EncodingMethod = encodingMethod; }
async void DeviceStatusVM_StatusAcquired(DeviceStatusInfo StatusInfo) { if (_statusUpdateDelay.TimeLeft > 0) { return; } else { await _statusUpdateDelay.WaitTimeLeftAsync(); // Restart } await Application.Current.Dispatcher.BeginInvoke(new Action(() => { using (Flags.EventSuppressingMode) { Flags.Clear(); Flags.AddRange(StatusInfo.CurrentStatuses); } using (Info.EventSuppressingMode) { Info.Clear(); if (StatusInfo.SerialNumber.HasValue) { Info.Add(new KeyValuePair <string, string>("Серийный номер", StatusInfo.SerialNumber.Value.ToStringInvariant())); } var flags = Convert .ToString(StatusInfo.Status.Bits, 2) .PadLeft(StatusInfo.Status.NumOfBits, '0') .Reverse() .GroupBy(4) .Select(g => g.Aggregate()) .Aggregate(" ") .Reverse() .Aggregate(); #warning hardcoded statuses if (StatusInfo.Status.NumOfBits == 16) { Info.Add(new KeyValuePair <string, string>("Статус", flags)); } else if (StatusInfo.Status.NumOfBits == 32) { Info.Add(new KeyValuePair <string, string>( $"Статус 31÷15", flags.Take(flags.Length / 2).Aggregate())); Info.Add(new KeyValuePair <string, string>( "Статус 15÷00", flags.TakeFromEnd(flags.Length / 2).Aggregate())); } else { throw new NotSupportedException(); } } }), System.Windows.Threading.DispatcherPriority.Normal); }
/// <summary> /// Creates a <see cref="ArchiveInitializer{TKey,TValue}"/> that will reside on the disk. /// </summary> /// <param name="paths">the paths to place the files.</param> /// <param name="desiredRemainingSpace">The desired free space to leave on the disk before moving to another disk.</param> /// <param name="directoryMethod">the method for storing files in a directory.</param> /// <param name="encodingMethod">the encoding method to use for the archive file.</param> /// <param name="prefix">the prefix to affix to the files created.</param> /// <param name="pendingExtension">the extension file name</param> /// <param name="finalExtension">the final extension to specify</param> /// <param name="flags">flags to include in the archive that is created.</param> /// <returns></returns> public void ConfigureOnDisk(IEnumerable <string> paths, long desiredRemainingSpace, ArchiveDirectoryMethod directoryMethod, EncodingDefinition encodingMethod, string prefix, string pendingExtension, string finalExtension, params Guid[] flags) { TestForEditable(); Initialize(); DirectoryMethod = directoryMethod; PendingExtension = pendingExtension; FinalExtension = finalExtension; Flags.AddRange(flags); Prefix = prefix; WritePath.AddRange(paths); DesiredRemainingSpace = desiredRemainingSpace; EncodingMethod = encodingMethod; }