/***************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
This code is licensed under the Visual Studio SDK license terms.
THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
***************************************************************************/
using System;
using System.Globalization;
using Microsoft.VisualStudio.Shell;
namespace BruSoft.VS2P4
{
/// <summary>
/// This file contains the implementation of a custom registration attribute that declares the key used by the package to persist solution properties.
/// When encountering a solution containing this key, the IDE will know which package it has to call to read that block of solution properties.
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
internal sealed class ProvideSolutionProps : RegistrationAttribute
{
private string _propName;
public ProvideSolutionProps(string propName)
{
_propName = propName;
}
public override void Register(RegistrationContext context)
{
context.Log.WriteLine(string.Format(CultureInfo.InvariantCulture, "ProvideSolutionProps: ({0} = {1})", context.ComponentType.GUID.ToString("B"), PropName));
Key childKey = null;
try
{
childKey = context.CreateKey(string.Format(CultureInfo.InvariantCulture, "{0}\\{1}", "SolutionPersistence", PropName));
childKey.SetValue(string.Empty, context.ComponentType.GUID.ToString("B"));
}
finally
{
if (childKey != null) childKey.Close();
}
}
public override void Unregister(RegistrationContext context)
{
context.RemoveKey(string.Format(CultureInfo.InvariantCulture, "{0}\\{1}", "SolutionPersistence", PropName));
}
public string PropName { get { return _propName; } }
}
}