private INodeInfo CreateMemberNodeInfo(MemberInfo member, TypeSplitter os, string category, string filename) { var name = $"{os.BaseName}.{member.Name}"; var ninfo = FNodeInfoFactory.CreateNodeInfo(name, category, "", filename, true); ninfo.BeginUpdate(); ninfo.Credits = "microdee, MESO"; ninfo.Help = "Exposes a single member of a CLR Type"; ninfo.Tags = "property, field, member"; ninfo.Type = NodeType.Plugin; ninfo.Factory = this; if (os.Info != null) { ninfo.UpdateFromPluginInfo(os.Info); } AuxNodeInfo.UpdateGeneric(ninfo, new NodeInfoExtension(os, member.Name)); ninfo.Arguments = os.SplitterType.ToString(); ninfo.CommitUpdate(); return(ninfo); }
private INodeInfo ExtractNodeInfoFromAttributeData(CustomAttributeData attribute, string filename) { var name = attribute.ConstructorArguments[0].Value as string; //var namedArguments = new Dictionary<string, object>(); //foreach (var namedArgument in attribute.NamedArguments) //{ // namedArguments[namedArgument.MemberInfo.Name] = namedArgument.TypedValue.Value; //} var attributes = new Dictionary <string, string>(); var namedArguments = attribute.NamedArguments; foreach (var argument in namedArguments) { var argumentName = argument.MemberInfo.Name; var value = argument.TypedValue.Value.ToString(); attributes.Add(argumentName, value); } string version; attributes.TryGetValue("Version", out version); var nodeInfo = FNodeInfoFactory.CreateNodeInfo( name, "CV.Image", version, filename, true); string author; attributes.TryGetValue("Author", out author); nodeInfo.Author = author; string help; attributes.TryGetValue("Help", out help); nodeInfo.Help = help; string credits; attributes.TryGetValue("Credits", out credits); nodeInfo.Credits = credits; string tags; attributes.TryGetValue("Tags", out tags); nodeInfo.Tags = tags; //foreach (var entry in namedArguments) //{ // nodeInfo.GetType().InvokeMember((string)entry.Key, BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetProperty, Type.DefaultBinder, nodeInfo, new object[] { entry.Value }); //} return(nodeInfo); }
private INodeInfo LoadNodeInfoFromEffect(string filename, FXProject project) { var nodeInfo = FNodeInfoFactory.CreateNodeInfo( Path.GetFileNameWithoutExtension(filename), this.NodeCategory,this.NodeVersion, filename, true); nodeInfo.BeginUpdate(); nodeInfo.Type = NodeType.Dynamic; nodeInfo.Factory = this; nodeInfo.UserData = project; try { // Create an instance of StreamReader to read from a file. // The using statement also closes the StreamReader. using (StreamReader sr = new StreamReader(filename)) { string line; string author = @"//@author:"; string desc = @"//@help:"; string tags = @"//@tags:"; string credits = @"//@credits:"; // Parse lines from the file until the end of // the file is reached. while ((line = sr.ReadLine()) != null) { if (line.StartsWith(author)) nodeInfo.Author = line.Replace(author, "").Trim(); else if (line.StartsWith(desc)) nodeInfo.Help = line.Replace(desc, "").Trim(); else if (line.StartsWith(tags)) nodeInfo.Tags = line.Replace(tags, "").Trim(); else if (line.StartsWith(credits)) nodeInfo.Credits = line.Replace(credits, "").Trim(); } } } catch (Exception ex) { Logger.Log(LogType.Error, "Effect does not contain detailed info"); Logger.Log(ex); } try { nodeInfo.CommitUpdate(); } catch { } return nodeInfo; }
protected override IEnumerable <INodeInfo> LoadNodeInfos(string filePath) { var document = Host.Session.CurrentSolution.GetOrAddDocument(filePath, createNew: false, loadDependencies: false); foreach (var nodeDefinition in GetNodeDefinitions(document)) { var(name, category, version) = GetNodeInfoKeys(nodeDefinition); var nodeInfo = FNodeInfoFactory.CreateNodeInfo(name, category, version, filePath, beginUpdate: true); UpdateNodeInfo(nodeDefinition, nodeInfo); yield return(nodeInfo); } }
//straight copy from vvvv-sdk INodeInfo ExtractNodeInfoFromAttributeData(CustomAttributeData attribute, string filename) { var namedArguments = new Dictionary <string, object>(); foreach (var namedArgument in attribute.NamedArguments) { namedArguments[namedArgument.MemberInfo.Name] = namedArgument.TypedValue.Value; } var nodeInfo = FNodeInfoFactory.CreateNodeInfo( (string)namedArguments.ValueOrDefault("Name"), (string)namedArguments.ValueOrDefault("Category"), (string)namedArguments.ValueOrDefault("Version"), filename, true); namedArguments.Remove("Name"); namedArguments.Remove("Category"); namedArguments.Remove("Version"); if (namedArguments.ContainsKey("InitialWindowWidth") && namedArguments.ContainsKey("InitialWindowHeight")) { nodeInfo.InitialWindowSize = new Size((int)namedArguments["InitialWindowWidth"], (int)namedArguments["InitialWindowHeight"]); namedArguments.Remove("InitialWindowWidth"); namedArguments.Remove("InitialWindowHeight"); } if (namedArguments.ContainsKey("InitialBoxWidth") && namedArguments.ContainsKey("InitialBoxHeight")) { nodeInfo.InitialBoxSize = new Size((int)namedArguments["InitialBoxWidth"], (int)namedArguments["InitialBoxHeight"]); namedArguments.Remove("InitialBoxWidth"); namedArguments.Remove("InitialBoxHeight"); } else { nodeInfo.InitialBoxSize = new Size(200, 200); } if (namedArguments.ContainsKey("InitialComponentMode")) { nodeInfo.InitialComponentMode = (TComponentMode)namedArguments["InitialComponentMode"]; namedArguments.Remove("InitialComponentMode"); } foreach (var entry in namedArguments) { nodeInfo.GetType().InvokeMember((string)entry.Key, BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetProperty, Type.DefaultBinder, nodeInfo, new object[] { entry.Value }); } return(nodeInfo); }
protected void LoadNodeInfosFromFile(string filename, string sourcefilename, ref List <INodeInfo> nodeInfos, bool commitUpdates) { if (filename.EndsWith(this.ext)) { var nodeInfo = FNodeInfoFactory.CreateNodeInfo(Path.GetFileNameWithoutExtension(filename), this.NodeCategory, this.NodeVersion, filename, true); nodeInfo.Arguments = Assembly.GetExecutingAssembly().Location.ToLower(); nodeInfo.Factory = this; nodeInfo.Type = NodeType.Plugin; nodeInfo.UserData = this; nodeInfo.AutoEvaluate = false; nodeInfos.Add(nodeInfo); nodeInfo.Factory = this; nodeInfo.CommitUpdate(); } }
private INodeInfo ExtractNodeInfoFromType(Type type, string filename) { INodeInfo nodeInfo = null; foreach (PropertyInfo info in type.GetProperties(BindingFlags.Public | BindingFlags.Static)) { if (info.PropertyType == typeof(INodeInfo)) { var pluginNodeInfo = (INodeInfo)info.GetValue(null, null); nodeInfo = FNodeInfoFactory.CreateNodeInfo( pluginNodeInfo.Name, pluginNodeInfo.Category, pluginNodeInfo.Version, filename, true); nodeInfo.UpdateFromNodeInfo(pluginNodeInfo); break; } // The old interface else if (info.PropertyType == typeof(IPluginInfo)) { var pluginInfo = (IPluginInfo)info.GetValue(null, null); nodeInfo = FNodeInfoFactory.CreateNodeInfo( pluginInfo.Name, pluginInfo.Category, pluginInfo.Version, filename, true); nodeInfo.UpdateFromPluginInfo(pluginInfo); break; } } return(nodeInfo); }
//create a node info from a filename protected override IEnumerable <INodeInfo> LoadNodeInfos(string filename) { if (FDTD == "") { LoadDTD(); } //check filename structure string fn = Path.GetFileNameWithoutExtension(filename); INodeInfo nodeInfo; //check filename structure to see if this is a module or an ordinary patch if (Regex.IsMatch(fn, @"^.+\s\(.+\)$")) { //match the filename var match = Regex.Match(fn, @"(\S+) \((\S+)(?: ([^)]*))?\)"); //create node info and read matches nodeInfo = FNodeInfoFactory.CreateNodeInfo( match.Groups[1].Value, match.Groups[2].Value, match.Groups[3].Value, filename, true); nodeInfo.Type = NodeType.Module; nodeInfo.InitialComponentMode = TComponentMode.InAWindow; // Hidden; } else //patch { //create node info and read matches nodeInfo = FNodeInfoFactory.CreateNodeInfo(fn, "", "", filename, true); nodeInfo.Type = NodeType.Patch; nodeInfo.InitialComponentMode = TComponentMode.InAWindow; } nodeInfo.Factory = this; try { // Create an instance of StreamReader to read from a file. // The using statement also closes the StreamReader. using (StreamReader sr = new StreamReader(filename)) { //skip first line var s = sr.ReadLine(); var settings = new XmlReaderSettings(); settings.ProhibitDtd = false; using (StringReader stringReader = new StringReader(FDTD + sr.ReadToEnd())) { var xmlReader = XmlReader.Create(stringReader, settings); //xmlReader.Settings if (xmlReader.ReadToFollowing("INFO")) { nodeInfo.Author = xmlReader.GetAttribute("author"); nodeInfo.Help = xmlReader.GetAttribute("description"); nodeInfo.Tags = xmlReader.GetAttribute("tags"); } } } } catch (Exception e) { Logger.Log(LogType.Error, "Could not extract detailed module info from XML of " + nodeInfo.Systemname); Logger.Log(e); } finally { nodeInfo.CommitUpdate(); } yield return(nodeInfo); }
void SyncNodeInfos(Document oldDocument, Document newDocument) { var oldFilePath = oldDocument.FilePath; var filePath = newDocument.FilePath; var oldMap = GetNodeDefinitions(oldDocument).ToDictionary(d => d.Identity); foreach (var newDef in GetNodeDefinitions(newDocument)) { var oldDef = oldMap.ValueOrDefault(newDef.Identity); if (oldDef == newDef) { continue; } var(oldName, oldCategory, oldVersion) = GetNodeInfoKeys(oldDef ?? newDef); var(name, category, version) = GetNodeInfoKeys(newDef); var nodeInfo = FNodeInfoFactory.CreateNodeInfo(oldName, oldCategory, oldVersion, oldFilePath, beginUpdate: true); var oldNodeInfo = nodeInfo; // Check if document was moved or the definition renamed. if (name != oldName || category != oldCategory || version != oldVersion || filePath != oldFilePath) { if (FNodeInfoFactory.ContainsKey(name, category, version, filePath)) { // A node info already exists (document already existed). Switch to the existing one (otherwise we'd see double entries). nodeInfo = FNodeInfoFactory.CreateNodeInfo(name, category, version, filePath, beginUpdate: false); } else { // Update the existing node info. FNodeInfoFactory.UpdateNodeInfo(nodeInfo, name, category, version, filePath); } // Point all existing nodes to the updated node info foreach (var node in FHDEHost.RootNode.AsDepthFirstEnumerable()) { if (node.NodeInfo == oldNodeInfo) { var patchMessage = new PatchMessage(node.Parent.NodeInfo.Filename); var nodeMessage = patchMessage.AddNode(node.ID); nodeMessage.CreateMe = true; nodeMessage.SystemName = nodeInfo.Systemname; nodeMessage.Filename = nodeInfo.Filename; FHDEHost.SendXMLSnippet(patchMessage.Filename, patchMessage.ToString(), true); } } } if (nodeInfo == oldNodeInfo) { UpdateNodeInfo(newDef, nodeInfo); } else { FNodeInfoFactory.DestroyNodeInfo(oldNodeInfo); } } var newMap = GetNodeDefinitions(newDocument).ToDictionary(d => d.Identity); foreach (var oldDef in GetNodeDefinitions(oldDocument)) { if (newMap.ContainsKey(oldDef.Identity)) { continue; } var(name, category, version) = GetNodeInfoKeys(oldDef); var nodeInfo = FNodeInfoFactory.CreateNodeInfo(name, category, version, filePath, beginUpdate: false); if (nodeInfo.Factory == this) { FNodeInfoFactory.DestroyNodeInfo(nodeInfo); } } if (filePath != oldFilePath && File.Exists(oldFilePath)) { // The document was saved under a new name but old document still exists on disk. // Scan the old document again so we have double entries in the node browser as we'd have after a restart. foreach (var info in LoadNodeInfos(oldFilePath)) { Touch(info); } } }