-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathExtensions.cs
More file actions
88 lines (77 loc) · 3.36 KB
/
Copy pathExtensions.cs
File metadata and controls
88 lines (77 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EnvDTE;
using EnvDTE80;
using Microsoft.VisualStudio.Settings;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Settings;
using NuGet.VisualStudio;
namespace ServiceStackVS.Common
{
public static class NuGetCoreExtensions
{
public static string GetLatestVersionOfPackage(this IVsPackageRestorer packageRepository, string packageId)
{
var package = packageRepository.GetLatestVersionOfPackage(packageId);
return package;
}
}
public static class WizardHelpers
{
public static string GetTemplateNameFromPath(string vsTemplatePath)
{
string result = "";
int lastBackSlashIndex = vsTemplatePath.LastIndexOf("\\", StringComparison.Ordinal);
int dotVsTemplateIndex = vsTemplatePath.IndexOf(".vstemplate", StringComparison.Ordinal);
result = vsTemplatePath.Substring(lastBackSlashIndex + 1, dotVsTemplateIndex - lastBackSlashIndex - 1);
return result;
}
}
public static class SettingsStorage
{
public const string CategoryName = "ServiceStack";
public const string PageName = "General";
public const string OptOutPropertyName = "OptOutStats";
public const string PackageSettingsCategory = "ServiceStackSettings";
public const string PackageReadyPropertyName = "PackageReady";
public static bool GetOptOutStatsSetting(this DTE2 dte)
{
var props = dte?.get_Properties(CategoryName, PageName);
return props?.Item(OptOutPropertyName)?.Value is bool b && b;
}
public static bool GetOptOutStatsSetting(this SVsServiceProvider vsServiceProvider)
{
var shellSettingsManager = new ShellSettingsManager(vsServiceProvider);
return shellSettingsManager.GetReadOnlySettingsStore(SettingsScope.UserSettings).GetBoolean(CategoryName, OptOutPropertyName);
}
public static WritableSettingsStore GetWritableSettingsStore(this SVsServiceProvider vsServiceProvider)
{
var shellSettingsManager = new ShellSettingsManager(vsServiceProvider);
return shellSettingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);
}
public static void InitWritableSettings(this WritableSettingsStore settingsStore)
{
if (!settingsStore.CollectionExists(PackageSettingsCategory))
{
settingsStore.CreateCollection(PackageSettingsCategory);
}
if (!settingsStore.PropertyExists(PackageSettingsCategory, PackageReadyPropertyName))
{
settingsStore.SetBoolean(PackageSettingsCategory,PackageReadyPropertyName,false);
}
}
public static void SetPackageReady(this WritableSettingsStore settingsStore, bool value)
{
settingsStore.InitWritableSettings();
settingsStore.SetBoolean(PackageSettingsCategory,PackageReadyPropertyName, value);
}
public static bool GetPackageReady(this WritableSettingsStore settingsStore)
{
settingsStore.InitWritableSettings();
return settingsStore.GetBoolean(PackageSettingsCategory, PackageReadyPropertyName);
}
}
}