Example #1
0
        public void TestLoadNoNamespaceClass()
        {
            LibraryServices libraryServices = LibraryServices.GetInstance();
            bool            libraryLoaded   = false;

            libraryServices.LibraryLoaded     += (sender, e) => libraryLoaded = true;
            libraryServices.LibraryLoadFailed += (sender, e) => Assert.Fail("Failed to load library: " + e.LibraryPath);

            string libraryPath = "FFITarget.dll";

            libraryServices.ImportLibrary(libraryPath, ViewModel.Model.Logger);
            Assert.IsTrue(libraryLoaded);

            // Get function groups for global classes with no namespace
            var functions = libraryServices.GetFunctionGroups(libraryPath)
                            .Where(x => x.Functions
                                   .Where(y => string.IsNullOrEmpty(y.Namespace)).Any());

            if (functions.Any())
            {
                var ctorfg = functions.Where(x => x.Functions.Where(y => y.Type == FunctionType.Constructor).Any());
                Assert.IsTrue(ctorfg.Any());
                foreach (var fg in ctorfg)
                {
                    foreach (var ctor in fg.Functions)
                    {
                        Assert.IsTrue(ctor.ClassName == ctor.UnqualifedClassName);
                    }
                }
            }
        }
Example #2
0
        private void LoadAssembliesIntoDynamo(DynamoLoader loader, ILogger logger)
        {
            var assemblies = LoadAssembliesInBinDirectory();

            // filter the assemblies
            var zeroTouchAssemblies = new List <Assembly>();
            var nodeModelAssemblies = new List <Assembly>();

            foreach (var assem in assemblies)
            {
                if (loader.ContainsNodeModelSubType(assem))
                {
                    nodeModelAssemblies.Add(assem);
                }
                else
                {
                    zeroTouchAssemblies.Add(assem);
                }
            }

            // load the zero touch assemblies
            foreach (var zeroTouchAssem in zeroTouchAssemblies)
            {
                LibraryServices.GetInstance().ImportLibrary(zeroTouchAssem.Location, logger);
            }

            // load the node model assemblies
            foreach (var nodeModelAssem in nodeModelAssemblies)
            {
                var nodes = loader.LoadNodesFromAssembly(nodeModelAssem);
                nodes.ForEach(x => LoadedTypes.Add(x));
            }
        }
Example #3
0
        public void TestPreLoadedLibrary()
        {
            LibraryServices libraryServices = LibraryServices.GetInstance();
            var             loadedLibs      = libraryServices.Libraries;

            Assert.IsTrue(loadedLibs.Any());
        }
Example #4
0
        public void TestPreLoadedLibrary()
        {
            LibraryServices libraryServices = LibraryServices.GetInstance();
            var             loadedLibs      = libraryServices.Libraries;
            List <string>   libs            = libraryServices.Libraries.Select(
                lib => { return(Path.GetFileName(lib)); }).ToList();

            foreach (var lib in loadedLibs)
            {
                Assert.IsTrue(libs.Any(x => string.Compare(x, lib, true) == 0));
            }
        }
Example #5
0
        public void TestLoadDSFile()
        {
            LibraryServices libraryServices = LibraryServices.GetInstance();
            bool            libraryLoaded   = false;

            libraryServices.LibraryLoaded     += (sender, e) => libraryLoaded = true;
            libraryServices.LibraryLoadFailed += (sender, e) => Assert.Fail("Failed to load library: " + e.LibraryPath);

            string libraryPath = Path.Combine(GetTestDirectory(), @"core\library\Dummy.ds");

            libraryServices.ImportLibrary(libraryPath);
            Assert.IsTrue(libraryLoaded);

            var functions = libraryServices.GetFunctionGroups(libraryPath);

            Assert.IsNotNull(functions);
            Assert.IsTrue(functions.Any());
        }
Example #6
0
        public void TestLibraryAcrossSessions()
        {
            LibraryServices libraryServices = LibraryServices.GetInstance();

            bool libraryLoaded = false;

            libraryServices.LibraryLoaded += (sender, e) => libraryLoaded = true;

            // library should be able to load
            string libraryPath = Path.Combine(GetTestDirectory(), @"core\library\Test.ds");

            libraryServices.ImportLibrary(libraryPath);
            Assert.IsTrue(libraryLoaded);

            // open dyn file which uses node in that library
            RunModel(@"core\library\t1.dyn");
            AssertValue("a", 1025);

            // open the other dyn file which uses node in that library, and
            // library should still be available
            RunModel(@"core\library\t2.dyn");
            AssertValue("a", 43);
        }
Example #7
0
        public void TestLibraryAcrossSessions()
        {
            LibraryServices libraryServices = LibraryServices.GetInstance();

            bool libraryLoaded = false;

            libraryServices.LibraryLoaded += (sender, e) => libraryLoaded = true;

            // library should be able to load
            string libraryPath = Path.Combine(GetTestDirectory(), @"core\library\Test.ds");

            libraryServices.ImportLibrary(libraryPath, ViewModel.Model.Logger);
            Assert.IsTrue(libraryLoaded);

            // open dyn file which uses node in that library
            RunModel(@"core\library\t1.dyn");
            AssertPreviewValue("2cacc70a-23a8-4fe0-92d1-9b72ae3db10b", 1025);

            // open the other dyn file which uses node in that library, and
            // library should still be available
            RunModel(@"core\library\t2.dyn");
            AssertPreviewValue("880ea294-7a01-4a78-8602-54d73f4b681b", 43);
        }
Example #8
0
 public override void Init()
 {
     base.Init();
     libraryServices = LibraryServices.GetInstance();
     RegisterEvents();
 }