コード例 #1
0
ファイル: PathManager.cs プロジェクト: tylerputnam/Dynamo
        /// <summary>
        /// Constructs an instance of PathManager object.
        /// </summary>
        /// <param name="pathManagerParams">Parameters to configure the new
        /// instance of PathManager. See PathManagerParams for details of each
        /// field.</param>
        ///
        internal PathManager(PathManagerParams pathManagerParams)
        {
            var corePath     = pathManagerParams.CorePath;
            var pathResolver = pathManagerParams.PathResolver;

            if (string.IsNullOrEmpty(corePath) || !Directory.Exists(corePath))
            {
                // If the caller does not provide an alternative core path,
                // use the default folder in which DynamoCore.dll resides.
                var dynamoCorePath = Assembly.GetExecutingAssembly().Location;
                corePath = Path.GetDirectoryName(dynamoCorePath);
            }

            dynamoCoreDir = corePath;
            var assemblyPath = Path.Combine(dynamoCoreDir, "DynamoCore.dll");

            if (!File.Exists(assemblyPath))
            {
                throw new Exception("Dynamo's core path could not be found. " +
                                    "If you are running Dynamo from a test, try specifying the " +
                                    "Dynamo core location in the DynamoBasePath variable in " +
                                    "TestServices.dll.config.");
            }

            // If both major/minor versions are zero, get from assembly.
            majorFileVersion = pathManagerParams.MajorFileVersion;
            minorFileVersion = pathManagerParams.MinorFileVersion;
            if (majorFileVersion == 0 && (minorFileVersion == 0))
            {
                var v = FileVersionInfo.GetVersionInfo(assemblyPath);
                majorFileVersion = v.FileMajorPart;
                minorFileVersion = v.FileMinorPart;
            }

            // Current user specific directories.
            userDataDir = GetUserDataFolder(pathResolver);

            userDefinitions    = Path.Combine(userDataDir, DefinitionsDirectoryName);
            logDirectory       = Path.Combine(userDataDir, LogsDirectoryName);
            packagesDirectory  = Path.Combine(userDataDir, PackagesDirectoryName);
            preferenceFilePath = Path.Combine(userDataDir, PreferenceSettingsFileName);
            backupDirectory    = Path.Combine(Directory.GetParent(userDataDir).FullName, BackupDirectoryName);

            // Common directories.
            commonDataDir = GetCommonDataFolder(pathResolver);

            commonDefinitions = Path.Combine(commonDataDir, DefinitionsDirectoryName);
            samplesDirectory  = GetSamplesFolder(commonDataDir);

            nodeDirectories = new HashSet <string>
            {
                Path.Combine(dynamoCoreDir, NodesDirectoryName)
            };

            preloadedLibraries        = new HashSet <string>();
            additionalResolutionPaths = new HashSet <string>();
            LoadPathsFromResolver(pathResolver);
        }
コード例 #2
0
        /// <summary>
        /// Constructs an instance of PathManager object.
        /// </summary>
        /// <param name="pathManagerParams">Parameters to configure the new
        /// instance of PathManager. See PathManagerParams for details of each
        /// field.</param>
        ///
        internal PathManager(PathManagerParams pathManagerParams)
        {
            var corePath     = pathManagerParams.CorePath;
            var pathResolver = pathManagerParams.PathResolver;

            if (string.IsNullOrEmpty(corePath) || !Directory.Exists(corePath))
            {
                // If the caller does not provide an alternative core path,
                // use the default folder in which DynamoCore.dll resides.
                var dynamoCorePath = Assembly.GetExecutingAssembly().Location;
                corePath = Path.GetDirectoryName(dynamoCorePath);
            }

            dynamoCoreDir = corePath;
            var assemblyPath = Path.Combine(dynamoCoreDir, "DynamoCore.dll");

            if (!PathHelper.IsValidPath(assemblyPath))
            {
                throw new Exception("Dynamo's core path could not be found. " +
                                    "If you are running Dynamo from a test, try specifying the " +
                                    "Dynamo core location in the DynamoBasePath variable in " +
                                    "TestServices.dll.config.");
            }

            hostApplicationDirectory  = pathManagerParams.HostPath;
            extensionsDirectories     = new HashSet <string>();
            viewExtensionsDirectories = new HashSet <string>();

            extensionsDirectories.Add(Path.Combine(dynamoCoreDir, ExtensionsDirectoryName));
            viewExtensionsDirectories.Add(Path.Combine(dynamoCoreDir, ViewExtensionsDirectoryName));

            if (!string.IsNullOrEmpty(hostApplicationDirectory))
            {
                extensionsDirectories.Add(Path.Combine(hostApplicationDirectory, ExtensionsDirectoryName));
                viewExtensionsDirectories.Add(Path.Combine(hostApplicationDirectory, ViewExtensionsDirectoryName));
            }

            // If both major/minor versions are zero, get from assembly.
            majorFileVersion = pathManagerParams.MajorFileVersion;
            minorFileVersion = pathManagerParams.MinorFileVersion;
            if (majorFileVersion == 0 && (minorFileVersion == 0))
            {
                var v = FileVersionInfo.GetVersionInfo(assemblyPath);
                majorFileVersion = v.FileMajorPart;
                minorFileVersion = v.FileMinorPart;
            }

            // Current user specific directories.
            userDataDir = GetUserDataFolder(pathResolver);

            // When running as a headless process, put the logs directory in a consistent
            // location that doesn't change every time the version number changes.
            var userDataDirNoVersion = Directory.GetParent(userDataDir).FullName;

            logDirectory = Path.Combine(Dynamo.Models.DynamoModel.IsHeadless ? userDataDirNoVersion : userDataDir,
                                        LogsDirectoryName);

            preferenceFilePath = Path.Combine(userDataDir, PreferenceSettingsFileName);
            backupDirectory    = Path.Combine(userDataDirNoVersion, BackupDirectoryName);

            // Common directories.
            commonDataDir = GetCommonDataFolder(pathResolver);

            commonDefinitions = Path.Combine(commonDataDir, DefinitionsDirectoryName);
            samplesDirectory  = GetSamplesFolder(commonDataDir);
            var galleryDirectory = GetGalleryDirectory(commonDataDir);

            galleryFilePath = Path.Combine(galleryDirectory, GalleryContentsFileName);

            rootDirectories = new List <string> {
                userDataDir
            };

            nodeDirectories = new HashSet <string>
            {
                Path.Combine(dynamoCoreDir, NodesDirectoryName)
            };

            preloadedLibraries        = new HashSet <string>();
            additionalResolutionPaths = new HashSet <string>();
            LoadPathsFromResolver(pathResolver);
        }
