Exemplo n.º 1
0
        public EngineController(DynamoModel dynamoModel, string geometryFactoryFileName)
        {
            this.dynamoModel = dynamoModel;

            // Create a core which is used for parsing code and loading libraries
            libraryCore = new ProtoCore.Core(new Options()
            {
                RootCustomPropertyFilterPathName = string.Empty
            });
            libraryCore.Executives.Add(Language.kAssociative,new ProtoAssociative.Executive(libraryCore));
            libraryCore.Executives.Add(Language.kImperative, new ProtoImperative.Executive(libraryCore));
            libraryCore.ParsingMode = ParseMode.AllowNonAssignment;

            libraryServices = new LibraryServices(libraryCore);
            libraryServices.LibraryLoading += this.LibraryLoading;
            libraryServices.LibraryLoadFailed += this.LibraryLoadFailed;
            libraryServices.LibraryLoaded += this.LibraryLoaded;

            liveRunnerServices = new LiveRunnerServices(dynamoModel, this, geometryFactoryFileName);
            liveRunnerServices.ReloadAllLibraries(libraryServices.ImportedLibraries);

            codeCompletionServices = new CodeCompletionServices(LiveRunnerCore);

            astBuilder = new AstBuilder(dynamoModel, this);
            syncDataManager = new SyncDataManager();

            dynamoModel.NodeDeleted += NodeDeleted;
        }
Exemplo n.º 2
0
        public void TestPreLoadedLibrary()
        {
            LibraryServices libraryServices = LibraryServices.GetInstance();
            var             loadedLibs      = libraryServices.Libraries;

            Assert.IsTrue(loadedLibs.Any());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Load a WorkspaceModel from json. If the WorkspaceModel is a HomeWorkspaceModel
        /// it will be set as the current workspace.
        /// </summary>
        /// <param name="json"></param>
        public static WorkspaceModel LoadWorkspaceFromJson(string json, LibraryServices libraryServices,
            EngineController engineController, DynamoScheduler scheduler, NodeFactory factory,
            bool isTestMode, bool verboseLogging, CustomNodeManager manager)
        {
            var settings = new JsonSerializerSettings
            {
                Error = (sender, args) =>
                {
                    args.ErrorContext.Handled = true;
                    Console.WriteLine(args.ErrorContext.Error);
                },
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
                TypeNameHandling = TypeNameHandling.Auto,
                Formatting = Formatting.Indented,
                Converters = new List<JsonConverter>{
                        new ConnectorConverter(),
                        new AnnotationConverter(),
                        new WorkspaceConverter(engineController, scheduler, factory, isTestMode, verboseLogging),
                        new NodeModelConverter(manager, libraryServices),
                    },
                ReferenceResolverProvider = () => { return new IdReferenceResolver(); }
            };

            var result = ReplaceTypeDeclarations(json, true);
            var ws = JsonConvert.DeserializeObject<WorkspaceModel>(result, settings);

            return ws;
        }
Exemplo n.º 4
0
 /// <summary>
 ///     Initilizes a new instance of the <see cref="CodeBlockNodeModel"/> class
 /// </summary>
 /// <param name="libraryServices"><see cref="LibraryServices"/> object to manage
 ///  builtin libraries as well as imported libraries</param>
 public CodeBlockNodeModel(LibraryServices libraryServices)
 {
     ArgumentLacing = LacingStrategy.Disabled;
     this.libraryServices = libraryServices;
     this.ElementResolver = new ElementResolver();
     ProcessCodeDirect();
 }
Exemplo n.º 5
0
 public CodeBlockNodeModel(LibraryServices libraryServices)
 {
     ArgumentLacing = LacingStrategy.Disabled;
     this.libraryServices = libraryServices;
     this.libraryServices.LibraryLoaded += LibraryServicesOnLibraryLoaded;
     this.ElementResolver = new ElementResolver();
 }
Exemplo n.º 6
0
        /// <summary>
        /// Save a Workspace to json.
        /// </summary>
        /// <returns>A string representing the serialized WorkspaceModel.</returns>
        public static string SaveWorkspaceToJson(WorkspaceModel workspace, LibraryServices libraryServices,
                                                 EngineController engineController, DynamoScheduler scheduler, NodeFactory factory,
                                                 bool isTestMode, bool verboseLogging, CustomNodeManager manager)
        {
            var settings = new JsonSerializerSettings
            {
                Error = (sender, args) =>
                {
                    args.ErrorContext.Handled = true;
                    Console.WriteLine(args.ErrorContext.Error);
                },
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
                TypeNameHandling      = TypeNameHandling.Auto,
                Formatting            = Formatting.Indented,
                Converters            = new List <JsonConverter> {
                    new ConnectorConverter(),
                    new AnnotationConverter(),
                    new WorkspaceConverter(engineController, scheduler, factory,
                                           isTestMode, verboseLogging),
                    new NodeModelConverter(manager, libraryServices),
                },
                ReferenceResolverProvider = () => { return(new IdReferenceResolver()); }
            };

            var json   = JsonConvert.SerializeObject(workspace, settings);
            var result = ReplaceTypeDeclarations(json);

            return(result);
        }
Exemplo n.º 7
0
        private async Task InitializeDataAsync()
        {
            var libraryServices   = new LibraryServices();
            var classroomServices = new ClassRoomServices();

            ClassRoomList = await classroomServices.GetClassRoomAsync();

            LibraryList = await libraryServices.GetLibraryAsync();
        }
Exemplo n.º 8
0
        public void Setup()
        {
            libraryCore = new ProtoCore.Core(new Options {
                RootCustomPropertyFilterPathName = string.Empty
            });
            libraryCore.Compilers.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Compiler(libraryCore));
            libraryCore.Compilers.Add(ProtoCore.Language.kImperative, new ProtoImperative.Compiler(libraryCore));
            libraryCore.ParsingMode = ParseMode.AllowNonAssignment;
            libraryServices         = new LibraryServices(libraryCore, pathManager);

            RegisterEvents();
        }
