public interface A
{
void print();
}
public class B : A
{
void A.print()
{
Console.WriteLine("B");
}
}
public class C : A
{
void A.print()
{
Console.WriteLine("C");
}
}
public class MyClass
{
public static void Main()
{
A a = new C();
Console.WriteLine("#: " + a.GetType().Name);
a.print();
RL();
}
}
Blogs on .NET and LAMP Technologies
There's often more than one correct thing.
There's often more than one right thing.
There's often more than one obvious thing.
--Larry Wall
Wednesday, March 28, 2007
Getting correct object type
Tuesday, March 27, 2007
SMTP Managed Event Sink for scanning incoming emails
I want to scan all incoming mails using Managed Event sink. I am implementing IMailTransportSubmission Interface.
void IMailTransportSubmission.OnMessageSubmission(
MailMsg message,
IMailTransportNotify notify,
IntPtr context)
{
try
{
// Fill details of the Message in database
FillData(message);
}
catch (Exception ex)
{
EventLog.WriteEntry(
Assembly.GetExecutingAssembly().FullName,
ex.Message + "\n" + ex.StackTrace.ToString(),
EventLogEntryType.Error);
}
finally
{
if (null != message)
Marshal.ReleaseComObject(message);
}
}
I am using following command to bind the event sink:
cscript smtpreg.vbs /add 1 OnTransportSubmission "MyEventSink.ManagedSink" MyEventSink.ManagedSink.Sink "MAIL FROM=*" 28001
I have a development exchange server. When I put a message in “pickup” directory, a entry for this message is inserted into database. That means my event sink working fine, but I am not sure how to test it for incoming message as this development exchange doesn’t have dns entries and I have to check event sink functionality for incoming mail from same development server somehow. First thing I want to know that whether I have implemented correct interface for scanning incoming mails. Two, whether I have registered correct event for incoming mails.
Tuesday, March 06, 2007
SharePoint Versioning Algorithm
int majorVersion = 0;
int maxMajorVersion = 2;
int maxMinorVersion = 20; // default 511;
string version = string.Empty;
int counter = 1;
int id = 1;
int maxId = 512 * maxMajorVersion;
List<int> lstNxtVersionIds = new List<int>();
for (int i = 1; i <= maxMajorVersion; i++)
lstNxtVersionIds.Add(i*512);
for (int i = 1; i<=maxId & id<=maxId; i++)
{
if (counter == maxMinorVersion)
{
version = majorVersion.ToString() + "." + counter.ToString();
Console.WriteLine ("id {0}, version {1}", id, version);
if (majorVersion < maxMajorVersion)
{
majorVersion++;
foreach (int nxtVersionId in lstNxtVersionIds)
{
if (id < nxtVersionId)
{
id = nxtVersionId;
break;
}
}
}
else if (majorVersion == maxMajorVersion)
break;
counter = 0;
}
version = majorVersion.ToString() + "." + counter.ToString();
Console.WriteLine ("id {0}, version {1}", id, version);
id++;
counter++;