Ok, since delegate dosen't support multi-type input or atlast as i searched in internet, i solved this with Generics, so:
i define a delegate as
public delegate byte[] EncryptMethod<t>(byte[] PlainToEnc, T t);</t>
which T is and entity class for the parameters
next i defaine my method as this:
public static void WriteSerialize<T,E>(T entity, EncryptMethod<E> encryptMethod, E e, string fileAddress)
{
so in here T is the entity that u dont need to care about, it's just my data which will processing within my method, so u can remove it, if u dont have any entity data class,
but the 'E'
is Important, cause it's the Type we defined for out delegate in top,
so to provide a delegate that accept different values, you have to provide unknown type <t> (in here E) after you write your method name, like
WriteSerialize<e> (...)</e>
and then as parameter, you need to pass That unknown type again to the delegate...., also you need to provide an object from that type
Like :
(EncryptMethod<e> encryptMethod, E e)</e>
no one more step you have for implement this fully:
inside the method when u wanan call the delegate you write :
encryptMethod.Invoke(e)
so u can pass any unknow input parameter to any delegate method...
after this the user who want to implement the delegate method have to go through this way:
1. he need to define all parameter which he need to change in his method.
like for DES encryption:
public static byte[] Encrypt(byte[] plainData, string sKey, string iv, CipherMode cm, PaddingMode pm)
{
2. next the user need to define a class which contain all the input parameter, with public access to members, or public property with get attribute.
3. he use this class as input type for his method, the way he define his delegate
and call his method, within this method, and pass parameters to the method , he define in step 1.
like:
public static byte[] Encrypt(byte[] PlainToEnc, DESParametersContainer DESPC)
{
return Encrypt(PlainToEnc, DESPC.SKey, DESPC.IV, DESPC.Cipher, DESPC.Padding);
}
in here
DESParametersContainer
the class i defined
4. there's nothing left, jsut user have to call your method, with his method and instance of parameter data class.
SerializeEncrypter.WriteSerialize<MyEntity, DESParametersContainer>(new MyEntity("a", "b", "c"), DESSymmetric.Encrypt, despc, DIR.GetCurrentDirectory() + fileName1);