After some Googling I found this: Use a Visual Studio Macro to Insert Copyright Headers into Source Files. It looked promising:
//
You could create a new snippet and just type cp + double tab to insert the notice where you want (needless to say you can change the keyword to whatever you want).
The only problem with it is, from what I'm aware, snippets do not support time functions, so getting the current time for your date line seems impossible with this technique. A not so good workaround for this is to make the time fields editable (similar to how the mbox snippet works) and just insert the time manually.
Here's an example on how a snippet looks. The bellow snippet will get the class name automatically and insert the copyright notice in the place where you type 'copyright' and double tab.
Method 1
Copyright
Copyright
Code snippet for Copyright notice
author name
Expansion
classname
ClassName()
// Copyright (c) 2012 All Rights Reserved
// Leniel Macaferi
//
]]>
Method 2
Also, here's an example of a program you can make to do that for you.
List files = new List()
{
"c:\\Form1.cs",
"c:\\Form2.cs",
};
foreach (string file in files)
{
string tempFile = Path.GetFullPath(file) + ".tmp";
using (StreamReader reader = new StreamReader(file))
{
using (StreamWriter writer = new StreamWriter(tempFile))
{
writer.WriteLine(@"//
// Copyright (c) 2012 All Rights Reserved
//
// Leniel Macaferi
// " + DateTime.Now + @"
// Class representing a Sample entity
");
string line = string.Empty;
while ((line = reader.ReadLine()) != null)
{
writer.WriteLine(line);
}
}
}
File.Delete(file);
File.Move(tempFile, file);
}
Some error catching will be required of course. But this should give you the general idea how to construct an UI around it an add the files you will want to process.
Method 3
It's also possible to change the template for your classes that can be usually be found under:
C:\Program Files (x86)\Microsoft Visual Studio \Common7\IDE\ItemTemplates\CSharp\1033\
Sometimes editing ItemTemplatesCache is also necessary to display the results.
Here's an example template based on your question:
using System;
using System.Collections.Generic;
$if$ ($targetframeworkversion$ >= 3.5)using System.Linq;
$endif$using System.Text;
/*
Copyright (c) 2012 All Rights Reserved
Leniel Macaferi
$time$
Class representing a Sample entity */
namespace $rootnamespace$
{
class $safeitemrootname$
{
}
}