Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
VSWIZARD 7.0
Wizard=VsWizard.VsWizardEngine.7.1
Param="WIZARD_NAME = CSharpAddSingleton"
Param="WIZARD_UI = FALSE"
Param="PROJECT_TYPE = CSPROJ"
// CSharp add-in wizard for creating singletons
function OnFinish(selProj, selObj)
{
var oldSuppressUIValue = true;
try
{
var strTarget = wizard.FindSymbol("ITEM_NAME");
var strClassName = strTarget.split(".");
var bValid = wizard.ValidateCLRIdentifier(strClassName[0]);
if (!bValid)
{
wizard.ReportError();
return VS_E_WIZARDBACKBUTTONPRESS;
}
oldSuppressUIValue = dte.SuppressUI;
var strProjectName = wizard.FindSymbol("PROJECT_NAME");
var strSafeProjectName = CreateSafeName(strProjectName);
wizard.AddSymbol("SAFE_PROJECT_NAME", strSafeProjectName);
SetTargetFullPath(selObj);
var strProjectPath = wizard.FindSymbol("TARGET_FULLPATH");
var strTemplatePath = wizard.FindSymbol("TEMPLATES_PATH");
var strTpl = "";
var strName = "";
var InfFile = CreateInfFile();
AddReferencesForClass(selProj);
AddFilesToCSharpProject(selObj, strProjectName, strProjectPath, InfFile, true);
}
catch(e)
{
if( e.description.length > 0 )
SetErrorInfo(e);
return e.number;
}
finally
{
dte.SuppressUI = oldSuppressUIValue;
if( InfFile )
InfFile.Delete();
}
}
function SetFileProperties(oFileItem, strFileName)
{
}
using System;
namespace [!output SAFE_NAMESPACE_NAME]
{
/// <summary>
/// Summary description for [!output SAFE_CLASS_NAME].
/// </summary>
public sealed class [!output SAFE_CLASS_NAME]
{
static readonly [!output SAFE_CLASS_NAME] _instance = new [!output SAFE_CLASS_NAME]();
// Explicit static constructor to tell C# compiler
// not to mark type as beforefieldinit
static [!output SAFE_CLASS_NAME]()
{
}
[!output SAFE_CLASS_NAME]()
{
}
public static [!output SAFE_CLASS_NAME] Instance
{
get
{
return _instance;
}
}
}
}
NewCSSingleton.cs
..\CSharpAddSingleton.vsz|{FAE04EC1-301F-11D3-BF4B-00C04F79EFBC}|C# Singleton Class|0|A Singleton class|{FAE04EC1-301F-11D3-BF4B-00C04F79EFBC}|4534|0|Singleton.cs