interface

C# overriding an interface contract method of a base class

拟墨画扇 提交于 2019-12-12 05:49:40
问题 I have created a converter class that uses the IValueConverter interface and InConverter. It is bound to a DataGrid and it is passed an array of strings in which it determines if the value is in the array. [ValueConversion(typeof(int), typeof(bool))] public class InConverter : IValueConverter { public object Convert(object value, Type type, object parameter, CultureInfo info) { String str = value as String; String[] compareList = parameter as String[]; if (str != null) { foreach (String

Interface inheritance and generic interfaces force explicit casts?

拈花ヽ惹草 提交于 2019-12-12 05:49:20
问题 I have a much more complicated issue, but I've boiled it down to the following simple example: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Sandbox { class Program { static void Main(string[] args) { IFactory<IProduct> factory = new Factory(); } } class Factory : IFactory<Product> { } class Product : IProduct { } interface IFactory<T> where T : IProduct { } interface IProduct { } } All is well and dandy... except that I get this error. Error

How can I utilize EntityCollection of type <Interface> using a partial class with Entity Framework?

徘徊边缘 提交于 2019-12-12 05:38:10
问题 I'm using partial classes. One class is generated from EntityFramework. Another class I generate myself so that I can implement an interface. The interface will be used so two libraries/assemblies will not know about each other but will be able to implement the common interface. My custom interface declares property EntityCollection( ITimesheetLabors ) but my EntityFramework generates EntityCollection(TimesheetLabors) so the compiler tells me that my class doesn't implement EntityCollection

Binding WPF controls to dynamically introduced interfaces on model objects

女生的网名这么多〃 提交于 2019-12-12 05:27:41
问题 I am using PostSharp's [CompositionAspect] capability to dynamically inject an interface to a model object in my WPF application. However, it seems WPF cannot bind (display) properties corre ctly unless the relevant interface is explicitly implemented on the model object? Using a custom CompositionAspect (ComposeObjectAspect) I am able to successfully expose the internal IMyInterface object's properties directly by runtime casting the ModelObject to the introduced interface; // some interface

Why language designers allow interface to contain fields?

自古美人都是妖i 提交于 2019-12-12 05:25:21
问题 As per Item 19 in Effective Java, one must use an interface to only represent a type. In this case the interface would contain the methods that form part of the public contract that is exposed by a class (implementing the interface) to the clients If so, why do interfaces support fields in the first place? Since the fields are implicitly public, static, final, (and hence constants), why did the language designers support having them? If they were unsupported then developers would invariably

swig: how to pass void* into generic function

时间秒杀一切 提交于 2019-12-12 04:56:49
问题 I have scenario where I need pass around opaque void* pointers through my C++ <-> Python interface implemented based on SWIG (ver 1.3). I am able to return and accept void* in regular functions like this: void* foo(); void goo( void* ); The problems begins when I try to do the same using generic functions (and this is what I actually need to do). I was able to deal with "foo" scenario above with the function doing essentially something like this (stolen from code generated by SWIG itself for

How to cleanly handle unchecked conversion with generics in an interface?

∥☆過路亽.° 提交于 2019-12-12 04:34:31
问题 Simplified Code Example public class SomeBaseClass { } public class SomeClass extends SomeBaseClass { } public interface SomeInterface { public <T extends SomeBaseClass> T someMethod(); } public class BestClass implements SomeInterface { // @SuppressWarnings("unchecked") @Override public SomeClass someMethod() { return null; } } More Detailed Code Example // Base config class public class BaseConfigClass { } // Some interface for all config classes to implement public interface SomeInterface

Decide what dll to call at runtime

雨燕双飞 提交于 2019-12-12 04:09:32
问题 I am using the Process.Start() method to launch a specific executable as needed. The executable is tailor-made, there are many of these, and the paths & names are in the database together with the job they do. Is there another way to launch them in-process, if they all implement an interface? I want to be able to debug them and have better type safety when calling them. I can set a library project in each solution, then instantiate that library and have it do the job instead of the executable

Interface implements a different interface, causing issues binding to Combobox

允我心安 提交于 2019-12-12 03:53:24
问题 I am learning Fluent NHibernate and this issue arose from that project. I have a base Class and a base Interface: public abstract class Base : IBase { public virtual Guid Id { get; set; } public virtual bool IsValid() { return false; } } public interface IBase { Guid Id { get; set; } bool IsValid(); } which I inherit all of my other Domain classes from: public class Item:Base, IItem { public virtual string Name { get; set; } public override bool IsValid() { <snip> } <snip> } public interface

Pass an array of interfaces into a function? [duplicate]

北慕城南 提交于 2019-12-12 03:48:59
问题 This question already has answers here : Type hinting - specify an array of objects (5 answers) Closed 3 years ago . In PHP since the interface benefits can used by passing as parameter mentioning the Interface name something like public function foo (Abc $abc){} where Abc is an interface.But how do I pass an array of these interfaces? Please note this not class but interface and only way to get advantage of interface is passing as function with type hinting 回答1: In PHP 5.6+ you could do