Search Results

Search found 13331 results on 534 pages for 'fluent interface'.

Page 12/534 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Object initializer with explicit interface in C#

    - by Ben Aston
    How can I use an object initializer with an explicit interface implementation in C#? public interface IType { string Property1 { get; set; } } public class Type1 : IType { string IType.Property1() { get; set; } } ... //doesn't work var v = new Type1 { IType.Property1 = "myString" };

    Read the article

  • Can't connect IBOutlet in Interface Builder

    - by Dave C
    Hello, I have the following code: @interface AddResident : UIViewController { IBOutlet UITextField *FirstName; IBOutlet UISegmentedControl *Gender; } I can see both of these outlets in interface builder but can only connect the UISegmented control... the other one will not connect to my UITextField on the form. Any help is much appreciated.

    Read the article

  • inner class within Interface

    - by harigm
    is that possible to create a inner class within an interface? If yes, why do we create like that? Anyways we are not going to create any interface objects? Do they help in any Development process?

    Read the article

  • Common header view on top of nib files with Interface builder

    - by Tiago
    Hi, I have a nib file that contains an header that will be used in most of my views, so that I can change it's layout just once when I need. I'd like to know if it's possible to add the header nib view with interface builder, or if I need to do that programmatically and how should it be done. I've thought about setting the subclass of the subview to a UIView subclass that automatically loads the nib file, but I'd like to do that with interface builder. Is that possible?

    Read the article

  • What is the use of interface constants?

    - by kunjaan
    I am learning Java and just found that the Interface can have fields, which are public static and final. I haven't seen any examples of these so far. What are some of the use cases of these Interface Constants and can I see some in the Java Standard Library?

    Read the article

  • Trouble creating a button matrix in Interface Builder

    - by Jake
    Hi, I am trying to create a matrix of buttons in Interface Builder 3.2.1 but can not find anyway to do it. I read the question and answer posted here: http://stackoverflow.com/questions/1771835/how-to-create-a-nsmatrix-of-nsimagecell-in-interface-builder-in-10-6 But following Layout Embed Objects In, as suggested, I see only View and Scroll View as options, not Matrix. Have I missed something? Thanks.

    Read the article

  • Interface in a dynamic language?

    - by Bryan
    Interface (or an abstract class with all the methods abstract) is a powerful weapon in a static language. It allows different derived types to be used in a uniformed way. However, in a dynamic language, all objects can be used in a uniformed way as long as they define certain methods. Does interface exist in dynamic languages? It seems unnecessary to me.

    Read the article

  • Web services that implement the same interface

    - by zachary
    My friend build a web service in java I build one in .net I want them to implement the same interface then in my program change the web.config to point to one or the other. In my mind this would be done by implementing the same interface. Not sure how it would actually be done...

    Read the article

  • Anonymous class implementing interface

    - by Flo
    I have the following code inside a method: var list = new[] { new { Name = "Red", IsSelected = true }, new { Name = "Green", IsSelected = false }, new { Name = "Blue", IsSelected = false }, }; I would like to call a function that requires a list of elements with each element implementing an interface (ISelectable). I know how this is done with normal classes, but in this case I am only trying to fill in some demo data. Is it possible to create an anonymous class implementing an interface? like this: new { Name = "Red", IsSelected = true } : ISelectable

    Read the article

  • Advantages/disadvantages of browser-based interface vs. graphics

    - by Josh
    Hello everyone, I'm in the design phase for a desktop-based application. Because of the nature of this particular application, I believe it would benefit greatly from a web-based approach (i.e., allowing a user to interface with the application through a browser running in kiosk mode) in order to leverage the simplicity of HTML/CSS/JS and the availability of many great JS interface plugins. Does taking this approach (rather than coding in a native or cross-platform graphics library) come with any gotchas?

    Read the article

  • Go - Methods of an interface

    - by nevalu
    Would be correct the next way to implement the methods attached to an interface? (getKey, getData) type reader interface { getKey(ver uint) string getData() string } type location struct { reader fileLocation string err os.Error } func (self *location) getKey(ver uint) string {...} func (self *location) getData() string {...} func NewReader(fileLocation string) *location { _location := new(location) _location.fileLocation = fileLocation return _location }

    Read the article

  • Go - Generic function using an interface

    - by nevalu
    Since I've a similar function for 2 different data types: func GetStatus(value uint8) (string) {...} func GetStatus(name string) (string) {...} I would want to use a way more simple like: func GetStatus(value interface{}) (string) {...} Is possible to create a generic function using an interface? The data type could be checked using reflect.Typeof(value)

    Read the article

  • Difference between abstract class and interface

    - by nectar
    A class implementing an interface has to implement all the methods of the interface, but if that class is implementing an abctract class is it necessary to implement all abstract methods? If not, can we create the object of that class which is implementing the Abstract class???

    Read the article

  • SQL programming interface to external storage application

    - by Gopala
    My application is a non-relational database application with a tcl interface to retrieve data. I would like to add SQL programming interface to my application. Is there any library that converts SQL/PLSQL statements to API calls? It should also support stored procedures. SQLite(Embedded) has 'virtual table' mechanism that suits my requirement but it lacks stored procedure feature. -Gopala

    Read the article

  • Interface explosion problem

    - by Benny
    I am implementing a screen using MVP pattern, with more feature added to the screen, I am adding more and more methods to the IScreen/IPresenter interface, hence, the IScreen/IPresenter interface is becoming bigger and bigger, what should I do to cope with this situation?

    Read the article

  • Give a reference to a python instance attribute at class definition

    - by Guenther Jehle
    I have a class with attributes which have a reference to another attribute of this class. See class Device, value1 and value2 holding a reference to interface: class Interface(object): def __init__(self): self.port=None class Value(object): def __init__(self, interface, name): self.interface=interface self.name=name def get(self): return "Getting Value \"%s\" with interface \"%s\""%(self.name, self.interface.port) class Device(object): interface=Interface() value1=Value(interface, name="value1") value2=Value(interface, name="value2") def __init__(self, port): self.interface.port=port if __name__=="__main__": d1=Device("Foo") print d1.value1.get() # >>> Getting Value "value1" with interface "Foo" d2=Device("Bar") print d2.value1.get() # >>> Getting Value "value1" with interface "Bar" print d1.value1.get() # >>> Getting Value "value1" with interface "Bar" The last print is wrong, cause d1 should have the interface "Foo". I know whats going wrong: The line interface=Interface() line is executed, when the class definition is parsed (once). So every Device class has the same instance of interface. I could change the Device class to: class Device(object): interface=Interface() value1=Value(interface, name="value1") value2=Value(interface, name="value2") def __init__(self, port): self.interface=Interface() self.interface.port=port So this is also not working: The values still have the reference to the original interface instance and the self.interface is just another instance... The output now is: >>> Getting Value "value1" with interface "None" >>> Getting Value "value1" with interface "None" >>> Getting Value "value1" with interface "None" So how could I solve this the pythonic way? I could setup a function in the Device class to look for attributes with type Value and reassign them the new interface. Isn't this a common problem with a typical solution for it? Thanks!

    Read the article

  • Interface Casting vs. Class Casting

    - by Legatou
    I've been led to believe that casting can, in certain circumstances, become a measurable hindrance on performance. This may be moreso the case when we start dealing with incoherent webs of nasty exception throwing\catching. Given that I wish to create more correct heuristics when it comes to programming, I've been prompted to ask this question to the .NET gurus out there: Is interface casting faster than class casting? To give a code example, let's say this exists: public interface IEntity { IParent DaddyMommy { get; } } public interface IParent : IEntity { } public class Parent : Entity, IParent { } public class Entity : IEntity { public IParent DaddyMommy { get; protected set; } public IParent AdamEve_Interfaces { get { IEntity e = this; while (this.DaddyMommy != null) e = e.DaddyMommy as IEntity; return e as IParent; } } public Parent AdamEve_Classes { get { Entity e = this; while (this.DaddyMommy != null) e = e.DaddyMommy as Entity; return e as Parent; } } } So, is AdamEve_Interfaces faster than AdamEve_Classes? If so, by how much? And, if you know the answer, why?

    Read the article

  • Newtonsoft JSON Interface Serialization error

    - by Ben
    I am using C# .NET 4.0, Newtonsoft JSON 4.5.0. public class Recipe { [JsonProperty(TypeNameHandling = TypeNameHandling.All)] public List<IFood> Foods{ get; set; } ... } I want to serialize and deserialize this Recipe object. If I serialize and deserialize the object during application lifetime this succeeds, but if I serialize the object, exit application and then deserialize it then it throws an exception, that it cannot instantiate IFood (since it is an interface). The problem is that it does not serialize the implementation of interface. "$type": "System.Collections.Generic.List`1[[NSM.Shared.Models.IFood, NSMShared]], mscorlib" I tried using TypeNameHandling.Object and Array and Auto, but it didn't help. Is there any way to serialize it properly? Or at least to define the class mapping before deserializing? EDIT: I am using JSON coupled with Hammock ( http://code.google.com/p/relax-net/ ), C# driver for CouchDB, which internally serializes and deserializes objects. As mentioned the problem is that it does not serialize the interface implementation.

    Read the article

  • Delphi RTTI unable to find interface

    - by conciliator
    I'm trying to fetch an interface using D2010 RTTI. program rtti_sb_1; {$APPTYPE CONSOLE} {$M+} uses SysUtils, Rtti, mynamespace in 'mynamespace.pas'; var ctx: TRttiContext; RType: TRttiType; MyClass: TMyIntfClass; begin ctx := TRttiContext.Create; MyClass := TMyIntfClass.Create; // This prints a list of all known types, including some interfaces. // Unfortunately, IMyPrettyLittleInterface doesn't seem to be one of them. for RType in ctx.GetTypes do WriteLn(RType.Name); // Finding the class implementing the interface is easy. RType := ctx.FindType('mynamespace.TMyIntfClass'); // Finding the interface itself is not. RType := ctx.FindType('mynamespace.IMyPrettyLittleInterface'); MyClass.Free; ReadLn; end. Both IMyPrettyLittleInterface and TMyIntfClass = class(TInterfacedObject, IMyPrettyLittleInterface) are declared in mynamespace.pas. Do anyone know why this doesn't work? Is there a way to solve my problem? Thanks in advance!

    Read the article

  • Cannot inherit from generic base class and specific interface using same type with generic constrain

    - by simendsjo
    Sorry about the strange title. I really have no idea how to express it any better... I get an error on the following snippet. I use the class Dummy everywhere. Doesn't the compiler understand the constraint I've added on DummyImplBase? Is this a compiler bug as it works if I use Dummy directly instead of setting it as a constraint? Error 1 'ConsoleApplication53.DummyImplBase' does not implement interface member 'ConsoleApplication53.IRequired.RequiredMethod()'. 'ConsoleApplication53.RequiredBase.RequiredMethod()' cannot implement 'ConsoleApplication53.IRequired.RequiredMethod()' because it does not have the matching return type of 'ConsoleApplication53.Dummy'. C:\Documents and Settings\simen\My Documents\Visual Studio 2008\Projects\ConsoleApplication53\ConsoleApplication53\Program.cs 37 27 ConsoleApplication53 public class Dummy { } public interface IRequired<T> { T RequiredMethod(); } public interface IDummyRequired : IRequired<Dummy> { void OtherMethod(); } public class RequiredBase<T> : IRequired<T> { public T RequiredMethod() { return default(T); } } public abstract class DummyImplBase<T> : RequiredBase<T>, IDummyRequired where T: Dummy { public void OtherMethod() { } }

    Read the article

  • Invoking a method overloaded where all arguments implement the same interface

    - by double07
    Hello, My starting point is the following: - I have a method, transform, which I overloaded to behave differently depending on the type of arguments that are passed in (see transform(A a1, A a2) and transform(A a1, B b) in my example below) - All these arguments implement the same interface, X I would like to apply that transform method on various objects all implementing the X interface. What I came up with was to implement transform(X x1, X x2), which checks for the instance of each object before applying the relevant variant of my transform. Though it works, the code seems ugly and I am also concerned of the performance overhead for evaluating these various instanceof and casting. Is that transform the best I can do in Java or is there a more elegant and/or efficient way of achieving the same behavior? Below is a trivial, working example printing out BA. I am looking for examples on how to improve that code. In my real code, I have naturally more implementations of 'transform' and none are trivial like below. public class A implements X { } public class B implements X { } interface X { } public A transform(A a1, A a2) { System.out.print("A"); return a2; } public A transform(A a1, B b) { System.out.print("B"); return a1; } // Isn't there something better than the code below??? public X transform(X x1, X x2) { if ((x1 instanceof A) && (x2 instanceof A)) { return transform((A) x1, (A) x2); } else if ((x1 instanceof A) && (x2 instanceof B)) { return transform((A) x1, (B) x2); } else { throw new RuntimeException("Transform not implemented for " + x1.getClass() + "," + x2.getClass()); } } @Test public void trivial() { X x1 = new A(); X x2 = new B(); X result = transform(x1, x2); transform(x1, result); }

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >