public List <MacroRecording> GetAllLeaves(MacroRecording macro) { List <MacroRecording> leaves = new List <MacroRecording>(); if (macro != null) { IterateForLeaves(macro); } return(leaves); void IterateForLeaves(MacroRecording recording) { foreach (MacroRecording child in recording.Childs) { if (child.Childs.Count == 0 && !leaves.Contains(child)) { leaves.Add(child); } else { IterateForLeaves(child); } } } }
public static bool CheckIfDependentMacrosAreAvailable(MacroRecording macro1) { if (macro1 == null) { return(false); } if (macro1.RecordingType == RecordingTypes.SingleRecording) { return(true); } return(macro1.MergedMacroConfigurations.SelectMany <MergedMacroConfiguration, string>((Func <MergedMacroConfiguration, IEnumerable <string> >)(macro2 => (IEnumerable <string>)macro2.MacrosToRun)).Distinct <string>().Count <string>() == macro1.Childs.Count && macro1.Childs.Cast <MacroRecording>().All <MacroRecording>((Func <MacroRecording, bool>)(childMacro => MacroGraph.CheckIfDependentMacrosAreAvailable(childMacro)))); }
public static void LinkMacroChilds(MacroRecording macro) { if (macro?.MergedMacroConfigurations == null) { return; } foreach (string str in macro.MergedMacroConfigurations.SelectMany <MergedMacroConfiguration, string>((Func <MergedMacroConfiguration, IEnumerable <string> >)(macro_ => (IEnumerable <string>)macro_.MacrosToRun))) { string dependentMacro = str; MacroGraph.mInstance.AddParentChild((BiDirectionalVertex <MacroRecording>)macro, (BiDirectionalVertex <MacroRecording>)MacroGraph.mInstance.Vertices.Cast <MacroRecording>().Where <MacroRecording>((Func <MacroRecording, bool>)(macro_ => string.Equals(macro_.Name, dependentMacro, StringComparison.InvariantCultureIgnoreCase))).FirstOrDefault <MacroRecording>()); } }
private static void CreateMacroGraphInstance() { if (!Directory.Exists(RegistryStrings.MacroRecordingsFolderPath)) { return; } foreach (string file in Directory.GetFiles(RegistryStrings.MacroRecordingsFolderPath)) { string path = Path.Combine(RegistryStrings.MacroRecordingsFolderPath, file); if (File.Exists(path)) { try { MacroRecording macroRecording = JsonConvert.DeserializeObject <MacroRecording>(File.ReadAllText(path), Utils.GetSerializerSettings()); if (macroRecording != null) { if (!string.IsNullOrEmpty(macroRecording.Name)) { if (!string.IsNullOrEmpty(macroRecording.TimeCreated)) { if (macroRecording.Events == null) { ObservableCollection <MergedMacroConfiguration> macroConfigurations = macroRecording.MergedMacroConfigurations; // ISSUE: explicit non-virtual call if ((macroConfigurations != null ? (__nonvirtual(macroConfigurations.Count) > 0 ? 1 : 0) : 0) == 0) { continue; } } MacroGraph.mInstance.AddVertex((BiDirectionalVertex <MacroRecording>)macroRecording); } } } } catch { Logger.Error("Unable to deserialize userscript."); } } } MacroGraph.DrawMacroGraph(); }