interface

not seeing UDP multicast messages from another device

半城伤御伤魂 提交于 2019-12-24 12:00:23
问题 I have a Windows machine where I have two scripts that send and receive messages via UDP multicast (on the same machine). I have a C and Python3 implementation of this. The Python3 one looks like this: sender.py import socket MCAST_GRP = '239.1.1.1' MCAST_PORT = 1234 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 2) print("Sending") sock.sendto(bytearray("str()", "utf-8"), (MCAST_GRP, MCAST_PORT)) data,

ASM transformation to find concrete class type

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 10:46:39
问题 I'm working on a project that will trace method calls from a class within a package to any other class. It's important that I can identify concrete types, and I'd prefer to have a minimum tracing overhead. There is no restrictions on when the probe is triggered; it can be before or after a method has been called. ASM is currently used, but there is no requirement for it. The system is moving from AspectJ in order to allow dynamic attachment, so that's out. Below is the current situation. A

Typescript abstract class static method not enforced

自作多情 提交于 2019-12-24 10:16:00
问题 I have this simple code in TypeScript: abstract class Config { readonly NAME: string; readonly TITLE: string; static CoreInterface: () => any } class Test implements Config { readonly NAME: string; readonly TITLE: string; } Even though the CoreInterface() member is missing in the Test class, TypeScript does not complain. Why is this? I need every derived class to provide some metadata about itself in the CoreInterface() static function. I know I could just extend the Config class and have

Separate Get/Set property in inherited interfaces in C# [duplicate]

寵の児 提交于 2019-12-24 09:29:37
问题 This question already has answers here : C#: interface inheritance getters/setters (4 answers) Closed 3 years ago . I have two interfaces and one implementation: IState , IEditableState and State , in which I have a single integer property called Value . I want to be using IState to get this property and IEditableState to set it. My code looks thusly: interface IState { int Value { get; } } interface IEditableState:IState { int Value { set; } } class State:IEditableState { int Value { get;

What's the point to have public method in class but not in interface?

我的未来我决定 提交于 2019-12-24 08:57:32
问题 For example: public interface IMessageService { void ProcessMessages(IEnumerable<Message> messages); } Implemented the interface: public class MessageService : IMessageService { public void ProcessMessages(IEnumerable<Message> messages) { // whatever } } Then realized that ProcessMessages should be broken down a little bit to handle different parts of the message: public class MessageService : IMessageService { public void ProcessMessages(IEnumerable<Message> messages) { foreach (var msg in

Can I implement an interface in a C# in an .h file?

偶尔善良 提交于 2019-12-24 07:38:24
问题 I have an interface that is used by several classes and the interface implementation is the same for all the classes. I would make it a base abstract class, but then it would stop the deriving classes from inhering from another class later on, which I need. So instead of reimplementing the same interface in all the classes, can I somehow implement the interface in one place, like an .h file and include the .h file in the cs file so the class "implements" the interface. By the way, the

One method to handle all the struct types that embed one common struct (json marshalling)

我们两清 提交于 2019-12-24 06:47:13
问题 I have a gin-gonic web app with somewhat MVC architecture. I created a couple of models, all of them embed one common struct: type User struct { ID int Name string } type Admin struct { User Level int } ... { User } Now I want to store them in database in json format. The goal I want to accomplish is to code only one function/method that will marshal any model and will save save it into DB. This method must marshal all the fields of current model, not only from User struct, e.g. User must be

Common filtering logic in WCF query interceptors using interface

徘徊边缘 提交于 2019-12-24 06:22:49
问题 The classes in my data model implement an interface: public class SomeType : ISomeInterface public interface ISomeInterface In my WCF query interceptors, I want to use a common Expression so that I can use the same filtering logic on multiple types: [QueryInterceptor("SomeType")] public Expression<Func<SomeType, bool>> SomeTypeInterceptor() { // Return CommonFilter() or extend it with logic unique to SomeType } private Expression<Func<ISomeInterface, bool>> CommonFilter() { // Use

Common filtering logic in WCF query interceptors using interface

流过昼夜 提交于 2019-12-24 06:22:13
问题 The classes in my data model implement an interface: public class SomeType : ISomeInterface public interface ISomeInterface In my WCF query interceptors, I want to use a common Expression so that I can use the same filtering logic on multiple types: [QueryInterceptor("SomeType")] public Expression<Func<SomeType, bool>> SomeTypeInterceptor() { // Return CommonFilter() or extend it with logic unique to SomeType } private Expression<Func<ISomeInterface, bool>> CommonFilter() { // Use

“Standard simple” interfaces in Java?

▼魔方 西西 提交于 2019-12-24 06:07:09
问题 So here in Java I've written a typical class, to send json to a rest server. (I'll include the whole class below for clarity.) So that's a file "Fetcher.java" Now for the callback you need an interface. The interface is trivial, just one function with a string. public interface FetcherInterface { public void fetcherDone(String result); } Annoyingly you need a whole file for that, "FetcherInterface.java" So this interface is nothing but "one callback with a string". Often all you need is just