Exemplo n.º 9
0
        public CodeBlockNodeModel(string userCode, Guid guid, double xPos, double yPos, LibraryServices libraryServices, ElementResolver resolver)
        {
            ArgumentLacing = LacingStrategy.Disabled;
            X = xPos;
            Y = yPos;
            this.libraryServices = libraryServices;
            this.ElementResolver = resolver;
            code = userCode;
            GUID = guid;
            ShouldFocus = false;

            ProcessCodeDirect();
        }
Exemplo n.º 10
0
        public override void Init()
        {
            base.Init();

            var options = new ProtoCore.Options();

            options.RootModulePathName = string.Empty;
            libraryServicesCore        = new ProtoCore.Core(options);
            libraryServicesCore.Compilers.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Compiler(libraryServicesCore));
            libraryServicesCore.Compilers.Add(ProtoCore.Language.kImperative, new ProtoImperative.Compiler(libraryServicesCore));

            libraryServices = new LibraryServices(libraryServicesCore);
        }
Exemplo n.º 11
0
        /// <summary>
        ///     Scan the PackagesDirectory for packages and attempt to load all of them.  Beware! Fails silently for duplicates.
        /// </summary>
        public void LoadPackagesIntoDynamo( IPreferences preferences, LibraryServices libraryServices )
        {
            this.ScanAllPackageDirectories( preferences );

            foreach (var pkg in LocalPackages)
            {
                DynamoPathManager.Instance.AddResolutionPath(pkg.BinaryDirectory);
            }

            foreach (var pkg in LocalPackages)
            {
                pkg.LoadIntoDynamo(loader, logger, libraryServices);
            }
        }
