using System; using System.Collections.Generic; using System.Runtime.CompilerServices; using Microsoft.VisualStudio.ProjectSystem; using VSPropertyPages; namespace Cosmos.VS.ProjectSystem.VS.PropertyPages.ViewModels { internal class CosmosPropertyPageViewModel : PropertyPageViewModel { #region Static Items private static readonly List DebugComItemsList = new List() { 1, 2, 3, 4 }; private static readonly Dictionary DebugModeItemsDictionary = new Dictionary() { ["IL"] = "IL", ["Source"] = "Source" }; private static readonly Dictionary TraceModeItemsDictionary = new Dictionary() { ["None"] = "None", ["User"] = "User", ["Cosmos"] = "Cosmos", ["All"] = "All" }; private static readonly Dictionary StackCorruptionDetectionLevelItemsDictionary = new Dictionary() { ["AllInstructions"] = "All Instructions", ["MethodFooters"] = "Method Footers" }; #endregion public bool DebugEnabled { get => String.Equals(GetProperty(nameof(DebugEnabled)), "True", StringComparison.OrdinalIgnoreCase); set => SetProperty(nameof(DebugEnabled), value.ToString(), nameof(DebugEnabled)); } public List DebugComItems => DebugComItemsList; public int DebugCom { get => Int32.Parse(GetProperty(nameof(DebugCom))); set => SetProperty(nameof(DebugCom), value.ToString()); } public Dictionary DebugModeItems => DebugModeItemsDictionary; public string DebugMode { get => GetProperty(nameof(DebugMode)); set => SetProperty(nameof(DebugMode), value); } public Dictionary TraceModeItems => TraceModeItemsDictionary; public string TraceMode { get => GetProperty(nameof(TraceMode)); set => SetProperty(nameof(TraceMode), value); } public bool IgnoreDebugStubAttribute { get => String.Equals(GetProperty(nameof(IgnoreDebugStubAttribute)), "True", StringComparison.OrdinalIgnoreCase); set => SetProperty(nameof(IgnoreDebugStubAttribute), value.ToString(), nameof(IgnoreDebugStubAttribute)); } public bool StackCorruptionDetectionEnabled { get => String.Equals(GetProperty(nameof(StackCorruptionDetectionEnabled)), "True", StringComparison.OrdinalIgnoreCase); set => SetProperty(nameof(StackCorruptionDetectionEnabled), value.ToString(), nameof(StackCorruptionDetectionEnabled)); } public Dictionary StackCorruptionDetectionLevelItems => StackCorruptionDetectionLevelItemsDictionary; public string StackCorruptionDetectionLevel { get => GetProperty(nameof(StackCorruptionDetectionLevel)); set => SetProperty(nameof(StackCorruptionDetectionLevel), value); } public string CosmosDebugPort { get => GetProperty(nameof(CosmosDebugPort)); set => SetProperty(nameof(CosmosDebugPort), value); } public string VisualStudioDebugPort { get => GetProperty(nameof(VisualStudioDebugPort)); set => SetProperty(nameof(VisualStudioDebugPort), value); } public CosmosPropertyPageViewModel( IPropertyManager propertyManager, IProjectThreadingService projectThreadingService) : base(propertyManager, projectThreadingService) { } private void SetAndRaiseIfChanged(ref T field, T value, [CallerMemberName] string propertyName = null) { if (!EqualityComparer.Default.Equals(field, value)) { field = value; OnPropertyChanged(propertyName); } } } }