public override int GetFile(int fileId, uint flags, out uint itemid, out string fileName)
{
const string propertiesFolderPath = "Properties\\";
HierarchyNode propertiesNode = FindChildEx(this, "Properties");
if (propertiesNode == null)
propertiesNode = CreateFolderNode("Properties");
HierarchyNode parent = this;
switch (fileId)
{
case (int)__PSFFILEID.PSFFILEID_AppConfig:
fileName = "app.config";
break;
case (int)__PSFFILEID.PSFFILEID_Licenses:
fileName = "licenses.licx";
break;
case (int)__PSFFILEID2.PSFFILEID_WebSettings:
fileName = "web.config";
break;
case (int)__PSFFILEID2.PSFFILEID_AppManifest:
fileName = "app.manifest";
break;
case (int)__PSFFILEID2.PSFFILEID_AppSettings:
fileName = propertiesFolderPath + "Settings.settings";
break;
case (int)__PSFFILEID2.PSFFILEID_AssemblyResource:
fileName = propertiesFolderPath + "Resources.resx";
break;
case (int)__PSFFILEID2.PSFFILEID_AssemblyInfo:
fileName = propertiesFolderPath + "AssemblyInfo.cs";
break;
default:
return base.GetFile(fileId, flags, out itemid, out fileName);
}
if (fileName.StartsWith(propertiesFolderPath, StringComparison.InvariantCulture))
parent = propertiesNode;
HierarchyNode fileNode = FindChildEx(parent, Path.GetFileName(fileName));
string fullPath = fileNode == null
? Path.Combine(ProjectFolder, fileName)
: fileNode.Url;
if (fileNode == null && (flags & (uint)__PSFFLAGS.PSFF_CreateIfNotExist) != 0)
{
// Create a zero-length file if not exist already.
//
if (!File.Exists(fullPath))
File.WriteAllText(fullPath, string.Empty);
fileNode = CreateFileNode(fileName);
parent.AddChild(fileNode);
}
itemid = fileNode != null ? fileNode.ID : 0;
if ((flags & (uint)__PSFFLAGS.PSFF_FullPath) != 0)
fileName = fullPath;
return VSConstants.S_OK;
}