Exemplo n.º 12
0
        /// <summary>
        ///     Scan the PackagesDirectory for packages and attempt to load all of them.  Beware! Fails silently for duplicates.
        /// </summary>
        public void LoadPackagesIntoDynamo(IPreferences preferences, LibraryServices libraryServices)
        {
            this.ScanAllPackageDirectories(preferences);

            foreach (var pkg in LocalPackages)
            {
                DynamoPathManager.Instance.AddResolutionPath(pkg.BinaryDirectory);
            }

            foreach (var pkg in LocalPackages)
            {
                pkg.LoadIntoDynamo(loader, logger, libraryServices);
            }
        }
Exemplo n.º 13
0
        public override void Init()
        {
            base.Init();

            var options = new ProtoCore.Options();
            options.RootModulePathName = string.Empty;
            libraryServicesCore = new ProtoCore.Core(options);
            libraryServicesCore.Executives.Add(ProtoCore.Language.kAssociative,
                new ProtoAssociative.Executive(libraryServicesCore));
            libraryServicesCore.Executives.Add(ProtoCore.Language.kImperative,
                new ProtoImperative.Executive(libraryServicesCore));

            libraryServices = new LibraryServices(libraryServicesCore);
        }
Exemplo n.º 14
0
        public EngineController(DynamoController controller)
        {
            libraryServices = LibraryServices.GetInstance();
            libraryServices.LibraryLoading += this.LibraryLoading;
            libraryServices.LibraryLoadFailed += this.LibraryLoadFailed;
            libraryServices.LibraryLoaded += this.LibraryLoaded;

            liveRunnerServices = new LiveRunnerServices(this);
            liveRunnerServices.ReloadAllLibraries(libraryServices.Libraries.ToList());

            astBuilder = new AstBuilder(this);
            syncDataManager = new SyncDataManager();

            this.controller = controller;
            this.controller.DynamoModel.NodeDeleted += NodeDeleted;
        }
Exemplo n.º 15
0
        public EngineController(DynamoModel dynamoModel, string geometryFactoryFileName)
        {
            this.dynamoModel = dynamoModel;

            libraryServices = LibraryServices.GetInstance();
            libraryServices.LibraryLoading += this.LibraryLoading;
            libraryServices.LibraryLoadFailed += this.LibraryLoadFailed;
            libraryServices.LibraryLoaded += this.LibraryLoaded;

            liveRunnerServices = new LiveRunnerServices(dynamoModel, this, geometryFactoryFileName);
            liveRunnerServices.ReloadAllLibraries(libraryServices.Libraries.ToList());

            astBuilder = new AstBuilder(dynamoModel, this);
            syncDataManager = new SyncDataManager();

            dynamoModel.NodeDeleted += NodeDeleted;
        }
Exemplo n.º 16
0
        public override void Setup()
        {
            base.Setup();

            libraryCore = new ProtoCore.Core(new Options { RootCustomPropertyFilterPathName = string.Empty });
            libraryCore.Compilers.Add(Language.kAssociative, new ProtoAssociative.Compiler(libraryCore));
            libraryCore.Compilers.Add(Language.kImperative, new ProtoImperative.Compiler(libraryCore));
            libraryCore.ParsingMode = ParseMode.AllowNonAssignment;

            var pathResolver = new TestPathResolver();
            pathResolver.AddPreloadLibraryPath("DSCoreNodes.dll");

            var pathManager = new PathManager(new PathManagerParams
            {
                PathResolver = pathResolver
            });

            libraryServices = new LibraryServices(libraryCore, pathManager);

            RegisterEvents();
        }
Exemplo n.º 17
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);
        }
Exemplo n.º 18
0
        public override void Setup()
        {
            base.Setup();

            libraryCore = new ProtoCore.Core(new Options());
            libraryCore.Compilers.Add(Language.Associative, new ProtoAssociative.Compiler(libraryCore));
            libraryCore.Compilers.Add(Language.Imperative, new ProtoImperative.Compiler(libraryCore));
            libraryCore.ParsingMode = ParseMode.AllowNonAssignment;

            var pathResolver = new TestPathResolver();
            pathResolver.AddPreloadLibraryPath("DSCoreNodes.dll");

            var pathManager = new PathManager(new PathManagerParams
            {
                PathResolver = pathResolver
            });

            var settings = new PreferenceSettings();

            libraryServices = new LibraryServices(libraryCore, pathManager, settings);

            RegisterEvents();
        }
