Dynamo.PackageManager.Package.IsNodeLibrary C# (CSharp) Method

IsNodeLibrary() static private method

Determine if an assembly is in the "node_libraries" list for the package. This algorithm accepts assemblies that don't have the same version, but the same name. This is important when a package author has updated a dll in their package. This algorithm assumes all of the entries in nodeLibraryFullNames are properly formatted as returned by the Assembly.FullName property. If they are not, it ignores the entry.
static private IsNodeLibrary ( IEnumerable nodeLibraryFullNames, AssemblyName name, IList &messages ) : bool
nodeLibraryFullNames IEnumerable
name System.Reflection.AssemblyName
messages IList
return bool
        internal static bool IsNodeLibrary(IEnumerable<string> nodeLibraryFullNames, AssemblyName name, ref IList<ILogMessage> messages)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            if (nodeLibraryFullNames == null)
            {
                return true;
            }

            foreach (var n in nodeLibraryFullNames)
            {
                try
                {
                    // The AssemblyName constructor throws an exception for an improperly formatted string
                    if (new AssemblyName(n).Name == name.Name)
                    {
                        return true;
                    }
                }
                catch (Exception _)
                {
                    if (messages != null)
                    {
                        messages.Add(LogMessage.Warning(Resources.IncorrectlyFormattedNodeLibraryWarning, WarningLevel.Mild));
                        messages.Add(LogMessage.Warning(String.Format(Resources.IncorrectlyFormattedNodeLibraryDisplay + " {0}", n), WarningLevel.Mild));
                    }
                }
            }
            return false;
        }

Usage Example

Exemplo n.º 1
0
        public void IsNodeLibrary_IsFalseAndHasMessagesForBadlyFormatted()
        {
            IList <ILogMessage> ws = new List <ILogMessage>();

            Assert.False(Package.IsNodeLibrary(new List <string>
            {
                "\\ x x x x x x"
            }, assemName, ref ws));
            Assert.AreEqual(2, ws.Count());
        }
All Usage Examples Of Dynamo.PackageManager.Package::IsNodeLibrary