Questions tagged [delegates]

Delegates can refer to several concepts. An object can rely on another (a delegate) to perform a function. Delegation can also refer to programming language feature making use of the method lookup rules for dispatching self-calls. In C#, a delegate defines which method to call when an event is triggered.

Filter by
Sorted by
Tagged with
0 votes
1 answer
20 views

Issues setting up WCSessionDelegate using SwiftUI

So I am learning how to setup the WCSession delegate for phone and watch. I feel like I am doing what Apple docs is advising but for whatever reason I am getting this log in my console: "...
AdrianGutierrez's user avatar
0 votes
0 answers
53 views

C++ Is it possible to use a consistent syntax when passing a function value or a function pointer

Since the type (Function vs Function pointer) is known at compile time, is it possible to use a consistent syntax which will pick the desired overload? using Function = void(*)(); void foo(){} ...
Macushla's user avatar
-1 votes
1 answer
30 views

Observe property change in Spring tests

Consider a Service-Bean, that sets a property on some schedule: @Service class UserService { var userInfo: Map<String, UserInfo>? = null @Scheduled(...) private fun fetchUserInfo()...
DFPy's user avatar
  • 1
-1 votes
1 answer
30 views

Listening to actions and passing parameters

I'm using Unity 2020.3.17f1, and I am working on a quest system. I want any script to be able to trigger an event, that the quest system will listen to and forward the quest progress based on that. I ...
Mavis de Ridder's user avatar
0 votes
1 answer
54 views

how to put an object of your own class in the Predicate delegate

I am making a data processing class, the return from the getData method of which is carried out on the basis of the function passed to it using the delegate Predicate.The getData method is planned to ...
Anton's user avatar
  • 5
-1 votes
0 answers
19 views

Exception when trying to bind a UFUNCTION with AddDynamic to a Delegate

Added UDP Component plugin (from here: https://github.com/getnamo/UDP-Unreal/tree/master) to my project and now im trying to bind a UFUNCTION HandleReceivedBytes (from my pawn class) to a Delegate ...
syat-cd's user avatar
-1 votes
0 answers
22 views

testing Delegates on destroyed MonoBehaviours

let's say I have a MonoBehaviour that calls this long-running method that has a callback that signals completion: public IEnumerator SomeLongOperation(System.Delegate cb) { yield return new ...
Jeffery Chow's user avatar
0 votes
1 answer
40 views

Delegate becomes nil from one class to another

I have this protocol and class which is the delegator L protocol userDetailsDelegate: AnyObject { func didSendUserDetails ( _ object: LoginViewController) } class LoginViewController: ...
Michael Drammond's user avatar
1 vote
0 answers
36 views

Getting "Error applying delegate" exception when applying GPU delegates on Android [closed]

I am getting an error on applying GPU delegates on my Samsung Galaxy S22. I have that checked that the GPU is present on the device. I have to run inferencing on Android Mobile. I have updated all the ...
James Clinton's user avatar
0 votes
2 answers
166 views

How to unchain asynchronous functions from delegates [duplicate]

I'm working on a Blazor server project, I have a repository service from which I'm executing database operations, and I have a razor component X which consumes that service. Basically, I want to ...
Youssef Bennour Sahli's user avatar
-1 votes
2 answers
48 views

WPF - How to change ContentControl view from sub-view?

I'm new to WPF/MVVM and building an application which runs "Jobs". The aplication currently looks like this: The MainView contains some buttons and a ContentControl. The ContentControl ...
CodeNinja's user avatar
  • 839
0 votes
1 answer
43 views

Pass event handler to object constructor as an argument

I have a method for executing batch scripts in memory by passing along a list of commands and executing them in a new Process. I use this method for running things like psql and gpg commands and it ...
G_Hosa_Phat's user avatar
  • 1,006
0 votes
0 answers
26 views

C# Moq Mocking a method that expects a Func<TResult> delegate [duplicate]

I need to setup a method with Moq so that I can control what it returns. The setup I'm trying to do looks like this: Setup(x => x.DoSomething<TResult>(It.IsAny<string>(), It.IsAny<...
mpmarven's user avatar
-2 votes
0 answers
19 views

C++/CLI: How do I create a delegate?

I have a problem regarding calls from C++ into a .NET assembly. The use case: I have a Windows application written in C++. I want to give users a chance to extend its functionality by writing a .NET ...
h.s.'s user avatar
  • 135
1 vote
2 answers
37 views

Can I simplify this delegate call when branching to other methods?

public MyDelegate HandleRemoteChange => (data) => DataSwitch.Invoke(data); private Func<ChangeMetadata, Action<ChangeMetadata>> DataSwitch => (d) => d.ChangeType switch { ...
NWoodsman's user avatar
  • 479
1 vote
1 answer
32 views

Why doesn't my class implement the interface despite having a defined event?

I am currently learning about events having the following code: public interface INotifyMessageChanged { public event EventHandler MessageChanged; } public class Academy : Organization, ...
Aleksandar's user avatar
0 votes
0 answers
21 views

To add contacts to sub domain using Google API

I need to add contacts in bulk to subdomain gsuite account using Google API but I am getting any specific technique or method that can be used to add contacts in sub domain account. As I have the ...
Aman's user avatar
  • 1
0 votes
1 answer
54 views

Why do I get error CS1660 when converting lambda expression

I need to optimize and add functionality to Powershell scripts for collecting and reconciling information from multiple sources of different types. These scripts are event-driven to be reactive and ...
Alain's user avatar
  • 43
1 vote
0 answers
26 views

C# Events and Delegates - How do I delay an event's subscriber from being called?

I learned about Events and Delegates, and have a simple example here: public class Subject { public delegate void RandomDelegate(); public event RandomDelegate randomEvent; void CallRandom() { ...
Lnio Yarschov's user avatar
0 votes
0 answers
79 views

Can a delegate in C# contain a collection of objects?

Assume the following Observer Pattern as described in the UML diagram below: Previously, the subscribers to the publisher were updated by the Notify() method in Academy through a collection List<...
Aleksandar's user avatar
0 votes
0 answers
26 views

Changing view color using Delegation

I have a UIView class ( delegator) within a UIViewcontroller class . I need to change color of viewed view in the UIViewcontroller using protocol conformance from the UIViewcontroller. I have the ...
Michael Drammond's user avatar
1 vote
2 answers
26 views

Can I use Scala 3 export in extension of opaque type to expose the inner type methods selectively?

I would like to have exports working with opaque tyeps in Scala 3: opaque type BigNumber = BigInt object BigNumber: def apply(s: String): BigNumber = BigInt(s) extension (cv: BigNumber) ...
Waldemar Wosiński's user avatar
1 vote
0 answers
42 views

How does koltin delegate access class delegated method?

There are some interfaces or classes blow: interface ITagProvider { fun getTag(): String } interface ITagPrinter { fun printTag() } class TagPrinter(val tagProvider: ITagProvider): ...
leimenghao's user avatar
0 votes
1 answer
37 views

Why doesn't delegate work in SwiftUI with UIViewControllerRepresentable?

Here's a sample code snippet for a video player in SwiftUI, where the player's core is implemented in UIKit (specifically in PlayerViewController): struct Page: View { let delegate = Delegate() ...
FaiChou's user avatar
  • 767
0 votes
0 answers
6 views

about staking on port.onflow.org

I'm writing to you because I've been delegating my tokens for over a year now. Last week I saw a request for destacking on one of my validators (I've never asked to withdraw my tokens) and today when ...
dohayonhotmailfr's user avatar
0 votes
0 answers
48 views

How can I solve Missing binding usage android delegate with Hilt

Hi I'm trying to use Android Delegate with Hilt. But when I try it I receive an error /news_api/app/build/generated/hilt/component_sources/bbc-newsDebug/com/newsapi/NewsApiApp_HiltComponents.java:146: ...
Bruno Brustoloni's user avatar
0 votes
1 answer
16 views

Directly Derive Delegate for Double Division

The double numerical type has a division operator. I can divide one double by another by simply writing x / y where x and y are both doubles. My understanding is that, in the computer, this operation ...
256Bits's user avatar
  • 384
0 votes
0 answers
28 views

Event won't trigger when subscribing to a casted object

I've got this code: public class StateController { public MainEventHandler EventHandler { get => eventHandler; } private State currentState; private MainEventHandler eventHandler = new(...
Bawenang Rukmoko Pardian Putra's user avatar
1 vote
1 answer
26 views

How to add another (object) delegate to existing using reflection?

I don't know how to cast d for using += operator for adding next method to d. Is here simplest way for it ? As explained first delegate lives outside the class and must be changed via reflection (not ...
SimpleCoder's user avatar
0 votes
0 answers
49 views

Python: base class overwrites methods of child class

I'm facing an issue where I want to "forward"/delegate a certain set of methods from the base class A to methods of the object alpha, however, when inheriting from it (class B) and ...
Xirraolyphus's user avatar
1 vote
1 answer
65 views

Extracting Delegates in generic methods

After some benchmarks I noticed most of my methods I created which use reflection are very, very slow, especially when used in iterations. I found a post from C# Corner, which shows how to create ...
Azzarrel's user avatar
  • 547
0 votes
3 answers
74 views

"modelData is not defined", inside repeater inside delegate

I would like to place swaths of color, as shown in the following picture. My qml experiments have been unsuccessful, I get ReferenceError: modelData is not defined for the color, even though the count ...
Thalia's user avatar
  • 13.7k
-1 votes
1 answer
68 views

C# Get the property name a Func<T> is set to

I have a Func<T> delegate points to a property/field from another class. I'd like to get the name of the target property/field from the Func<T> but I'm only seeing '<InitialiseModel>...
Jake Slack's user avatar
1 vote
0 answers
35 views

Implementing Delegate Methods in Swift from interface

I am trying to implement delegate methods in the source code so it can listen to changes that is exposed by a library. I could implement this: - (void)controllerDidCancel:(ControllerType *_Nonnull)...
Nex's user avatar
  • 92
0 votes
0 answers
24 views

TypeError for wrong number of arguments when correct number is given

Python's native exceptions are driving me insane. def __call__(self, *args, **kwargs): rtn = None if len(args) < self.positionals: raise TypeError(f"Expected ...
Azeranth 's user avatar
-1 votes
2 answers
62 views

convert action<> lambda to full delegate

I have the following code that uses a lambda: this.Notify(action: listener => listener.OnAccelerometersChanged(x, y, z)); action parameter is of type Action<IMyInterface>. I would like to ...
user avatar
0 votes
1 answer
21 views

Unity Actions/events/delegates confusion

Having some trouble setting up Actions in Unity for a small project I'm working on. Would love to get some guidance as I'm a little confused. basic setup is: I click a ui button element to move the ...
colossalchrist97's user avatar
-1 votes
1 answer
55 views

Pass delegate Action<T> explicitly to the method instead of anonymously

Let's say I'm adding a DbContext to services by dependency injection like this : builder.Services.AddDbContext<AppDbContext>(options => options.UseSqlServer(builder.Configuration....
Dear Deer's user avatar
  • 515
0 votes
0 answers
19 views

Passing data from a textfield in a custom cell to the tableview in Swift [duplicate]

I have a TableView Controller with 2 types of cell. In the first row i have a custom cell that contains a text field and a button. In the remaining rows i have standard cells just showing strings ...
PaulW's user avatar
  • 23
0 votes
1 answer
68 views

Detect Backspace Event on TextField using Subclass or Delegate Solution Integration problem

To preface, this problem has been solved using a couple of different methods - I'll leave the stack overflow post that has the solution here text The problem deals with detecting when the "delete&...
Sebastian's user avatar
-2 votes
1 answer
39 views

How to incrementally declare public events and then execute based on the same int?

What problem I'm trying to solve: I need the ability to incrementally fire off i number of methods, one method per trigger in the specified order. These methods have to be public unity events so that ...
Chiril Russu's user avatar
1 vote
0 answers
63 views

Microsoft Azure Graph Authentication - Current Windows User / Hardcoded User

I'm new to Azure and I'm trying to read user emails using the Microsoft Azure Graph. The email account I am trying to read never changes. So I am trying to "hardcode" it somewhere using an ...
stevetur29's user avatar
0 votes
0 answers
28 views

How can I get the QStyleOptionSpinBox to render the model value?

I am trying to create a column for a spin box delegate. Although I have the behaviour so that I can edit data and update the model, I cannot print the current model value into the cell. Unlike other ...
memelord23's user avatar
0 votes
0 answers
70 views

I have a c#.net dll with events , I want to use this event in delphi

I have a c#.net dll with events. I use it in C# like this: PcPos.CardSwiped += PosCardSwiped; and declare a procedure and i can get data in it but I want to use this event in delphi. when i import ...
Mohsen Moghadam's user avatar
1 vote
0 answers
22 views

Error: ArgumentException: Cannot bind to the target method because its signature is not compatible with that of the delegate type. in dot net core6

Error: ArgumentException: Cannot bind to the target method because its signature is not compatible with that of the delegate type This is in .NET Core 6; I wanted to add custom html helper textbox ...
pooja sankpal's user avatar
2 votes
1 answer
41 views

Link between Comparer<T>, IComparer<T> and Comparison<T>

I'm newbie to C#. I need to write a code which will sort an array of T. I ran into a problem with choosing comparing methods. According to my task, I should provide methods, working with Comparer<...
Svetlana's user avatar
0 votes
0 answers
47 views

CMWaterSubmersionManager setting delegate (or is it just a simple issue of missing something different)

I am following Apple documentation https://developer.apple.com/documentation/coremotion/accessing_submersion_data Created a new watchOS app with iOS companion app. Went into ContentView default code ...
justas180's user avatar
0 votes
0 answers
30 views

Register a delegate service to use in custom authorization attribute

I created a custom Authorization attribute and I want to use a service in it but I'm not sure how to use it there as dependency injection doesn't work well. public class MyAuthorizationAttribute : ...
user7849697's user avatar
-1 votes
1 answer
54 views

C# send actions from 1 scope to another

I couldn't find what I'm looking for, I tried different ways and none seems to work. There is any way for this to work? public class A { public void B(int num) { for (int i = 0; i < ...
fmj.SO's user avatar
  • 9
0 votes
0 answers
33 views

defining a self-returning method in C#

I have a method Append(string text, string color, SomeOtherParamsWeLlPretendDoNotExist){} I'd like for Append to return a reference to itself, to be able to call it like: Append("Title",&...
Andrea Bardelli's user avatar

1
2 3 4 5
227