Exemplo n.º 19
0
 public CodeBlockNodeModel(string userCode, double xPos, double yPos, LibraryServices libraryServices)
     : this(userCode, Guid.NewGuid(), xPos, yPos, libraryServices) { }
Exemplo n.º 20
0
 public CodeBlockNodeSearchElement(TypeLoadData data, LibraryServices manager)
     : base(data)
 {
     libraryServices = manager;
 }
Exemplo n.º 21
0
 public override void Setup()
 {
     base.Setup();
     libraryServices = CurrentDynamoModel.LibraryServices;
 }
Exemplo n.º 22
0
        /// <summary>
        ///     LibraryLoaded event handler.
        /// </summary>
        private void LibraryLoaded(object sender, LibraryServices.LibraryLoadedEventArgs e)
        {
            liveRunnerServices.ReloadAllLibraries(libraryServices.ImportedLibraries);

            // The LiveRunner core is newly instantiated whenever a new library is imported
            // due to which a new instance of CodeCompletionServices needs to be created with the new Core
            codeCompletionServices = new CodeCompletionServices(LiveRunnerCore);
            libraryServices.SetLiveCore(LiveRunnerCore);
        }
Exemplo n.º 23
0
        /// <summary>
        /// This function creates EngineController
        /// </summary>
        /// <param name="libraryServices"> LibraryServices manages builtin libraries and imported libraries.</param>
        /// <param name="geometryFactoryFileName">Path to LibG</param>
        /// <param name="verboseLogging">Bool value, if set to true, enables verbose logging</param>
        public EngineController(LibraryServices libraryServices, string geometryFactoryFileName, bool verboseLogging)
        {
            this.libraryServices = libraryServices;
            libraryServices.LibraryLoaded += LibraryLoaded;
            CompilationServices = new CompilationServices(libraryServices.LibraryManagementCore);

            liveRunnerServices = new LiveRunnerServices(this, geometryFactoryFileName);

            liveRunnerServices.ReloadAllLibraries(libraryServices.ImportedLibraries);
            libraryServices.SetLiveCore(LiveRunnerCore);

            codeCompletionServices = new CodeCompletionServices(LiveRunnerCore);

            astBuilder = new AstBuilder(this);
            syncDataManager = new SyncDataManager();

            VerboseLogging = verboseLogging;
        }