コード例 #3
0
ファイル: PathManager.cs プロジェクト: Randy-Ma/Dynamo
        /// <summary>
        /// Constructs an instance of PathManager object.
        /// </summary>
        /// <param name="pathManagerParams">Parameters to configure the new 
        /// instance of PathManager. See PathManagerParams for details of each 
        /// field.</param>
        /// 
        internal PathManager(PathManagerParams pathManagerParams)
        {
            var corePath = pathManagerParams.CorePath;
            var pathResolver = pathManagerParams.PathResolver;

            if (string.IsNullOrEmpty(corePath) || !Directory.Exists(corePath))
            {
                // If the caller does not provide an alternative core path, 
                // use the default folder in which DynamoCore.dll resides.
                var dynamoCorePath = Assembly.GetExecutingAssembly().Location;
                corePath = Path.GetDirectoryName(dynamoCorePath);
            }

            dynamoCoreDir = corePath;
            var assemblyPath = Path.Combine(dynamoCoreDir, "DynamoCore.dll");
            if (!PathHelper.IsValidPath(assemblyPath))
            {
                throw new Exception("Dynamo's core path could not be found. " +
                    "If you are running Dynamo from a test, try specifying the " +
                    "Dynamo core location in the DynamoBasePath variable in " +
                    "TestServices.dll.config.");
            }

            hostApplicationDirectory = pathManagerParams.HostPath;
            extensionsDirectories = new HashSet<string>();
            viewExtensionsDirectories = new HashSet<string>();

            extensionsDirectories.Add(Path.Combine(dynamoCoreDir, ExtensionsDirectoryName));
            viewExtensionsDirectories.Add(Path.Combine(dynamoCoreDir, ViewExtensionsDirectoryName));

            if(!string.IsNullOrEmpty(hostApplicationDirectory))
            {
                extensionsDirectories.Add(Path.Combine(hostApplicationDirectory, ExtensionsDirectoryName));
                viewExtensionsDirectories.Add(Path.Combine(hostApplicationDirectory, ViewExtensionsDirectoryName));
            }

            // If both major/minor versions are zero, get from assembly.
            majorFileVersion = pathManagerParams.MajorFileVersion;
            minorFileVersion = pathManagerParams.MinorFileVersion;
            if (majorFileVersion == 0 && (minorFileVersion == 0))
            {
                var v = FileVersionInfo.GetVersionInfo(assemblyPath);
                majorFileVersion = v.FileMajorPart;
                minorFileVersion = v.FileMinorPart;
            }

            // Current user specific directories.
            userDataDir = GetUserDataFolder(pathResolver);

            logDirectory = Path.Combine(userDataDir, LogsDirectoryName);
            preferenceFilePath = Path.Combine(userDataDir, PreferenceSettingsFileName);
            backupDirectory = Path.Combine(Directory.GetParent(userDataDir).FullName, BackupDirectoryName);

            // Common directories.
            commonDataDir = GetCommonDataFolder(pathResolver);

            commonDefinitions = Path.Combine(commonDataDir, DefinitionsDirectoryName);
            samplesDirectory = GetSamplesFolder(commonDataDir);
            var galleryDirectory = GetGalleryDirectory(commonDataDir);
            galleryFilePath = Path.Combine(galleryDirectory, GalleryContentsFileName);

            rootDirectories = new List<string> { userDataDir };

            nodeDirectories = new HashSet<string>
            {
                Path.Combine(dynamoCoreDir, NodesDirectoryName)
            };

            preloadedLibraries = new HashSet<string>();
            additionalResolutionPaths = new HashSet<string>();
            LoadPathsFromResolver(pathResolver);
        }