|
|
@ -30,7 +30,7 @@ namespace CSharpBinding.FormattingStrategy |
|
|
|
{ |
|
|
|
{ |
|
|
|
public override void Execute(object parameter) |
|
|
|
public override void Execute(object parameter) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Initialize CSharpFormattingOptionsPersistence as early as possible (before solution is opened)
|
|
|
|
// Initialize CSharpFormattingPolicies as early as possible (before solution is opened)
|
|
|
|
CSharpFormattingPolicies.Instance.Initialize(); |
|
|
|
CSharpFormattingPolicies.Instance.Initialize(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -40,21 +40,20 @@ namespace CSharpBinding.FormattingStrategy |
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
internal class CSharpFormattingPolicies |
|
|
|
internal class CSharpFormattingPolicies |
|
|
|
{ |
|
|
|
{ |
|
|
|
public static readonly CSharpFormattingPolicies Instance = new CSharpFormattingPolicies(); |
|
|
|
static readonly Lazy<CSharpFormattingPolicies> LazyInstance = |
|
|
|
|
|
|
|
new Lazy<CSharpFormattingPolicies>(() => new CSharpFormattingPolicies()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static CSharpFormattingPolicies Instance { |
|
|
|
|
|
|
|
get { return LazyInstance.Value; } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public event EventHandler<CSharpFormattingPolicyUpdateEventArgs> FormattingPolicyUpdated; |
|
|
|
public event EventHandler<CSharpFormattingPolicyUpdateEventArgs> FormattingPolicyUpdated; |
|
|
|
|
|
|
|
|
|
|
|
static bool initialized; |
|
|
|
bool initialized; |
|
|
|
static Dictionary<string, CSharpFormattingPolicy> projectOptions; |
|
|
|
Dictionary<string, CSharpFormattingPolicy> projectOptions; |
|
|
|
|
|
|
|
|
|
|
|
public void Initialize() |
|
|
|
public CSharpFormattingPolicies() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (initialized) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initialized = true; |
|
|
|
|
|
|
|
projectOptions = new Dictionary<string, CSharpFormattingPolicy>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Load global settings
|
|
|
|
// Load global settings
|
|
|
|
GlobalOptions = new CSharpFormattingPolicy( |
|
|
|
GlobalOptions = new CSharpFormattingPolicy( |
|
|
|
SD.PropertyService.MainPropertiesContainer, new CSharpFormattingOptionsContainer() { |
|
|
|
SD.PropertyService.MainPropertiesContainer, new CSharpFormattingOptionsContainer() { |
|
|
@ -62,6 +61,15 @@ namespace CSharpBinding.FormattingStrategy |
|
|
|
}); |
|
|
|
}); |
|
|
|
GlobalOptions.FormattingPolicyUpdated += OnFormattingPolicyUpdated; |
|
|
|
GlobalOptions.FormattingPolicyUpdated += OnFormattingPolicyUpdated; |
|
|
|
GlobalOptions.Load(); |
|
|
|
GlobalOptions.Load(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void Initialize() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (initialized) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initialized = true; |
|
|
|
|
|
|
|
projectOptions = new Dictionary<string, CSharpFormattingPolicy>(); |
|
|
|
|
|
|
|
|
|
|
|
// Handlers for solution loading/unloading
|
|
|
|
// Handlers for solution loading/unloading
|
|
|
|
var projectService = SD.GetService<IProjectService>(); |
|
|
|
var projectService = SD.GetService<IProjectService>(); |
|
|
@ -92,8 +100,8 @@ namespace CSharpBinding.FormattingStrategy |
|
|
|
|
|
|
|
|
|
|
|
public CSharpFormattingPolicy GetProjectOptions(IProject project) |
|
|
|
public CSharpFormattingPolicy GetProjectOptions(IProject project) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (projectOptions == null) |
|
|
|
if (!initialized) |
|
|
|
return null; |
|
|
|
return GlobalOptions; |
|
|
|
|
|
|
|
|
|
|
|
var csproject = project as CSharpProject; |
|
|
|
var csproject = project as CSharpProject; |
|
|
|
if (csproject != null) { |
|
|
|
if (csproject != null) { |