public override void SetValue(int nRow, int nCol, int value) { ICommand command = new SetValueCommand( inner, nRow, nCol, value); invoker.Execute(command); }
protected void Edit_Button_OnClick(object sender, RoutedEventArgs e) { if (!Value) { SetValueCommand.Execute(Main); } }
/// <summary> /// Sets missing properties on the retrieval method if they can be inferred. /// </summary> /// <param name="retrievalMethod">The retrieval method.</param> /// <param name="executor">Used to modify properties in an undoable fashion.</param> /// <param name="localPath">An optional local file path where the <paramref name="retrievalMethod"/> has already been downloaded.</param> public static void SetMissing(this DownloadRetrievalMethod retrievalMethod, ICommandExecutor executor, string?localPath = null) { #region Sanity checks if (retrievalMethod == null) { throw new ArgumentNullException(nameof(retrievalMethod)); } if (executor == null) { throw new ArgumentNullException(nameof(executor)); } #endregion switch (retrievalMethod) { case Archive archive when string.IsNullOrEmpty(archive.MimeType): executor.Execute(SetValueCommand.For(() => archive.MimeType, Archive.GuessMimeType(localPath ?? archive.Href.OriginalString))); break; case SingleFile file when string.IsNullOrEmpty(file.Destination): executor.Execute(SetValueCommand.For(() => file.Destination, Path.GetFileName(localPath ?? file.Href.GetLocalFileName()))); break; } }
protected override void EditButton_OnClick(object sender, RoutedEventArgs e) { if (Value) { SetValueCommand.Execute(Alternate); } }
public bool Set <T>(string key, T value) { ValidateKeyVal(key); ValidateInputValueNotDefault(value); var command = new SetValueCommand <T>(key, value); return(command.Execute()); }
/// <summary> /// Applies a retrieval method to the implementation. Sets missing properties in the process. /// </summary> /// <param name="builder">The builder.</param> /// <param name="retrievalMethod">The retrieval method.</param> /// <param name="executor">Used to modify properties in an undoable fashion.</param> /// <param name="handler">A callback object used when the the user needs to be informed about IO tasks.</param> /// <param name="localPath">An optional local file path where the <paramref name="retrievalMethod"/> has already been downloaded.</param> /// <exception cref="OperationCanceledException">The user canceled the task.</exception> /// <exception cref="WebException">A file could not be downloaded from the internet.</exception> /// <exception cref="IOException">There is a problem accessing <paramref name="localPath"/>.</exception> /// <exception cref="UnauthorizedAccessException">Read access to <paramref name="localPath"/> is not permitted.</exception> public static void Add(this IBuilder builder, DownloadRetrievalMethod retrievalMethod, ICommandExecutor executor, ITaskHandler handler, string?localPath = null) { #region Sanity checks if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (retrievalMethod == null) { throw new ArgumentNullException(nameof(retrievalMethod)); } if (executor == null) { throw new ArgumentNullException(nameof(executor)); } if (handler == null) { throw new ArgumentNullException(nameof(handler)); } #endregion void Process(Stream stream) { retrievalMethod.SetMissing(executor, localPath); builder.Add(retrievalMethod, stream, handler); long size = stream.Length; if (retrievalMethod is Archive archive) { size -= archive.StartOffset; } if (retrievalMethod.Size != size) { executor.Execute(SetValueCommand.For(() => retrievalMethod.Size, newValue: size)); } } if (localPath == null) { try { handler.RunTask(new DownloadFile(ModelUtils.GetAbsoluteHref(retrievalMethod.Href, executor.Path), Process)); } #region Error handling catch (UriFormatException ex) { // Wrap exception since only certain exception types are allowed throw new WebException(ex.Message, ex); } #endregion } else { handler.RunTask(new ReadFile(localPath, Process)); } }
static Processor() { commands = new Dictionary <string, ICommand>(); commands["set"] = new SetValueCommand(); commands["get"] = new GetValueCommand(); commands["sadd"] = new SetAddMemberCommand(); commands["srem"] = new SetRemoveMemberCommand(); commands["sismember"] = new SetIsMemberCommand(); }
public void CreateAndExecuteSetValueCommand() { IExpression expression = new ConstantExpression(1); SetValueCommand cmd = new SetValueCommand("one", expression); Assert.AreEqual(expression, cmd.Expression); Assert.AreEqual("one", cmd.Name); Context context = new Context(); cmd.Execute(context); Assert.AreEqual(1, context.GetValue("one")); }
public void ParseChannelSendUsingOperator() { ICommand command = ParseCommand("a <- 10;"); Assert.IsNotNull(command); Assert.IsInstanceOfType(command, typeof(SetValueCommand)); SetValueCommand setvalcmd = (SetValueCommand)command; Assert.IsInstanceOfType(setvalcmd.Expression, typeof(ConstantExpression)); Assert.IsInstanceOfType(setvalcmd.LeftValue, typeof(VariableExpression)); }
private bool SetValueOnAutomationIdentification(AutomationIdentifier controlIdentifier, string textValue, int ordinal, AutomationIdentifier parentIdentifier) { var command = new SetValueCommand { AutomationIdentifier = controlIdentifier, TextValue = textValue, Ordinal = ordinal, ParentIdentifier = parentIdentifier }; var result = SyncExecuteCommand(command); var successResult = result as SuccessResult; return(successResult != null); }
private static void ConvertSha256ToSha256New(Implementation implementation, ICommandExecutor executor) { if (string.IsNullOrEmpty(implementation.ManifestDigest.Sha256) || !string.IsNullOrEmpty(implementation.ManifestDigest.Sha256New)) { return; } var digest = new ManifestDigest( implementation.ManifestDigest.Sha1, implementation.ManifestDigest.Sha1New, implementation.ManifestDigest.Sha256, implementation.ManifestDigest.Sha256.Base16Decode().Base32Encode()); executor.Execute(SetValueCommand.For(() => implementation.ManifestDigest, newValue: digest)); }
private static void GenerateMissingArchive(Implementation implementation, ITaskHandler handler, ICommandExecutor executor) { var archive = implementation.RetrievalMethods.OfType <Archive>().FirstOrDefault(); if (archive == null || !string.IsNullOrEmpty(archive.Destination) || !string.IsNullOrEmpty(archive.Extract)) { return; } if (string.IsNullOrEmpty(implementation.LocalPath)) { return; } string directoryPath = ModelUtils.GetAbsolutePath(implementation.LocalPath, executor.Path); if (archive.Href == null) { return; } var archiveHref = ModelUtils.GetAbsoluteHref(archive.Href, executor.Path); if (!archiveHref.IsFile) { return; } implementation.UpdateDigest(directoryPath, handler, executor); using (var generator = ArchiveGenerator.Create( directoryPath, archiveHref.LocalPath, archive.MimeType ?? Archive.GuessMimeType(archiveHref.LocalPath))) handler.RunTask(generator); executor.Execute(SetValueCommand.For(() => archive.Size, newValue: new FileInfo(archiveHref.LocalPath).Length)); executor.Execute(SetValueCommand.For <string?>(() => implementation.LocalPath, newValue: null)); }
public void Handle(SetValueCommand command) { this.Value = command.Value; }
public void Set(string name, object data) { var setCommand = new SetValueCommand(name, data, _variables); Commands.Add(setCommand.SetValue); }