C# How to call the delegate method in Consumerbuilder class from Confluent.Kafka library? - confluent-cloud

C# How to class the delegate method in Consumerbuilder class from Confluent.Kafka library?

Related

How to override protected methods of a class of MVCResourceCommand in liferay?

I want to override a protected method in the class ExportArticleMVCResourceCommand which extends theBaseMVCResourceCommand class.
I want to convert journal article's to pdf in liferay 7 . I have written this functionality in its own method and wish to call that method in the doServeResource(...) method. But as doServeResource() is protected, I am not able to call it on a button submit. Therefore, I want to ask how to override this doServeResource() method in liferay 7.
Dissecting the problem
Liferay 7 is an open source Java platform an as such the best way to troubleshoot (absent any documentation) is to first at the code. You will notice that theExportArticleMVCResourceCommand class extends BaseMVCResourceCommand. In the ExportArticleMVCResourceCommand class you can see that the doServeResource method overrides it's parent's doServeResource method. In BaseMVCResourceCommand there are several things to note.
It is an abstract class
There is protected abstract void doServeResource method with no implementation.
The serveResource method simply calls the doServeResource
Piecing it together
So you want to override the doServeResource method in the ExportArticleMVCResourceCommandclass because that method does not work when the "targeted extension" is of type PDF (purportedly). You cannot override the doServeResource by extending or implementing any *MVCResourceCommand class or interface because it's either protected (and your OSGi component override is bundled separately) or in the case of MVCResourceCommand interface it doesn't exist.
Solution
Remember the doServeResource method is simply called by the serveResource method in ExportArticleMVCResourceCommand, and the serveResource method is public in both the MVCResourceCommand interface and BaseMVCResourceCommand class. Therefore to override the doServeResource method you simply need to create your own OSGi component with that appropriate annotations, have it override the serveResource method, and do not the referened serveResource method at the end of your own.
#Component(
property = {
"javax.portlet.name=" + JournalPortletKeys.JOURNAL,
"mvc.command.name=exportArticle"
},
service = MVCResourceCommand.class
public class CustomExportArticleMVCResourceCommand implements MVCResourceCommand {
#Override
public boolean serveResource
(ResourceRequest resourceRequest, ResourceResponse resourceResponse) {
// Call your custom method here
// ExportArticleUtil.sendFile("pdf", resourceRequest, resourceResponse);
}
#Reference(target = "(component.name=com.liferay.journal.web.internal.portlet.action.ExportArticleMVCResourceCommand)")
protected MVCResourceCommand mvcResourceCommand;
}

Reference C++ managed class library from C# class library

How to reference class library from C++ managed? I can reference C++ managed library from another C++ managed library and use classes from it. But when i reference it from C# library it does not provide classes and namespaces from C++ (object browser show classes as well).
C++ Managed Class library1
namespace ns1{
public ref class Class1{};
}
C++ Managed Class library2
using namespace ns1;
namespace ns2{
public ref class class2{
ns1::Class1 _cl;
};
}
And i can not do the same from C# class library.
VS 2010 can not reference C++ managed library from C# as 'Project reference'.
It is necessary to reference .dll file.
Did not you forget public keyword?
Class definition should look like this:
public ref class MyClass
{
}
to be accessible from another assembly.

"Activating a single-threaded class from MTA is not supported" error in from C++ WinRT DLL used in C# application

I have a C# program that uses a C++ WinRT DLL. The C# program creates an instance of a public WinRT class Foo which internally tries to instantiate an object of a second WinRT class Bar that isn't declared public. When calling "ref new" on the Bar class, it throws an exception saying "Activating a single-threaded class from MTA is not supported".
How do I configure the Bar class to that it works in a MTA-style threaded application? Is it a per-class or DLL-wide setting?
It's per-class behavior, controlled by attributes ThreadingModel and MarshallingBehavior. See MSDN for details - Threading and Marshaling.
Usage is like this:
using namespace Windows::Foundation::Metadata;
using namespace Platform;
[Threading(ThreadingModel=ThreadingModel::STA]
[MarshalingBehavior(MarshalingType=MarshalingType::None)]
public ref class MySTAClass
{
};

Java ME class access from another class

Java ME main class runs very well. It has a Form with CustomItem (Button like shape). When it is clicked keyPressed() is called in the CustomItem class. But I need to get information from the main class in the CustomItem class. As the main class is already run hence I can't create new object of the main class in the CustomItem's keyPressed() method. How to get access to the main class's element in the keyPressed() method?
You can do one thing, just pass the object of main class with your next class constructor when you calling that class. You can use your main class object for any purpose. Just pass it with your next class constructor. If you dont understand post code here i will tell you.
Thanks

Using of Base Class and Derived Class and Inheritance

I has a 2 Methods in Base Class(say Method1 and Method2) and having a two derived class (say Derived Class1 and Derived Class2) which are inheriting from Base Class
Now the Derived Class1 will get the two methods of Base Class(Method1 and Method2) But Derived Class2 should get only one method of Base Class(say Method1).
so, can any one suggest how can i proceed in this scenario(i am using C# as a Programming Language)
Thank in Advance!
Declare the two method as virtual in the base class
virtual void Method1()
virtual void Method2()
You could implement Method1 as an extension method and only have it referenced by DerivedClass1.

Resources