Skip to content

Commit

Permalink
Remove the DynamoModel.PreferenceSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
saintentropy committed Nov 30, 2023
1 parent 6363956 commit b9adf9f
Show file tree
Hide file tree
Showing 64 changed files with 474 additions and 695 deletions.
4 changes: 2 additions & 2 deletions src/DynamoCore/Configuration/ExecutionSession.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using Dynamo.Interfaces;
Expand All @@ -22,7 +22,7 @@ public ExecutionSession(Scheduler.UpdateGraphAsyncTask updateTask, DynamoModel m
parameters[ParameterKeys.GeometryFactory] = geometryFactoryPath;
parameters[ParameterKeys.MajorVersion] = pathManager.MajorFileVersion;
parameters[ParameterKeys.MinorVersion] = pathManager.MinorFileVersion;
parameters[ParameterKeys.NumberFormat] = model.PreferenceSettings.NumberFormat;
parameters[ParameterKeys.NumberFormat] = PreferenceSettings.Instance.NumberFormat;
parameters[ParameterKeys.LastExecutionDuration] = new TimeSpan(updateTask.ExecutionEndTime.TickCount - updateTask.ExecutionStartTime.TickCount);
parameters[ParameterKeys.PackagePaths] = pathManager.PackagesDirectories;
parameters[ParameterKeys.Logger] = model.Logger;
Expand Down
20 changes: 4 additions & 16 deletions src/DynamoCore/Configuration/PathManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,11 @@ internal static Lazy<PathManager>

#endregion

internal IPreferences Preferences { get; set; }

private IEnumerable<string> RootDirectories
{
get
{
return Preferences != null ?
Preferences.CustomPackageFolders.Select(path => path == DynamoModel.BuiltInPackagesToken ? BuiltinPackagesDirectory : path)
: rootDirectories;
{
return PreferenceSettings.Instance.CustomPackageFolders.Select(path => path == DynamoModel.BuiltInPackagesToken ? BuiltinPackagesDirectory : path);
}
}

Expand Down Expand Up @@ -175,11 +171,7 @@ public string DefaultUserDefinitions
{
get
{
if (Preferences is PreferenceSettings preferences)
{
return TransformPath(preferences.SelectedPackagePathForInstall, DefinitionsDirectoryName);
}
return TransformPath(RootDirectories.First(), DefinitionsDirectoryName);
return TransformPath(PreferenceSettings.Instance.SelectedPackagePathForInstall, DefinitionsDirectoryName);
}
}

Expand Down Expand Up @@ -207,11 +199,7 @@ public string DefaultPackagesDirectory
{
get
{
if (Preferences is PreferenceSettings preferences)
{
return TransformPath(preferences.SelectedPackagePathForInstall, PackagesDirectoryName);
}
return TransformPath(RootDirectories.First(), PackagesDirectoryName);
return TransformPath(PreferenceSettings.Instance.SelectedPackagePathForInstall, PackagesDirectoryName);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/DynamoCore/Configuration/PreferenceSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ internal readonly static Lazy<PreferenceSettings>
(() => PreferenceSettings.Load(PathManager.Instance.PreferenceFilePath));

[XmlIgnore]
public static PreferenceSettings Instance { get { return dynamoModelRuntimePreferenceSettings ?? lazy.Value; } }
public static PreferenceSettings Instance { get; internal set; } = lazy.Value;

private string numberFormat;
private string lastUpdateDownloadPath;
Expand Down
3 changes: 2 additions & 1 deletion src/DynamoCore/Extensions/StartupParams.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Dynamo.Configuration;
using Dynamo.Graph.Nodes.CustomNodes;
using Dynamo.Interfaces;
using Dynamo.Library;
Expand Down Expand Up @@ -121,7 +122,7 @@ internal StartupParams(DynamoModel dynamoModel)
libraryLoader = new ExtensionLibraryLoader(dynamoModel);
customNodeManager = dynamoModel.CustomNodeManager;
dynamoVersion = new Version(DynamoModel.Version);
preferences = dynamoModel.PreferenceSettings;
preferences = PreferenceSettings.Instance;
linterManager = dynamoModel.LinterManager;
IsGeometryLibraryLoaded = dynamoModel.IsASMLoaded;
NoNetworkMode = dynamoModel.NoNetworkMode;
Expand Down
14 changes: 2 additions & 12 deletions src/DynamoCore/Library/LibraryServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public class LibraryServices : LogSourceBase, IDisposable
private readonly List<string> packagedLibraries = new List<string>();

private readonly IPathManager pathManager;
private readonly IPreferences preferenceSettings;

/// <summary>
/// Returns core which is used for parsing code and loading libraries
Expand All @@ -69,25 +68,16 @@ public UpgradeHint()
private readonly Dictionary<string, UpgradeHint> priorNameHints =
new Dictionary<string, UpgradeHint>();

/// <summary>
/// Initializes a new instance of the <see cref="LibraryServices"/> class.
/// </summary>
/// <param name="libraryManagementCore">Core which is used for parsing code and loading libraries</param>
/// <param name="pathManager">Instance of IPathManager containing neccessary Dynamo paths</param>
public LibraryServices(ProtoCore.Core libraryManagementCore, IPathManager pathManager)
: this(libraryManagementCore, pathManager, null) { }

/// <summary>
/// Initializes a new instance of the <see cref="LibraryServices"/> class.
/// </summary>
/// <param name="libraryManagementCore">Core which is used for parsing code and loading libraries</param>
/// <param name="pathManager">Instance of IPathManager containing neccessary Dynamo paths</param>
/// <param name="preferences">The preference settings of the Dynamo instance</param>
public LibraryServices(ProtoCore.Core libraryManagementCore, IPathManager pathManager, IPreferences preferences)
public LibraryServices(ProtoCore.Core libraryManagementCore, IPathManager pathManager)
{
LibraryManagementCore = libraryManagementCore;
this.pathManager = pathManager;
preferenceSettings = preferences;

PreloadLibraries(pathManager.PreloadedLibraries);
PopulateBuiltIns();
Expand Down Expand Up @@ -366,7 +356,7 @@ internal IEnumerable<FunctionGroup> GetFunctionGroups(string library)
IEnumerable<FunctionGroup> result = functionGroups.Values;

// Skip namespaces specified in the preference settings
var settings = preferenceSettings as PreferenceSettings;
var settings = PreferenceSettings.Instance;
if (settings != null)
{
foreach (var nsp in settings.NamespacesToExcludeFromLibrary
Expand Down
Loading

0 comments on commit b9adf9f

Please sign in to comment.