/// <inheritdoc/> public override void DeleteFiles(DeleteFilesEventArgs args) { if (args == null) { return; } // skip not default modes if (MemberMode != 0) { args.Result = JobResult.Ignore; return; } // ask if (args.UI && 0 != (long)Far.Api.GetSetting(FarSetting.Confirmations, "Delete")) { if (Far.Api.Message("Delete selected members", Res.Delete, MessageOptions.None, new string[] { Res.Delete, Res.Cancel }) != 0) { args.Result = JobResult.Ignore; return; } } try { int count1 = Value.Properties.Count(); foreach (FarFile file in args.Files) { PSPropertyInfo pi = file.Data as PSPropertyInfo; if (pi == null) { continue; } Value.Properties.Remove(pi.Name); } int count2 = Value.Properties.Count(); if (count1 - args.Files.Count != count2) { args.Result = JobResult.Incomplete; } } finally { // update always, some members can be deleted, don't leave them MemberPanel.WhenMemberChanged(Value); //????? will it be 2 times for THIS panel? } }
internal static void SetPropertyFromTextUI(object target, PSPropertyInfo pi, string text) { bool isPSObject; object value; string type; if (pi.Value is PSObject && (pi.Value as PSObject).BaseObject != null) { isPSObject = true; type = (pi.Value as PSObject).BaseObject.GetType().FullName; } else { isPSObject = false; type = pi.TypeNameOfValue; } if (type == "System.Collections.ArrayList" || type.EndsWith("]", StringComparison.Ordinal)) { ArrayList lines = new ArrayList(); foreach (var line in FarNet.Works.Kit.SplitLines(text)) { lines.Add(line); } value = lines; } else { value = text; } if (isPSObject) { value = PSObject.AsPSObject(value); } try { pi.Value = value; MemberPanel.WhenMemberChanged(target); } catch (RuntimeException ex) { Far.Api.Message(ex.Message, "Setting property"); } }