Exemplo n.º 24
0
        /// <summary>
        /// Default constructor for DynamoModel
        /// </summary>
        /// <param name="config">Start configuration</param>
        protected DynamoModel(IStartConfiguration config)
        {
            ClipBoard = new ObservableCollection<ModelBase>();

            pathManager = new PathManager(new PathManagerParams
            {
                CorePath = config.DynamoCorePath,
                HostPath = config.DynamoHostPath,
                PathResolver = config.PathResolver
            });

            // Ensure we have all directories in place.
            var exceptions = new List<Exception>();
            pathManager.EnsureDirectoryExistence(exceptions);

            Context = config.Context;
            IsTestMode = config.StartInTestMode;

            var config2 = config as IStartConfiguration2;
            IsHeadless = (config2 != null) ? config2.IsHeadless : false;

            DebugSettings = new DebugSettings();
            Logger = new DynamoLogger(DebugSettings, pathManager.LogDirectory);

            foreach (var exception in exceptions)
            {
                Logger.Log(exception); // Log all exceptions.
            }

            MigrationManager = new MigrationManager(DisplayFutureFileMessage, DisplayObsoleteFileMessage);
            MigrationManager.MessageLogged += LogMessage;
            MigrationManager.MigrationTargets.Add(typeof(WorkspaceMigrations));

            var thread = config.SchedulerThread ?? new DynamoSchedulerThread();
            Scheduler = new DynamoScheduler(thread, config.ProcessMode);
            Scheduler.TaskStateChanged += OnAsyncTaskStateChanged;

            geometryFactoryPath = config.GeometryFactoryPath;

            IPreferences preferences = CreateOrLoadPreferences(config.Preferences);
            var settings = preferences as PreferenceSettings;
            if (settings != null)
            {
                PreferenceSettings = settings;
                PreferenceSettings.PropertyChanged += PreferenceSettings_PropertyChanged;
            }

            InitializeInstrumentationLogger();

            if (!IsTestMode && PreferenceSettings.IsFirstRun)
            {
                DynamoMigratorBase migrator = null;

                try
                {
                    var dynamoLookup = config.UpdateManager != null && config.UpdateManager.Configuration != null
                        ? config.UpdateManager.Configuration.DynamoLookUp : null;

                    migrator = DynamoMigratorBase.MigrateBetweenDynamoVersions(pathManager, dynamoLookup);
                }
                catch (Exception e)
                {
                    Logger.Log(e.Message);
                }

                if (migrator != null)
                {
                    var isFirstRun = PreferenceSettings.IsFirstRun;
                    PreferenceSettings = migrator.PreferenceSettings;

                    // Preserve the preference settings for IsFirstRun as this needs to be set
                    // only by UsageReportingManager
                    PreferenceSettings.IsFirstRun = isFirstRun;
                }
            }
            InitializePreferences(PreferenceSettings);

            // At this point, pathManager.PackageDirectories only has 1 element which is the directory
            // in AppData. If list of PackageFolders is empty, add the folder in AppData to the list since there
            // is no additional location specified. Otherwise, update pathManager.PackageDirectories to include
            // PackageFolders
            if (PreferenceSettings.CustomPackageFolders.Count == 0)
                PreferenceSettings.CustomPackageFolders = new List<string> {pathManager.UserDataDirectory};

            //Make sure that the default package folder is added in the list if custom packages folder.
            var userDataFolder = pathManager.GetUserDataFolder(); //Get the default user data path
            if (Directory.Exists(userDataFolder) && !PreferenceSettings.CustomPackageFolders.Contains(userDataFolder))
            {
                PreferenceSettings.CustomPackageFolders.Add(userDataFolder);
            }

            pathManager.Preferences = PreferenceSettings;


            SearchModel = new NodeSearchModel();
            SearchModel.ItemProduced +=
                node => ExecuteCommand(new CreateNodeCommand(node, 0, 0, true, true));

            NodeFactory = new NodeFactory();
            NodeFactory.MessageLogged += LogMessage;

            CustomNodeManager = new CustomNodeManager(NodeFactory, MigrationManager);
            InitializeCustomNodeManager();

            extensionManager = new ExtensionManager();
            extensionManager.MessageLogged += LogMessage;
            var extensions = config.Extensions ?? LoadExtensions();

            Loader = new NodeModelAssemblyLoader();
            Loader.MessageLogged += LogMessage;

            // Create a core which is used for parsing code and loading libraries
            var libraryCore = new ProtoCore.Core(new Options());

            libraryCore.Compilers.Add(Language.Associative, new Compiler(libraryCore));
            libraryCore.Compilers.Add(Language.Imperative, new ProtoImperative.Compiler(libraryCore));
            libraryCore.ParsingMode = ParseMode.AllowNonAssignment;

            LibraryServices = new LibraryServices(libraryCore, pathManager, PreferenceSettings);
            LibraryServices.MessageLogged += LogMessage;
            LibraryServices.LibraryLoaded += LibraryLoaded;

            ResetEngineInternal();

            AddHomeWorkspace();

            AuthenticationManager = new AuthenticationManager(config.AuthProvider);

            UpdateManager = config.UpdateManager ?? new DefaultUpdateManager(null);

            // config.UpdateManager has to be cast to IHostUpdateManager in order to extract the HostVersion and HostName
            // see IHostUpdateManager summary for more details 
            var hostUpdateManager = config.UpdateManager as IHostUpdateManager;
          
            if (hostUpdateManager != null)
            {
                HostName = hostUpdateManager.HostName;
                HostVersion = hostUpdateManager.HostVersion == null ? null : hostUpdateManager.HostVersion.ToString();
            }
            else
            {
                HostName = string.Empty;
                HostVersion = null;
            }
            
            UpdateManager.Log += UpdateManager_Log;
            if (!IsTestMode && !IsHeadless)
            {
                DefaultUpdateManager.CheckForProductUpdate(UpdateManager);
            }

            Logger.Log(string.Format("Dynamo -- Build {0}",
                                        Assembly.GetExecutingAssembly().GetName().Version));

            InitializeNodeLibrary(PreferenceSettings);

            if (extensions.Any())
            {
                var startupParams = new StartupParams(config.AuthProvider,
                    pathManager, new ExtensionLibraryLoader(this), CustomNodeManager,
                    GetType().Assembly.GetName().Version, PreferenceSettings);

                foreach (var ext in extensions)
                {
                    var logSource = ext as ILogSource;
                    if (logSource != null)
                        logSource.MessageLogged += LogMessage;

                    try
                    {
                        ext.Startup(startupParams);
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(ex.Message);
                    }

                    ExtensionManager.Add(ext);
                }
            }

            LogWarningMessageEvents.LogWarningMessage += LogWarningMessage;

            StartBackupFilesTimer();

            TraceReconciliationProcessor = this;

            foreach (var ext in ExtensionManager.Extensions)
            {
                try
                {
                    ext.Ready(new ReadyParams(this));
                }
                catch (Exception ex)
                {
                    Logger.Log(ex.Message);
                }
            }
        }
