From b7b8ea8d97c612e6169cf09864145736cdbf46b7 Mon Sep 17 00:00:00 2001 From: slace Date: Sun, 21 Jun 2009 06:53:58 +0000 Subject: [PATCH] DO NOT DOWNLOAD. DOWNLOAD LATEST STABLE FROM RELEASE TAB Fixing missing file from VSSDK [TFS Changeset #55206] --- .../DTMetal.CodeBuilder.csproj | 5 +- .../CodeGeneratorRegistrationAttribute.cs | 158 ++++++++++++++++++ 2 files changed, 159 insertions(+), 4 deletions(-) create mode 100644 LinqToUmbraco/src/umbraco.Linq/DTMetal.CodeBuilder/RegistrationAttributes/CodeGeneratorRegistrationAttribute.cs diff --git a/LinqToUmbraco/src/umbraco.Linq/DTMetal.CodeBuilder/DTMetal.CodeBuilder.csproj b/LinqToUmbraco/src/umbraco.Linq/DTMetal.CodeBuilder/DTMetal.CodeBuilder.csproj index 6e11fd0a15..b12e830319 100644 --- a/LinqToUmbraco/src/umbraco.Linq/DTMetal.CodeBuilder/DTMetal.CodeBuilder.csproj +++ b/LinqToUmbraco/src/umbraco.Linq/DTMetal.CodeBuilder/DTMetal.CodeBuilder.csproj @@ -83,10 +83,6 @@ - - RegistrationAttributes\CodeGeneratorRegistrationAttribute.cs - true - @@ -104,6 +100,7 @@ InstallerProgress.cs + True True diff --git a/LinqToUmbraco/src/umbraco.Linq/DTMetal.CodeBuilder/RegistrationAttributes/CodeGeneratorRegistrationAttribute.cs b/LinqToUmbraco/src/umbraco.Linq/DTMetal.CodeBuilder/RegistrationAttributes/CodeGeneratorRegistrationAttribute.cs new file mode 100644 index 0000000000..1ae8830d41 --- /dev/null +++ b/LinqToUmbraco/src/umbraco.Linq/DTMetal.CodeBuilder/RegistrationAttributes/CodeGeneratorRegistrationAttribute.cs @@ -0,0 +1,158 @@ +/*************************************************************************** + +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; + +namespace Microsoft.VisualStudio.Shell +{ + /// + /// This attribute adds a custom file generator registry entry for specific file + /// type. + /// For Example: + /// [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Generators\ + /// {fae04ec1-301f-11d3-bf4b-00c04f79efbc}\MyGenerator] + /// "CLSID"="{AAAA53CC-3D4F-40a2-BD4D-4F3419755476}" + /// "GeneratesDesignTimeSource" = d'1' + /// + /// + [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)] + public sealed class CodeGeneratorRegistrationAttribute : RegistrationAttribute + { + private string _contextGuid; + private Type _generatorType; + private Guid _generatorGuid; + private string _generatorName; + private string _generatorRegKeyName; + private bool _generatesDesignTimeSource = false; + private bool _generatesSharedDesignTimeSource = false; + /// + /// Creates a new CodeGeneratorRegistrationAttribute attribute to register a custom + /// code generator for the provided context. + /// + /// The type of Code generator. Type that implements IVsSingleFileGenerator + /// The generator name + /// The context GUID this code generator would appear under. + public CodeGeneratorRegistrationAttribute(Type generatorType, string generatorName, string contextGuid) + { + if (generatorType == null) + throw new ArgumentNullException("generatorType"); + if (generatorName == null) + throw new ArgumentNullException("generatorName"); + if (contextGuid == null) + throw new ArgumentNullException("contextGuid"); + + _contextGuid = contextGuid; + _generatorType = generatorType; + _generatorName = generatorName; + _generatorRegKeyName = generatorType.Name; + _generatorGuid = generatorType.GUID; + } + + /// + /// Get the generator Type + /// + public Type GeneratorType + { + get { return _generatorType; } + } + + /// + /// Get the Guid representing the project type + /// + public string ContextGuid + { + get { return _contextGuid; } + } + + /// + /// Get the Guid representing the generator type + /// + public Guid GeneratorGuid + { + get { return _generatorGuid; } + } + + /// + /// Get or Set the GeneratesDesignTimeSource value + /// + public bool GeneratesDesignTimeSource + { + get { return _generatesDesignTimeSource; } + set { _generatesDesignTimeSource = value; } + } + + /// + /// Get or Set the GeneratesSharedDesignTimeSource value + /// + public bool GeneratesSharedDesignTimeSource + { + get { return _generatesSharedDesignTimeSource; } + set { _generatesSharedDesignTimeSource = value; } + } + + + /// + /// Gets the Generator name + /// + public string GeneratorName + { + get { return _generatorName; } + } + + /// + /// Gets the Generator reg key name under + /// + public string GeneratorRegKeyName + { + get { return _generatorRegKeyName; } + set { _generatorRegKeyName = value; } + } + + /// + /// Property that gets the generator base key name + /// + private string GeneratorRegKey + { + get { return string.Format(CultureInfo.InvariantCulture, @"Generators\{0}\{1}", ContextGuid, GeneratorRegKeyName); } + } + /// + /// Called to register this attribute with the given context. The context + /// contains the location where the registration inforomation should be placed. + /// It also contains other information such as the type being registered and path information. + /// + public override void Register(RegistrationContext context) + { + using (Key childKey = context.CreateKey(GeneratorRegKey)) + { + childKey.SetValue(string.Empty, GeneratorName); + childKey.SetValue("CLSID", GeneratorGuid.ToString("B")); + + if (GeneratesDesignTimeSource) + childKey.SetValue("GeneratesDesignTimeSource", 1); + + if (GeneratesSharedDesignTimeSource) + childKey.SetValue("GeneratesSharedDesignTimeSource", 1); + + } + + } + + /// + /// Unregister this file extension. + /// + /// + public override void Unregister(RegistrationContext context) + { + context.RemoveKey(GeneratorRegKey); + } + } +}