interface

what will happen if fields with same name inherites from two sources(class and interface)

拜拜、爱过 提交于 2020-01-06 08:42:03
问题 valid code: interface Int1{ String str = "123"; } class Pparent{ String str = "123"; } class F extends Pparent implements Int1{ } invalid code add main method to F class: class F extends Pparent implements Int1{ public static void main(String[] args) { System.out.println(str); } } outs Exception in thread "main" java.lang.Error: Unresolved compilation problem: The field str is ambiguous at test.core.F.main(NullReferenceTest.java:45) I don't see striking differs beetwen both variants. I

phpunit error when testing an implementation with injected dependencies

梦想与她 提交于 2020-01-06 06:53:23
问题 I am trying to set up a phpunit test on a class I have built called EloquentListing which implements an interface called ListingInterface . The constructor for the EloquentListing model requires an Eloquent Model to be injected. As such I am using a service provider to bind the implementation to the interface and inject the model called RepoServiceProvider . However, I am getting the following error when I run phpunit: .PHP Fatal error: Cannot instantiate interface PlaneSaleing\Repo\Listing

Problems with an NHibernate LINQ query in loosely coupled project

北战南征 提交于 2020-01-06 03:39:06
问题 hope you can help! I've started a project in MVC 3 and set the business domain model in another assembly, the interfaces define the contract between this assembly and all projects that will use it. I'm using Ninject to inject the dependencies into the project. I've hit a brick wall at the moment with a specific LINQ query. public IEnumerable<ITheInterface> DoMyQuery() { using (ISession session = _sessionFactory.OpenSession()) { var query = ( from c in session.Query<IMyInterface>() where

Creating interface objects in java

爱⌒轻易说出口 提交于 2020-01-06 02:33:11
问题 I encountered some Java code: public class LocationProvider { public interface LocationCallback { public void handleNewLocation(Location location); } // class constructor public LocationProvider(Context context, LocationCallback callback){ ... } } For the first time in Java, I am encountering a constructor or method with an argument of a "type" that is an interface. Is it possible to create objects of interfaces ? Can you use them like regular objects ? In C++ I know it's not possible to

How does SelectedListViewItemCollection implement IList but not have Add()?

元气小坏坏 提交于 2020-01-05 14:12:43
问题 I am trying to mimic the way a ListView and other controls handle SelectedItems collections. I have a class with a collection of items and each Item has a Selected property. I want to mimic the smart behavior where an Item can change its own Selected property and upon doing so would raise a SelectedItemsChanged event in the parent class, and the SelectedItems collection should now reflect the change. I am trying to implement a SelectedItemsCollection class which does not contain an inner list

How does SelectedListViewItemCollection implement IList but not have Add()?

戏子无情 提交于 2020-01-05 14:12:20
问题 I am trying to mimic the way a ListView and other controls handle SelectedItems collections. I have a class with a collection of items and each Item has a Selected property. I want to mimic the smart behavior where an Item can change its own Selected property and upon doing so would raise a SelectedItemsChanged event in the parent class, and the SelectedItems collection should now reflect the change. I am trying to implement a SelectedItemsCollection class which does not contain an inner list

Having trouble accessing a key in a map inside an []interface

我的未来我决定 提交于 2020-01-05 08:59:48
问题 Example code: package main import "fmt" func main() { example_container := []interface{}{ map[string]string{ "name": "bob", "id": "1", }, map[string]string{ "name": "jim", "id": "2", }, } fmt.Printf("%v\n", example_container) fmt.Printf("%v\n", example_container[0]) fmt.Printf("%v\n", example_container[0]["name"]) } Problematic line: fmt.Printf("%v\n", example_container[0]["name"]) Error: invalid operation: example_container[0]["name"] (type interface {} does not support indexing) Question:

Cast To Interface

吃可爱长大的小学妹 提交于 2020-01-05 08:44:08
问题 I am not getting any errors in my code, but my filter object is always null. When I run the debugger the filter object looks just like the sort object, a list with stuff in it. Although as you can see it is actually a interface.. What do I need to change in this code to access the information in the filter? I guess my main problem is I don't quite fully grasp how to work with interfaces. public IList<Kendo.Mvc.IFilterDescriptor> Filters { get; set; } public IList<Kendo.Mvc.SortDescriptor>

Converting inerface with delegate from vb to c#

南楼画角 提交于 2020-01-05 08:09:21
问题 I've got interface: Public Interface ICSIItem Sub Initialize() Event AnswerValueChanged(ByVal sender As Object, ByVal e As NotebookAnswerChangedEventArgs) Property DataContext() As Object End Interface and converter http://www.developerfusion.com/tools/convert/vb-to-csharp/ public interface ICSIItem { void Initialize(); event AnswerValueChangedEventHandler AnswerValueChanged; delegate void AnswerValueChangedEventHandler(object sender, NotebookAnswerChangedEventArgs e); object DataContext {

Serializing interface in wcf

空扰寡人 提交于 2020-01-05 04:16:12
问题 I designed an application that has an interface and two inherited classes: interface IPerson {} class Man:IPerson{} class Woman:IPerson{} Now, I wrote a method that looks like this: public IPerson GetPeron(int idNumber); This method gets an ID number and looks for that number in the DB. If that number belogns to a man, a new Man instance is created, data from the DB is being put into the new instance and finally the instance returns. The same goes if the given ID belongs to a woman Now I want