Does Spring Data Couchbase support Inheritance - spring-data-couchbase

Clicking around the documentation for Spring Data Couchbase I can't find any suggestion that #Document's can extend other #Documents? Is this possible, and if so, how can it be done?
For example:
#Document
class A {...}
#Document
class B extends A {...}

Related

How to pass an object from one page component to another page component in a .NET Blazor app?

I have a .NET Blazor Server app and need to pass an object from one component to another. Both components are pages, meaning that they have #page directives with routes. I know how to use cascading values to pass a parameter between regular Blazor components, but this does not work with page components. I also know how to pass a parameter within an endpoint route. However, instead of a string or int I want to pass an object with multiple properties and am unsure how to best accomplish this.
Is it possible to pass an object as an endpoint route parameter? If not, what is a good way to accomplish this within a Razor components context?
Using dependency injection would likely solve this issue for you.
Example:
Create a class called "ApplicationService"
Create an interface in that class called "IApplicationService"
You could have something like this
public interface IApplicationService
{
public Task MsgBox(string value);
}
In the ApplicationService class inside the "ApplicationService.cs" file, go ahead and implement the interface member above.
You could have something like this:
public async Task MsgBox(string value)
{
await _JSRuntime.InvokeAsync<string>("alert", value);
}
In the program.cs class, you need to now register that "service" we just created.
You could have something like this
builder.Services.AddTransient<IApplicationService, ApplicationService>();
builder.Services.AddScoped<ApplicationService>();
In your _Imports.razor you can inject the class so that the pages have access to it:
#inject ApplicationService MainAppService;
Now in your razor components you should be able to do something like this:
await MainAppService.MsgBox("This is a message box");
This works in my WASM blazor app, hope it sheds some light on the server side of things 🚀
Use a DI service. Create a class to hold your object. Add it as a Scoped Service in Program. Use it in any component (pages are just components with a page attribute) though #inject.

What's the base class of a Razor View in ASP.NET MVC3

I'm trying to have all my views inherit from a custom class so that I can add certain behaviour and values to all pages, but I'm having some issues. I tried subclassing System.Web.Mvc.WebViewPage but I'm forced to implement an Execute procedure that I don't know what it should do. Also, if I try to access the Context variable, I get a null reference (really weird). This leads me to think that I may have the wrong base class....
Any thoughts?
Diego, System.Web.Mvc.WebViewPage is the right base type (and you should have another class inheriting from System.Web.Mvc.WebViewPage<TModel> if you want strongly-typed views). You should mark your own class as abstract so that you are not forced to implement the Execute method.
Update: To configure all your views to use your custom base class, look into the ~\Views\Web.config file. Inside of it there's a Razor-specific section where you can use the pageBaseType attribute to configure your custom type.
As far as the Context property is concerned, it should be fully initialized once the view is executing. However, it might not be available if you try to access it too early (for example, from your classes constructor). When are you trying to access it?
The Execute method is something that is provided by the Razor compiler when your view is compiled. For example, given the following view file
Hello #Name!
The Razor compiler will behind the scenes generate the following class (this is a simplification, so the details might be off, but it should convey the point)
public class _Some_Generated_Class_Name_ : System.Web.Mvc.WebViewPage {
public void Execute() {
Write("Hello ");
Write(Name);
Write("!");
}
}
Then the framework calls the Execute method on your view class and your view gets executed.

can we inherit more then on class in asp.net aspx page?

I want to inherit more than one class is there any method?
For instance in login.aspx page:
<%# page language="c#" codefile="nishant.aspx.cs" autowireup="true" inherit="nishant"%>
now code behind file
nishant.aspx.cs:
class nishant
{
//code...
}
class bill
{
//code.....
}
Now, I want to inherit bill class then how I will ?
.NET does not support multiple inheritance, this includes asp.net, so no, this is not possible.
You can have your nishant class inherit from the bill class or the other way around, if you want to share functionality. You page can then inherit from the inheriting class and access the functionality of both.
Another option is to inherit from one class and implement an interface (or several interfaces), but the fact that you can implement more than one interface is not the same as multiple inheritance.
There are other things that can be done, depending on what exactly you are trying to achieve (I am primarily thinking about composition versus inheritance).
Multiple inheritance is not allowed. The only way is:
public class Bill : Page
{ }
public class Nishant : Bill
{ }
But rather you should think about your design. Such approach is usually not needed.
No. By nature, .Net allows only single inheritance. At best you could implement an interface, but you will still have to have the code in your nishant class or extract the functionality into your bill class and make function calls.
Although in the case you mention, this is not actually multiple inheritance. Your nishant class must be of type System.Web.UI.Page. So if you create a library with a "bill class", you can then inherit it.
public class bill : System.Web.UI.Page
{
// Your custom code
}
///
public class nishant : bill
{
}
.NET does not support multiple inheritance (one class that inherit from two or more classes).
However you can have as many parent class as you want. Have a look at the decorator pattern.
Or use interfaces, you can have more than one.
In short: implement interfaces and use extension methods
Implementing interfaces might be the way to go, really depends on the functionality you want to inherit.
You can read about inheritance and interfaces here: http://msdn.microsoft.com/en-us/library/ms973861.aspx
When you implement interfaces, but don't want to duplicate the same code into every class that implements a certain interface, you can also write extension methods for the interfaces. Read more about extension methods here: http://msdn.microsoft.com/en-us/library/bb384936.aspx

How to hack private static field in Flex?

Is there a way to change private static field of an alien class?
For example:
package mx.managers {
public class TooltipManager ... {
private static var _impl:IToolTipManager2; // <- assign my own value here
...
}
}
In Java it is possible to do it using Reflection API. What about Flex?
No, that is not possible.
If you are looking into changing the implementation of the TooltipManager, have a look at the Singleton class in the Flex SDK. You'll need to create a custom implementation and register it via the Singleton class before the application initializes. The best is to override the application preloader and do the registration there.
Well, if you feel like you can handle the extra responsibility, you can monkey patch the class by copying the source into your own source tree with the same package and apply the necessary modifications. That way the flex compiler will use your implementation rather than the SDK implementation.
This technique is sometimes used as a last resort to fix issues which cannot be fixed otherwise. Drawbacks include issues such as forwards compatibility and unintended side effects in the same or other classes dependant on the class your editing.

Mate PropertyInjectors - Inject to as3 class?

Does anyone know if it is possible to inject into a regular as3 (non mxml) class? I've tried with limited success.
Thanks
Could you be more specific? There's no difference between an "MXML" class and a class defined in ActionScript, it's just different ways of writing the same thing.
All that is needed for injection to work is a source property that is bindable and a destination property that is public (either a public setter or a public instance variable). If those two requirements are met and the code compiles it should work.
Look at the code for the example application you can find here: http://code.google.com/p/mate-examples/wiki/DocumentBasedExampleIntro and you will find a ton of injectors that target classes not defined using MXML (look for injectors targeting classes whose names end in "Model" especially). You can also find countless examples in the Mate forums.

Resources