Hi,
I've got a class that's got a bunch of public methods, and I'd like to reflect over it to find the set of member methods that could be used as a particular delegate.
For example:
delegate void InterestingFunc(int i);
class Entity
{
public void F();
public void G();
public void H(int i);
public void X(int i);
}
C...
In C#, how does one create a delegate type that maps delegate types to a delegate type?
In particular, in my example below, I want to declare a delegate Sum such that (borrowing from mathematical notation) Sum(f,g) = f + g. I then want to invoke Sum(f,g) -- such as Sum(f,g)(5) [this meaning f(5) + g(5)].
class Example
{
delegate int ...
I'm writing a wrapper for another library and I would like to know the BCP for receiving the data returned via the delegate and returning that response to the instance that called the wrapper object.
// Original_Instance.m
BOOL example = [wrapperInstance getSomeData];
// Wrapper_Instance.m
[self thisWillReturnDataToTheDelegate];
retur...
From How to: Publish Events that Conform to .NET Framework Guidelines
Although events in classes that you
define can be based on any valid
delegate type, even delegates that
return a value, it is generally
recommended that you base your events
on the .NET Framework pattern by using
EventHandler, as shown in the
followin...
I'm writing my first iPhone application and I'm having trouble switching views. I have 2 views and a reference to each in the AppDelegate (an instance of UIApplicationDelegate). I create instances of both in the applicationDidFinishLaunching and immediately show the first view. This works fine.
The problem is the reference to the o...
I suppose in some ways either (or both) Delegate or MethodInfo qualify for this title. However, neither provide the syntactic niceness that I'm looking for. So, in short, Is there some way that I can write the following:
FunctionPointer foo = // whatever, create the function pointer using mechanisms
foo();
I can't use a solid delegate...
I am assigning protocols in a couple classes that follow an inheritance tree. Like so:
first class
@protocol LevelOne
- (void) functionA
@end
@interface BaseClass : NSObject <LevelOne> {
}
second class
@protocol LevelTwo <LevelOne>
- (void) functionB
@end
@interface SubClass : BaseClass <LevelTwo> {
}
Later I am assigning the c...
Hi
See the second bit of code below.. code doesn't compile. Am trying to figure out anon methods, and I get it..
But not the example of not using anon methods which I found on the web, which doesn't compile
Using VS2008.. compiling to .NET3.5
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
nam...
I have a collection class with an Equals method that I want to pass in a method to do equality checking between each item. Furthermore, I want to allow the delegate type to operate on superclasses of T as well as T itself:
public delegate bool EqualityComparer<T>(T x, T y);
public class Collection<T>
{
//...
public bool Equals...
I have some VERY inefficient code in which many lines appear 4 times as I go through permutations with "<" and ">" operations and a variety of variables and constants. It would seem that there is a way to write the function once and pass in the operators along with the necessarily changing values and"ref" variables. What technique do I...
Reading from MSDN:
"A delegate is a type that references a method. Once a delegate is assigned a method, it behaves exactly like that method."
Does then "delegate" mean a type or an object?!
...It cannot be both. It seems to me that the single word is used in two different meanings:
a type containing a reference to a method of some s...
For instance... if i have a method that performs some asynchronous operation and i want to notify/call some sort of callback once it's done, would i use delegate?
I can't seem to get my head round how that would work. Can anyone point me in the right direction?
I was looking at something like....
public class ContentContext
{
...
I'm trying to create a custom extension of BasicSliderUI. I'm just trying to make the thumb a circle (note I'm in the Windows L&F). I've created a very simple implementation that just calls g.drawOval, but whenever I drag it, it leaves a "trail" behind. Any ideas why this is?
thanks,
Jeff
...
Hello. I have the following code on a control of my own:
MethodInvoker _mi;
public MethodInvoker MI { get { return _mi; } set { _mi = value; } }
I thought the IDE would recognize this delegate, and allow me to choose a suitable already implemented function or create a new one if I wanted, just like it does to events, although at least...
When one Implements an Interface (equivalent to a Protocol in Objective-C) in the .Net environment, the IDE automatically adds the properties and methods that need to be implemented to the class' file. Is there a setting that will result in a similar behavior in the Xcode environment? Will it do the same for a delegate?
At this point,...
What is the Java equivalent of Cocoa delegates?
(I understand that I can have an interface passed to a class, and have that class call the appropriate methods, but I'm wondering if there is any other way to achieve something closer to Cocoa/Objective-C's informal protocols)
...
I am doing a small multithreaded app that uses asynchronous TCP sockets, but I will get to the point: I am using a custom event to read a value from a form and the delegate used by the event returns a string when finished.
My question here is: is that correct? is it Ok to return values from the events? or is there a best way to do this?...
EDIT: Highlight difficulties with virtual and/or value-type methods
Can you create a delegate of an instance method without specifying the instance at creation time? In other words, can you create a "static" delegate that takes as it's first parameter the instance the method should be called on?
For example, how can I construct the fo...
I am trying to change the active index of a multiview by using a delegate and it doesn't work as i expect.
this is my code
protected void ucWaitPage_FinishedWaiting(PerformAfterWaitDelegate performAfterWait)
{
performAfterWait.Invoke();
this.SetIndex();
}
private void SetIndex()
{
this.m...
When i store a delegate (that points to a page method) in session state, retrive it after a postback and execute it the target of the delegate is the old page object and not the current one, is there anyway to change the target of the delegate so that it executes the method on the current page object ?
I have thought about using a stati...