how to make a service component with Event(sink)

L

lightdoll

hello everyone.

i want to make a service component with Event,

the event will be used in C++, C, VB.

but i don't know how to make a service compnent with Event, and to use the
componet in C++, C, VB.

i want to append a event function below Source Code.

Best regards.
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
[Guid("4b3b9bfe-304b-4a5c-ad7f-a1472fdcd41f")]
public interface ISingleton
{
int Foo();
bool Variant(object VarData);

}


[JustInTimeActivation]
[ObjectPooling(Enabled=true, MinPoolSize=1, MaxPoolSize=1,
CreationTimeout=5000)]
[Guid("e57cd005-f67e-44a0-99e4-9c1032c4420a")]
[ProgId("SomeOnes.Singleton")]
[ComVisible(true)]
public sealed class Singleton : ServicedComponent, ISingleton
{

public Singleton () {}
public int Foo()
{
return SingleInstance.instance.GetFoo();
}

public bool Variant(object VarData)
{
return SingleInstance.instance.Variant(VarData);

}
}

public sealed class SingleInstance
{
int i;
public static readonly SingleInstance instance = new
SingleInstance();
public SingleInstance(){}
public int GetFoo()
{
return ++i;
}

public bool Variant(object VarData)
{
/* int nTest;

string[] strTest = new string[3];
nTest = (int)((object[])(VarData))[0];
strTest[0] = (string)((object[])(VarData))[1];
strTest[1] = (string)((object[])(VarData))[2];
strTest[2] = (string)((object[])(VarData))[3];
Console.WriteLine("{0}, {1}, {2}, {3}", nTest, strTest[0],
strTest[1], strTest[2], strTest[3]);*/

// Console.WriteLine("{0}", (string)((object[])(VarData))[0]);
// MessageBox.Show((string)((object[])(VarData))[0]);
System.Diagnostics.Debugger.Break();
return true;
}
 
W

Willy Denoyette [MVP]

lightdoll said:
hello everyone.

i want to make a service component with Event,

the event will be used in C++, C, VB.

but i don't know how to make a service compnent with Event, and to use the
componet in C++, C, VB.

i want to append a event function below Source Code.

Best regards.
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
[Guid("4b3b9bfe-304b-4a5c-ad7f-a1472fdcd41f")]
public interface ISingleton
{
int Foo();
bool Variant(object VarData);

}


[JustInTimeActivation]
[ObjectPooling(Enabled=true, MinPoolSize=1, MaxPoolSize=1,
CreationTimeout=5000)]
[Guid("e57cd005-f67e-44a0-99e4-9c1032c4420a")]
[ProgId("SomeOnes.Singleton")]
[ComVisible(true)]
public sealed class Singleton : ServicedComponent, ISingleton
{

public Singleton () {}
public int Foo()
{
return SingleInstance.instance.GetFoo();
}

public bool Variant(object VarData)
{
return SingleInstance.instance.Variant(VarData);

}
}

public sealed class SingleInstance
{
int i;
public static readonly SingleInstance instance = new
SingleInstance();
public SingleInstance(){}
public int GetFoo()
{
return ++i;
}

public bool Variant(object VarData)
{
/* int nTest;

string[] strTest = new string[3];
nTest = (int)((object[])(VarData))[0];
strTest[0] = (string)((object[])(VarData))[1];
strTest[1] = (string)((object[])(VarData))[2];
strTest[2] = (string)((object[])(VarData))[3];
Console.WriteLine("{0}, {1}, {2}, {3}", nTest, strTest[0],
strTest[1], strTest[2], strTest[3]);*/

// Console.WriteLine("{0}",
(string)((object[])(VarData))[0]);
// MessageBox.Show((string)((object[])(VarData))[0]);
System.Diagnostics.Debugger.Break();
return true;
}



Search the MSDN docs for LCE (Loosely Coupled Events) and the
EventClassAttribute in the .NET docs.

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top