Search Results

Search found 13880 results on 556 pages for 'explicit interface'.

Page 4/556 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • In Enterprise Architect I modified an interface, how to update the realizing classes?

    - by Timo
    I've created an interface in a class model. This interface has two methods, A and B and method A takes an argument (a) and method B does not take an argument (yet). Additionally I've created a class that implements this interface, overriding both methods. After a discussing the model method B now should also take a parameter (b), so I modified the interface to reflect this change. However the class realizing this interface is not updated automatically. For one class it's possible to add the method by re-creating the link between the interface, specify the which method should be implemented and deleting this link again. Then the OLD method signature has to be removed as well. This is a lot of work if there is more then one class implementing the modified interface, not to mention error-prone. Does anybody know how to make an entire class model update this type of dependency?

    Read the article

  • Frustration with superuser.com user interface (please migrate this to "meta")

    - by Randolf Richardson
    Can someone please migrate this question to "meta" for me? I'm unable to post there while I wait for OpenID to fix my password problems. Thanks. I'm having problems with superuser.com's interface -- when I provide an answer to a question, sometimes the buttons get locked and then I find out that the question was migrated. Usually I can go back and copy-and-paste my answer at whatever site it goes to, but on occasion my answer is lost and I have to re-type it. This is very time-consuming, and makes it quite frustrating to use the system. In addition, I find that I'm wasting a lot of time dealing with having to re-register on the other sites. My suggestion is to not de-activate the "Submit answer" button but to just forward that along to the migrated site automatically, thus ensuring that answers that people put a lot of effort into don't get lost. Thanks in advance.

    Read the article

  • Pause Nagios reloading in web interface

    - by 2rec
    Is there any option how could I turn off reloading of web page in Nagios web interface? Many times I checked many services and I needed the webpage to stay static and don't reload. One solution come to my mind - turn off the whole reloading for a while. Problem is that other people are using it too and they may want it at the time I don't want it. If anybody know about any kind of workaround or solution, please don't hesitate to write an answer. ;-) EDIT (+ reaction to the first answer): Maybe there could be a better way how to do it instead of modyfying nagios core. Interesting is, that I tried to disable javascript, it refreshed. I tried to disable http refreshing, it refreshed anyway. Has anybody know how and where is the refresh implemented?

    Read the article

  • Programmatically implementing an interface that combines some instances of the same interface in var

    - by namin
    What is the best way to implement an interface that combines some instances of the same interface in various specified ways? I need to do this for multiple interfaces and I want to minimize the boilerplate and still achieve good efficiency, because I need this for a critical production system. Here is a sketch of the problem. Abstractly, I have a generic combiner class which takes the instances and specify the various combinators: class Combiner<I> { I[] instances; <T> T combineSomeWay(InstanceMethod<I,T> method) { // ... method.call(instances[i]) ... combined in some way ... } // more combinators } Now, let's say I want to implement the following interface among many others: Interface Foo { String bar(int baz); } I want to end up with code like this: class FooCombiner implements Foo { Combiner<Foo> combiner; @Override public String bar(final int baz) { return combiner.combineSomeWay(new InstanceMethod<Foo, String> { @Override public call(Foo instance) { return instance.bar(baz); } }); } } Now, this can quickly get long and winded if the interfaces have lots of methods. I know I could use a dynamic proxy from the Java reflection API to implement such interfaces, but method access via reflection is hundred times slower. So what are the alternatives to boilerplate and reflection in this case?

    Read the article

  • How to fix error - "@interface interfaceName : someEnumeration" gives error "cannot find interface '

    - by Paul V
    How can I solve "cannot find interface declaration 'someEnumeration', superclass of 'interfaceName'" error? What steps will reproduce the problem? Compiling Wsdl2ObjC Targeting groupwise.wsdl file Fixing non-valid file names of output csource code like ".h" + ".m" and objects inside source files Moving up one of the @interface BEFORE it was used futher in code! What is the expected output? Something working What do you see instead? 33 errors. "Inherited" from only 3 similar Inheritances of a typedef enum object by a class. All errors are typical: typedef enum types_StatusTrackingOptions { types_StatusTrackingOptions_none = 0, types_StatusTrackingOptions_None, types_StatusTrackingOptions_Delivered, types_StatusTrackingOptions_DeliveredAndOpened, types_StatusTrackingOptions_All, } types_StatusTrackingOptions; types_StatusTrackingOptions types_StatusTrackingOptions_enumFromString(NSString *string); NSString * types_StatusTrackingOptions_stringFromEnum(types_StatusTrackingOptions enumValue); @interface types_StatusTracking : types_StatusTrackingOptions { ... and here I'm having error "cannot find interface declaration for 'types_StatusTrackingOptions', superclass of 'types_StatusTracking'". What version of the product are you using? On what operating system? Wsdl2ObjC - rev 168, OS - Mac OS X 10.6.2, iPhone SDK - 3.2, Simulator - v. 3.1.2 - 3.1.3, wsdl - for GroupWise v.8, NDK released 2008-12-23, wsdl and xsd files are attached. P.S. GroupWise.wsdl + .xsd files could be downloaded from http://code.google.com/p/wsdl2objc/issues/detail?id=99

    Read the article

  • Play or Lift: which one is more explicit?

    - by Andrea
    I am going to investigate web development with Scala, and the choice is between learning Lift or Play: probably I will not have enough time to try both, at least at first. Now, many comparisons between the two are available on the internet, but I would like to know how do they compare with respect to being explicit and involving less magic. Let me explain what I mean by example. I have used, to various degrees, CakePHP, symfony2, Django and Grails. I feel a very clear distinction between Django and symfony2, which are very explicit about what you are doing, and Grails and CakePHP, which try to do their best to guess what you are trying to achieve and often feel "magical". Let me give some examples comparing Django and Grails. In Django, views are functions that take a request as input and return a response. You can instantiate explicitly an instance of HttpResponse and populate its body with a string, or you can use shortcut functions to leverage the template system. In any case the return value from your view always has the same type. In contrast, the render method from Grails is highly polymorphic. You can throw a context at it and it will try to render a template which is found by convention using that context. Or you can pass it a pair of a template path and a context and that will work too. Or a string. Or XML. Grails tries hard to make sense of whatever you return from your controller. In the Django ORM, each model class has a static attribute representing the manager for that class. That manager exposes a fluent interface to build querysets. In Grails, you can have a similar functionality by composing detached criteria. Still, the most common way to query objects seems to be the use of runtime-generated methods like FindUserByEmailNotNull or FindPostByDateGreaterThan. I will not go further, but my point is that in Django-like frameworks you have control over the whole flow of the request/response process, while in Grails-like ones I feel I only have to feel the blanks and the framework will manage the rest of the flow for me. This is not to criticize Grails or CakePHP; which type you prefer is mainly a matter of preference. In fact, I happen to like some aspects of Grails, but I feel more comfortable with a framework which does less for me. Back to the point of the question: which one among Play and Lift is more explicit about what you do and which one tries to simplify more what you have to do with a layer of "magic"?

    Read the article

  • Can I use metro style interface in my own web application?

    - by LukeP
    I am wondering if I would need to license the Metro style or if I can just freely use it in my own applications. I mean, is it patented or protected in any way that would prevent me from building my own implementation? I effectively would like to copy the visible part of it. I like to idea of being able to: Provide an interface which is used somewhere else (as in 1 less to learn) Use the interface that has been tested for usability (I personally like it) Have the possibility of getting free publicity because of implementing full Metro style web application while not associated with Microsoft, etc.

    Read the article

  • Spring 3 DI using generic DAO interface

    - by Peders
    I'm trying to use @Autowired annotation with my generic Dao interface like this: public interface DaoContainer<E extends DomainObject> { public int numberOfItems(); // Other methods omitted for brevity } I use this interface in my Controller in following fashion: @Configurable public class HelloWorld { @Autowired private DaoContainer<Notification> notificationContainer; @Autowired private DaoContainer<User> userContainer; // Implementation omitted for brevity } I've configured my application context with following configuration <context:spring-configured /> <context:component-scan base-package="com.organization.sample"> <context:exclude-filter expression="org.springframework.stereotype.Controller" type="annotation" /> </context:component-scan> <tx:annotation-driven /> This works only partially, since Spring creates and injects only one instance of my DaoContainer, namely DaoContainer. In other words, if I ask userContainer.numberOfItems(); I get the number of notificationContainer.numberOfItems() I've tried to use strongly typed interfaces to mark the correct implementation like this: public interface NotificationContainer extends DaoContainer<Notification> { } public interface UserContainer extends DaoContainer<User> { } And then used these interfaces like this: @Configurable public class HelloWorld { @Autowired private NotificationContainer notificationContainer; @Autowired private UserContainer userContainer; // Implementation omitted... } Sadly this fails to BeanCreationException: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.organization.sample.dao.NotificationContainer com.organization.sample.HelloWorld.notificationContainer; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.organization.sample.NotificationContainer] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} Now, I'm a little confused how should I proceed or is using multiple Dao's even possible. Any help would be greatly appreciated :)

    Read the article

  • Storing Interface type in ASP.NET Profile

    - by NathanD
    In my ASP.NET website all calls into the data layer return entities as interfaces and the website does not need to know what the concrete type is. This works fine, but I have run into a problem when trying to store one of those types into the user Profile. My interface implements ISerializable, like the following: public interface IInsured : IPerson, IEntity, ISerializable and the concrete type in the datalayer does implement ISerializable. My Profile property in web.config is: <add name="ActiveInsured" type="FacadeInterfaces.IInsured" serializeAs="Binary" defaultValue="[null]"/> It compiles just fine, but I get a runtime error on Profile.Save() saying that the interface cannot be serialized. I have also tried it with serializeAs="Xml". I thought that if my interface implemented ISerializable it would work. Anybody had this problem before or know of a workaround?

    Read the article

  • Java: why is declaration not sufficient in interface?

    - by HH
    Big class contains Format-interfcase and Format-class. The Format-class contains the methods and the interface has the values of the fields. I could have the fields in the class Format but the goal is with Interface. So do I just create dummy-vars to get the errors away, design issue or something ELSE? KEY: Declaration VS Initialisation Explain by the terms, why you have to init in interface. What is the logic behind it? To which kind of problems it leads the use of interface? Sample Code having the init-interface-problem import java.util.*; import java.io.*; public class FormatBig { private static class Format implements Format { private static long getSize(File f){return f.length();} private static long getTime(File f){return f.lastModified();} private static boolean isFile(File f){if(f.isFile()){return true;}} private static boolean isBinary(File f){return Match.isBinary(f);} private static char getType(File f){return Match.getTypes(f);} private static String getPath(File f){return getNoErrPath(f);} //Java API: isHidden, --- SYSTEM DEPENDED: toURI, toURL Format(File f) { // PUZZLE 0: would Stack<Object> be easier? size=getSize(f); time=getTime(f); isfile=isFile(f); isBinary=isBinary(f); type=getType(f); path=getPath(f); //PUZZLE 1: how can simplify the assignment? values.push(size); values.push(time); values.push(isfile); values.push(isBinary); values.push(type); values.push(path); } } public static String getNoErrPath(File f) { try{return f.getCanonicalPath(); }catch(Exception e){e.printStackTrace();} } public static final interface Format { //ERR: IT REQUIRES "=" public long size; public long time; public boolean isFile=true; //ERROR goes away if I initialise wit DUMMY public boolean isBinary; public char type; public String path; Stack<Object> values=new Stack<Object>(); } public static void main(String[] args) { Format fm=new Format(new File(".")); for(Object o:values){System.out.println(o);} } }

    Read the article

  • Delphi interface cast using TValue

    - by conciliator
    I've recently experimented extensively with interfaces and D2010 RTTI. I don't know at runtime the actual type of the interface; although I will have access to it's qualified name using a string. Consider the following: program rtti_sb_1; {$APPTYPE CONSOLE} uses SysUtils, Rtti, TypInfo, mynamespace in 'mynamespace.pas'; var ctx: TRttiContext; InterfaceType: TRttiType; Method: TRttiMethod; ActualParentInstance: IParent; ChildInterfaceValue: TValue; ParentInterfaceValue: TValue; begin ctx := TRttiContext.Create; // Instantiation ActualParentInstance := TChild.Create as IParent; {$define WORKAROUND} {$ifdef WORKAROUND} InterfaceType := ctx.GetType(TypeInfo(IParent)); InterfaceType := ctx.GetType(TypeInfo(IChild)); {$endif} // Fetch interface type InterfaceType := ctx.FindType('mynamespace.IParent'); // This cast is OK and ChildMethod is executed (ActualParentInstance as IChild).ChildMethod(100); // Create a TValue holding the interface TValue.Make(@ActualParentInstance, InterfaceType.Handle, ParentInterfaceValue); InterfaceType := ctx.FindType('mynamespace.IChild'); // This cast doesn't work if ParentInterfaceValue.TryCast(InterfaceType.Handle, ChildInterfaceValue) then begin Method := InterfaceType.GetMethod('ChildMethod'); if (Method <> nil) then begin Method.Invoke(ChildInterfaceValue, [100]); end; end; ReadLn; end. The contents of mynamespace.pas is as follows: {$M+} IParent = interface ['{2375F59E-D432-4D7D-8D62-768F4225FFD1}'] procedure ParentMethod(const Id: integer); end; {$M-} IChild = interface(IParent) ['{6F89487E-5BB7-42FC-A760-38DA2329E0C5}'] procedure ChildMethod(const Id: integer); end; TParent = class(TInterfacedObject, IParent) public procedure ParentMethod(const Id: integer); end; TChild = class(TParent, IChild) public procedure ChildMethod(const Id: integer); end; For completeness, the implementation goes as procedure TParent.ParentMethod(const Id: integer); begin WriteLn('ParentMethod executed. Id is ' + IntToStr(Id)); end; procedure TChild.ChildMethod(const Id: integer); begin WriteLn('ChildMethod executed. Id is ' + IntToStr(Id)); end; The reason for {$define WORKAROUND} may be found in this post. Question: is there any way for me to make the desired type cast using RTTI? In other words: is there a way for me to invoke IChild.ChildMethod from knowing 1) the qualified name of IChild as a string, and 2) a reference to the TChild instance as a IParent interface? (After all, the hard-coded cast works fine. Is this even possible?) Thanks!

    Read the article

  • How to add member variable to an interface in c#

    - by Nassign
    I know this may be basic but I cannot seem to add a member variable to an interface. I tried inheriting the interface to an abstract class and add member variable to the abstract class but it still does not work. Here is my code: public interface IBase { void AddData(); void DeleteData(); } public abstract class AbstractBase : IBase { string ErrorMessage; abstract AddData(); abstract DeleteData(); }

    Read the article

  • Creating Mock object of Interface with type-hint in method fails on PHPUnit

    - by Mark
    I created the following interface: <?php interface Action { public function execute(\requests\Request $request, array $params); } Then I try to make a Mock object of this interface with PHPUnit 3.4, but I get the following error: Fatal error: Declaration of Mock_Action_b389c0b1::execute() must be compatible with that of Action::execute() in D:\Xampp\xampp\php\PEAR\PHPUnit\Framework\TestCase.php(1121) : eval()'d code on line 2 I looked through the stack trace I got from PHPUnit and found that it creates a Mock object that implements the interface Action, but creates the execute method in the following way: <?php public function execute($request, array $params) As you can see, PHPUnit takes over the array type-hint, but forgets about \requests\Request. Which obviously leads to an error. Does anyone knows a workaround for this error? I also tried it without namespaces, but I still get the same error.

    Read the article

  • Interface for classes that have nothing in common

    - by Tomek Tarczynski
    Lets say I want to make few classes to determine behaviour of agents. The good practice would be to make some common interface for them, such interface (simplified) could look like this: interface IModel { void UpdateBehaviour(); } All , or at least most, of such model would have some parameters, but parameters from one model might have nothing in common with parameters of other model. I would like to have some common way of loading parameters. Question What is the best way to do that? Is it maybe just adding method void LoadParameters(object parameters) to the IModel? Or creating empty interface IParameters and add method void LoadParameters(IParameters parameters)? That are two ideas I came up with, but I don't like either of them.

    Read the article

  • Constructor in a Interface?

    - by Sebi
    I know its not possible to define a constructor in a interface. But im wondering why, because i think i could be very useful. So you could be sure that some fields in a class are defined for every implementaiton of this interface. For example consider the following message class: public class MyMessage { public MyMessage(String receiver) { this.receiver = receiver; } private String receiver; public void send() { //some implementation for sending the mssage to the receiver } } If a define a Interface for this class so that i can have more classes which implement the message interface, i can only define the send method and not the constructor. So how can i assure that every implementation of this class really has an receiver setted? If i use a method like setReceiver(String receiver) i can't be sure that this method is really called. In the constructor i could assure it.

    Read the article

  • C# naming convention for extension methods for interface

    - by Sarah Vessels
    I typically name my C# interfaces as IThing. I'm creating an extension method class for IThing, but I don't know what to name it. On one hand, calling it ThingExtensions seems to imply it is an extension class to some Thing class instead of to the IThing interface. It also makes the extension class be sorted away from the interface it extends, when viewing files alphabetically. On the other hand, naming it IThingExtensions makes it look like it is an interface itself, instead of an extension class for an interface. What would you suggest?

    Read the article

  • VS2010 Implement Generic Interface expansion doesn't use specified type

    - by TJB
    Using the release version of Visual Studio 2010 I think there's a difference in the "Implement Interface" expansion from VS2008 If I speicify an interface and implement it in a class as so: public interface IRepository<T> where T : IModel { T Get<T>(int id); void Update<T>(); int Add<T>(T item); } public class MockRepository : IRepository<MockUser> { // ... } Then use the "Implement Interface" expansion and get this: public class MockRepository : IRepository<MockUser> { public T Get<T>(int id) { throw new NotImplementedException(); } public void Update<T>() { throw new NotImplementedException(); } public int Add<T>(T item) { throw new NotImplementedException(); } } Instead of what I expected public class MockRepository : IRepository<MockUser> { public MockUser Get<MockUser>(int id) { throw new NotImplementedException(); } public void Update<MockUser>() { throw new NotImplementedException(); } public int Add<MockUser>(MockUser item) { throw new NotImplementedException(); } } The IDE uses the type variable name from the generic interface definition T instead of the specified concrete type MockUser. Is this a bug? Or is something new just for VS2010 / .Net 4.0?

    Read the article

  • Implementing few methods of a interface class-C#

    - by Jankhana
    Is it possible in C# to have a class that implement an interface that has 10 methods declared but implementing only 5 methods i.e defining only 5 methods of that interface??? Actually I have an interface that is implemented by 3 class and not all the methods are used by all the class so if I could exclude any method???

    Read the article

  • iPhone: Interface Builder leaks memory?

    - by Stefan Klumpp
    I have been working on an iPhone project, where we created all the user interface programmatically in code. Now I'm going to start a new iPhone project and thinking of using Interface Builder instead, because it has been recommended to me as being a very useful tool, creating less headache than writing everything in code and in general much faster (regarding development time). However, my team members have some concerns due to previous problems with using Interface Builder and resulting memory leaks. Therefor they suggest building everything in code again. I don't know where these concerns come from, but maybe someone with more experience than we have can give some insight on that topic. Doing a simple Google search doesn't really provide any information proofing that there are any problems with memory leaks created by the Interface Builder itself.

    Read the article

  • Interface injection in Spring Framework

    - by Aubergine
    There is article in here, however I am still in doubt, as some people keep confusing me. Doesn't Spring really support Interface injection at all? So what I want to clarify: setSomething(somethingInterface something); // this IS NOT interface injection, IT IS setter injection? Interface injection is when you just write `implements someExportedModuleInterface' and it configures it automatically? Could you please give an example of how this interface injection is done with Spring 'aware' interfaces? I am writing dissertation and I want to be sure what I am saying is not lie and correct.

    Read the article

  • How to define colors in XCodes' Interface Builder?

    - by favo
    Hi, I would like to copy colors between elements in the interface builder or define them using RGB values. I.e. copy the background color of a button to another button without duplicating the button. Or: Enter an exact RGB code using the interface builder. Currently I can do this only programmatically but the interface builder is meant to design the GUI, so there must be such possibilities. Thank you all in advance for your answers.

    Read the article

  • 6 Prominent Features of New GMail User Interface

    - by Gopinath
    GMail’s user interface has got a big make over today and the new user interface is available to everyone. We can switch to the new user interface by click on “Switch to the new look” link available at the bottom right of GMail (If you are on IE 6 or similar type of bad browsers, you will not see the option!). I switched to the new user interface as soon I noticed the link and played with it for sometime. In this post I want to share the prominent features of all new GMail interface. 1. All New Conversations Interface GMail’s threaded conversations is a game changing feature when it was first introduced by Google. For  a long time we have not seen much updates to the threaded conversation views. In the new GMail interface, threaded conversation sports a great new look – conversations are always visible in a horizontal fashion as opposed to stack interface of earlier version. When you open a conversation, you get a quick glance of individual thread without expanding the thread. Readability is improved a lot now.  Check image after the break 2. Sender Profile Photos In Email Threads Did you observe the above screenshot of conversations view? It has profile images of the participants in the thread. Identifying person of a thread is much more easy. 3. Advanced Search Box Search is the heart of Google’s business and it’s their flagship technology. GMail’s search interface is enhanced to let you quickly find the required e-mails. Also you can create mail filters from the search box without leaving the screen or opening up a new popup. 4. Gmail Automatically Resizing To Fit Multiple Devices There is no doubt that this is post PC era where people started using more of tablets and big screen smartphones than ever. The new user interface of GMail automatically resizes itself to fit the size of screen seamlessly. 5. HD Images For Your Themes, Sourced from iStockphoto Are you bored with minimalistic GMail interface and the few flashy themes? Here comes GMail HD themes backed by stock photographs sourced from iStockPhoto website. If you have a widescreen HD monitor then decorate your inbox with beautiful themes. 6. Resize Labels & Chat Panels Now you got a splitter between Labels & Chat panel that lets resize their height as you prefer. Also Label panel auto expands its height when you mouse over to show you hidden labels if any. Video – overview of new GMail features This article titled,6 Prominent Features of New GMail User Interface, was originally published at Tech Dreams. Grab our rss feed or fan us on Facebook to get updates from us.

    Read the article

  • Interface contracts – forcing code contracts through interfaces

    - by DigiMortal
    Sometimes we need a way to make different implementations of same interface follow same rules. One option is to duplicate contracts to all implementation but this is not good option because we have duplicated code then. The other option is to force contracts to all implementations at interface level. In this posting I will show you how to do it using interface contracts and contracts class. Using code from previous example about unit testing code with code contracts I will go further and force contracts at interface level. Here is the code from previous example. Take a careful look at it because I will talk about some modifications to this code soon. public interface IRandomGenerator {     int Next(int min, int max); }   public class RandomGenerator : IRandomGenerator {     private Random _random = new Random();       public int Next(int min, int max)     {         return _random.Next(min, max);     } }    public class Randomizer {     private IRandomGenerator _generator;       private Randomizer()     {         _generator = new RandomGenerator();     }       public Randomizer(IRandomGenerator generator)     {         _generator = generator;     }       public int GetRandomFromRangeContracted(int min, int max)     {         Contract.Requires<ArgumentOutOfRangeException>(             min < max,             "Min must be less than max"         );           Contract.Ensures(             Contract.Result<int>() >= min &&             Contract.Result<int>() <= max,             "Return value is out of range"         );           return _generator.Next(min, max);     } } If we look at the GetRandomFromRangeContracted() method we can see that contracts set in this method are applicable to all implementations of IRandomGenerator interface. Although we can write new implementations as we want these implementations need exactly the same contracts. If we are using generators somewhere else then code contracts are not with them anymore. To solve the problem we will force code contracts at interface level. NB! To make the following code work you must enable Contract Reference Assembly building from project settings. Interface contracts and contracts class Interface contains no code – only definitions of members that implementing type must have. But code contracts must be defined in body of member they are part of. To get over this limitation, code contracts are defined in separate contracts class. Interface is bound to this class by special attribute and contracts class refers to interface through special attribute. Here is the IRandomGenerator with contracts and contracts class. Also I write simple fake so we can test contracts easily based only on interface mock. [ContractClass(typeof(RandomGeneratorContracts))] public interface IRandomGenerator {     int Next(int min, int max); }   [ContractClassFor(typeof(IRandomGenerator))] internal sealed class RandomGeneratorContracts : IRandomGenerator {     int IRandomGenerator.Next(int min, int max)     {         Contract.Requires<ArgumentOutOfRangeException>(                 min < max,                 "Min must be less than max"             );           Contract.Ensures(             Contract.Result<int>() >= min &&             Contract.Result<int>() <= max,             "Return value is out of range"         );           return default(int);     } }   public class RandomFake : IRandomGenerator {     private int _testValue;       public RandomGen(int testValue)     {         _testValue = testValue;     }       public int Next(int min, int max)     {         return _testValue;     } } To try out these changes use the following code. var gen = new RandomFake(3);   try {     gen.Next(10, 1); } catch(Exception ex) {     Debug.WriteLine(ex.Message); }   try {     gen.Next(5, 10); } catch(Exception ex) {     Debug.WriteLine(ex.Message); } Now we can force code contracts to all types that implement our IRandomGenerator interface and we must test only the interface to make sure that contracts are defined correctly.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >