This repository has been archived by the owner on Oct 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 111
/
Copy pathProvideProjectFileGeneratorAttribute.cs
45 lines (38 loc) · 1.88 KB
/
ProvideProjectFileGeneratorAttribute.cs
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
using System;
using Microsoft.VisualStudio.Shell;
namespace Microsoft.VisualStudio.ProjectSystem.FileSystemMirroring.Package.Registration {
public sealed class ProvideProjectFileGeneratorAttribute : RegistrationAttribute {
public Type GeneratorType { get; }
public string FileNames { get; set; }
public string FileExtensions { get; set; }
public string[] PossibleGeneratedProjectTypes { get; }
private int? _displayGeneratorFilter;
public int DisplayGeneratorFilter {
get { return _displayGeneratorFilter ?? 0; }
set { _displayGeneratorFilter = value; }
}
public ProvideProjectFileGeneratorAttribute(Type projectFileGeneratorType, params string[] possibleGeneratedProjectTypes) {
GeneratorType = projectFileGeneratorType;
PossibleGeneratedProjectTypes = possibleGeneratedProjectTypes;
}
public override void Register(RegistrationContext context) {
Build().Register(context);
}
public override void Unregister(RegistrationContext context) {
Build().Unregister(context);
}
private RegistrationAttributeBuilder Build() {
var builder = new RegistrationAttributeBuilder();
builder.Key("ProjectGenerators")
.GuidSubKey(GeneratorType)
.PackageGuidValue("Package")
.StringValue("FileNames", FileNames)
.StringValue("FileExtensions", FileExtensions)
.ResourceIdValue("DisplayGeneratorFilter", DisplayGeneratorFilter)
.GuidArrayValue("PossibleGeneratedProjectTypes", PossibleGeneratedProjectTypes);
return builder;
}
}
}