Exemplo n.º 25
0
 private void LibraryServicesOnLibraryLoaded(object sender, LibraryServices.LibraryLoadedEventArgs libraryLoadedEventArgs)
 {
     //ProcessCodeDirect();
 }
Exemplo n.º 26
0
        protected DynamoModel(IStartConfiguration config)
        {
            ClipBoard = new ObservableCollection<ModelBase>();

            pathManager = new PathManager(new PathManagerParams
            {
                CorePath = config.DynamoCorePath,
                PathResolver = config.PathResolver
            });

            // Ensure we have all directories in place.
            pathManager.EnsureDirectoryExistence();

            Context = config.Context;
            IsTestMode = config.StartInTestMode;
            DebugSettings = new DebugSettings();
            Logger = new DynamoLogger(DebugSettings, pathManager.LogDirectory);

            MigrationManager = new MigrationManager(DisplayFutureFileMessage, DisplayObsoleteFileMessage);
            MigrationManager.MessageLogged += LogMessage;
            MigrationManager.MigrationTargets.Add(typeof(WorkspaceMigrations));

            var thread = config.SchedulerThread ?? new DynamoSchedulerThread();
            Scheduler = new DynamoScheduler(thread, IsTestMode);
            Scheduler.TaskStateChanged += OnAsyncTaskStateChanged;

            geometryFactoryPath = config.GeometryFactoryPath;

            IPreferences preferences = CreateOrLoadPreferences(config.Preferences);
            var settings = preferences as PreferenceSettings;
            if (settings != null)
            {
                PreferenceSettings = settings;
                PreferenceSettings.PropertyChanged += PreferenceSettings_PropertyChanged;
            }

            InitializePreferences(preferences);
            InitializeInstrumentationLogger();

            if (!isTestMode && this.PreferenceSettings.IsFirstRun)
            {
                DynamoMigratorBase migrator = null;

                try
                {
                    migrator = DynamoMigratorBase.MigrateBetweenDynamoVersions(pathManager, config.PathResolver);
                }
                catch (Exception e)
                {
                    Logger.Log(e.Message);
                }

                if (migrator != null)
                {
                    var isFirstRun = this.PreferenceSettings.IsFirstRun;
                    this.PreferenceSettings = migrator.PreferenceSettings;

                    // Preserve the preference settings for IsFirstRun as this needs to be set 
                    // only by UsageReportingManager
                    this.PreferenceSettings.IsFirstRun = isFirstRun;
                }
            }

            SearchModel = new NodeSearchModel();
            SearchModel.ItemProduced +=
                node => ExecuteCommand(new CreateNodeCommand(node, 0, 0, true, true));

            NodeFactory = new NodeFactory();
            NodeFactory.MessageLogged += LogMessage;

            CustomNodeManager = new CustomNodeManager(NodeFactory, MigrationManager);
            InitializeCustomNodeManager();

            extensionManager = new ExtensionManager();
            extensionManager.MessageLogged += LogMessage;
            var extensions = config.Extensions ?? ExtensionManager.ExtensionLoader.LoadDirectory(pathManager.ExtensionsDirectory);

            if (extensions.Any())
            {
                var startupParams = new StartupParams(config.AuthProvider,
                    pathManager, CustomNodeManager);

                foreach (var ext in extensions)
                {
                    ext.Startup(startupParams);
                    ext.Load(preferences, pathManager);
                    ext.RequestLoadNodeLibrary += LoadNodeLibrary;
                    ExtensionManager.Add(ext);
                }
            }

            Loader = new NodeModelAssemblyLoader();
            Loader.MessageLogged += LogMessage;

            DisposeLogic.IsShuttingDown = false;

            // Create a core which is used for parsing code and loading libraries
            var libraryCore =
                new ProtoCore.Core(new Options { RootCustomPropertyFilterPathName = string.Empty });

            libraryCore.Compilers.Add(Language.kAssociative, new Compiler(libraryCore));
            libraryCore.Compilers.Add(Language.kImperative, new ProtoImperative.Compiler(libraryCore));
            libraryCore.ParsingMode = ParseMode.AllowNonAssignment;

            LibraryServices = new LibraryServices(libraryCore, pathManager);
            LibraryServices.MessageLogged += LogMessage;
            LibraryServices.LibraryLoaded += LibraryLoaded;

            ResetEngineInternal();

            AddHomeWorkspace();

            AuthenticationManager = new AuthenticationManager(config.AuthProvider);

            UpdateManager = config.UpdateManager ?? new DefaultUpdateManager(null);
            UpdateManager.Log += UpdateManager_Log;
            if (!IsTestMode)
            {
                DefaultUpdateManager.CheckForProductUpdate(UpdateManager);
            }
            
            Logger.Log(string.Format("Dynamo -- Build {0}", 
                                        Assembly.GetExecutingAssembly().GetName().Version));

            InitializeNodeLibrary(preferences);

            LogWarningMessageEvents.LogWarningMessage += LogWarningMessage;

            StartBackupFilesTimer();

            TraceReconciliationProcessor = this; 
            
            foreach (var ext in ExtensionManager.Extensions)
            {
                try
                {
                    ext.Ready(new ReadyParams());
                }
                catch (Exception ex)
                {
                    Logger.Log(ex.Message);
                }
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// LibraryLoaded event handler.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LibraryLoaded(object sender, LibraryServices.LibraryLoadedEventArgs e)
        {
            string newLibrary = e.LibraryPath;

            // Load all functions defined in that library.
            dynamoModel.SearchModel.Add(libraryServices.GetFunctionGroups(newLibrary));

            // Reset the VM
            liveRunnerServices.ReloadAllLibraries(libraryServices.ImportedLibraries);

            // The LiveRunner core is newly instantiated whenever a new library is imported
            // due to which a new instance of CodeCompletionServices needs to be created with the new Core
            codeCompletionServices = new CodeCompletionServices(LiveRunnerCore);

            // Mark all nodes as dirty so that AST for the whole graph will be
            // regenerated.
            foreach (var node in dynamoModel.HomeSpace.Nodes)
            {
                node.RequiresRecalc = true;
            }
        }
Exemplo n.º 28
0
        public void LoadIntoDynamo( DynamoLoader loader, ILogger logger, LibraryServices libraryServices)
        {
            try
            {
                this.LoadAssembliesIntoDynamo(loader, logger, libraryServices);
                this.LoadCustomNodesIntoDynamo( loader );
                this.EnumerateAdditionalFiles();
                
                Loaded = true;
            }
            catch (Exception e)
            {
                logger.Log("Exception when attempting to load package " + this.Name + " from " + this.RootDirectory);
                logger.Log(e.GetType() + ": " + e.Message);
            }

        }
Exemplo n.º 29
0
        /// <summary>
        /// LibraryLoaded event handler.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LibraryLoaded(object sender, LibraryServices.LibraryLoadedEventArgs e)
        {
            string newLibrary = e.LibraryPath;

            // Load all functions defined in that library.
            dynSettings.Controller.SearchViewModel.Add(libraryServices.GetFunctionGroups(newLibrary));

            // Reset the VM
            liveRunnerServices.ReloadAllLibraries(libraryServices.Libraries.ToList());

            // Mark all nodes as dirty so that AST for the whole graph will be
            // regenerated.
            foreach (var node in dynSettings.Controller.DynamoModel.HomeSpace.Nodes)
            {
                node.RequiresRecalc = true;
            }
        }
Exemplo n.º 30
0
 /// <summary>
 /// LibraryLoadFailed event handler.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void LibraryLoadFailed(object sender, LibraryServices.LibraryLoadFailedEventArgs e)
 {
 }
Exemplo n.º 31
0
        private void LoadAssembliesIntoDynamo( DynamoLoader loader, ILogger logger, LibraryServices libraryServices)
        {
            var assemblies = LoadAssembliesInBinDirectory(logger);

            // 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.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));
            }
        }
Exemplo n.º 32
0
 public CodeBlockNodeModel(string userCode, double xPos, double yPos, LibraryServices libraryServices, ElementResolver resolver)
     : this(userCode, Guid.NewGuid(), xPos, yPos, libraryServices, resolver) { }
Exemplo n.º 33
0
 private void LibraryLoaded(object sender, LibraryServices.LibraryLoadedEventArgs e)
 {
     // Mark all nodes as dirty so that AST for the whole graph will be
     // regenerated.
     MarkNodesAsModifiedAndRequestRun(Nodes);
 }
Exemplo n.º 34
0
        public override void Cleanup()
        {
            if (libraryServicesCore != null)
            {
                libraryServicesCore.Cleanup();
                libraryServicesCore = null;
            }
            libraryServices = null;

            base.Cleanup();
            DynamoUtilities.DynamoPathManager.DestroyInstance();
        }
Exemplo n.º 35
0
 /// <summary>
 ///     Initilizes a new instance of the <see cref="CodeBlockNodeModel"/> class
 /// </summary>
 /// <param name="code">Code block content</param>
 /// <param name="x">X coordinate of the code block</param>
 /// <param name="y">Y coordinate of the code block</param>
 /// <param name="libraryServices"><see cref="LibraryServices"/> object to manage
 ///  builtin libraries as well as imported libraries</param>
 /// <param name="resolver">Responsible for resolving 
 /// a partial class name to its fully resolved name</param>
 public CodeBlockNodeModel(string code, double x, double y, LibraryServices libraryServices, ElementResolver resolver)
     : this(code, Guid.NewGuid(), x, y, libraryServices, resolver) { }
Exemplo n.º 36
0
        /// <summary>
        /// LibraryLoaded event handler.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LibraryLoaded(object sender, LibraryServices.LibraryLoadedEventArgs e)
        {
            string newLibrary = e.LibraryPath;

            // Load all functions defined in that library.
            AddZeroTouchNodesToSearch(LibraryServices.GetFunctionGroups(newLibrary));
        }
Exemplo n.º 37
0
 /// <summary>
 /// LibraryLoading event handler.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void LibraryLoading(object sender, LibraryServices.LibraryLoadingEventArgs e)
 {
 }