delegates

Is there a more abbreviated way to define a custom event in C#3 and C#4?

In the following console application example, the event is defined like this: public delegate void PurchaseHandler(object obj, PurchaseArgs args); public event PurchaseHandler OnPurchaseMade; It seems to me after reading around that this might be a bit "C#2". Is there a more abbreviated way to express this with C#3 and C#4? using S...

Creating a property setter delegate

I have created methods for converting a property lambda to a delegate: public static Delegate MakeGetter<T>(Expression<Func<T>> propertyLambda) { var result = Expression.Lambda(propertyLambda.Body).Compile(); return result; } public static Delegate MakeSetter<T>(Expression<Action<T>> propertyLambda) { var result = Expressio...

NSURLConnectionDelegate connection:didReceiveData not working

Hi All, I need some help regarding the NSURLConnectionDelegate method. - (void)startDownload { NSString *URLString = [NSString stringWithFormat:appRecord.imageURLString]; NSURL *url = [NSURL URLWithString:URLString]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; imageConnection = [[NSURLConnection alloc] initWithReque...

C# specifying generic delegate type param at runtime

following setup, i have several generic functions, and i need to choose the type and the function identified by two strings at runtime. my first try looked like this: public static class FOOBAR { public delegate void MyDelegateType(int param); public static void foo<T>(int param){...} public static void bar<T>(int param){....

iphone app: delegate not responding

Hi guys.. So i'm very new to this iphone development stuff.... and i'm stuck. I'm building an app that connects to the twitter api. However when the connectionDidFinishLoading method gets called, it doesn't seem to recognise the delegate. Here's the source code of the request class: #import "OnePageRequest.h" @implementation OnePa...

When using delegates, need better way to do sequential processing

I have a class WebServiceCaller that uses NSURLConnection to make asynchronous calls to a web service. The class provides a delegate property and when the web service call is done, it calls a method webServiceDoneWithXXX on the delegate. There are several web service methods that can be called, two of which are say GetSummary and GetLi...

why can't I set a new instance's delegate as self?

I have a uipickerview, which appears with an ActionSheet. All this is in a class "MultiPicker". I create a new instance from "FirstViewController" this way: multiPicker *multiPic = [[multiPicker alloc]init]; multiPic.delegate = self; [multiPic action:aRunIndex]; And inside "multiPicker", in "action:" UIActionSheet *actionSheet ...

What is Action<string> ?

What is Action<string>, how can it be used? ...

linq delegate function checking from objects

I am trying to find the list of objects which can be replaced. Class Letter{ int ID; string Name; string AdvCode; int isDeleted; } Class Replacers{ int ID; string MainAdvCode; string ReplacesAdvCode; } example data: Replacers 0 455 400 1 955 400 2 955 455 LettersA 0 pack 455 1 addon 400 LettersB 0 big 955 1 pack 455 LettersC 0...

iPhone xcode - Best way to control audio from several view controllers

Hi, I am pretty new to iPhone programming. I have a navBar with three views. I need to control audio from all of the views. I only want one audio stream to play at a time. I was thinking that it would be smart to let my AppDelegate have an instance of my audioplaying class and let the three other views use that instance to control th...

Different behavior of reflected generic delegates with and without debugger

Hello. We have encountered some strange things while calling reflected generic delegates. In some cases with attatched debuger we can make impossible call, while without debugger we cannot catch any exception and application fastfails. Here is the code: using System; using System.Windows.Forms; using System.Reflection; namespace Gener...

Can an asynchronously fired event run synchronously on a form?

[VS 2010 Beta with .Net Framework 3.5] I've written a C# component to asynchronously monitor a socket and raise events when data is received. I set the VB form to show message boxes when the event is raised. What I've noticed is that when the component raises the event synchronously, the message box blocks the component code and locks t...

Returning NSNull from actionForLayer:forKey

If I implement the CALayer delegate method actionForLayer:forKey I can return [NSNull null] to force the CALayer to not animate any changes. Unfortunately, [NSNull null] doesn't implement the CAAction delegate and XCode kicks out the following warning: warning: class 'NSNull' does not implement the 'CAAction' protocol Here is the m...

iphone: Implement delegate in class

I am trying to call up a modal table view controller using presentModalViewController but I am not sure what to do about the delegate. The following code gives me an error: MyRidesListView *controller = [[MyRidesListView alloc] init]; controller.delegate = self; [self presentModalViewController:controller animated:YES]; [co...

iPhone: Remove annotation from MKMapView which is in another view

I have two views. The first is a MKMapView with some annotations. Clicking a UIButton pushes a second view on the stack. This has a UITableView with a list of annotations which correspond to the map annotations. So, when you click the delete button, how can I call my MKMapView which is in another view, so that I can remove the annota...

How can i mock or test my deferred evaluation/execution functionality?

I have what could be seen as a bizarre hybrid of IQueryable<T> and IList<T> collections of domain objects passed up my application stack. I'm trying to maintain as much of the 'late querying' or 'lazy loading' as possible. I do this in two ways: By using a LinqToSql data layer and passing IQueryable<T>s through by repositories and to m...

jQuery delegates with plugins

Hello, jQuery delegates are great, especially when using with table row click events. I was wondering if it's possible to use delegates with plug-ins as well? For example if I attach elastic plug-in to every text area, I would do: $("textarea").elastic(); But how would I attach this plug-in using delegate? ...

how to extend a protocol for a delegate in objective C, then subclass an object to require a conforming delegate.

I want to subclass UITextView, and send a new message to the delegate. So, I want to extend the delegate protocol, What's the correct way to do this? I started out with this: interface: #import <Foundation/Foundation.h> @class MySubClass; @protocol MySubClassDelegate <UITextViewDelegate> - (void) MySubClassMessage: (MySubClass ...

When to stop UIViewController from receiving delegate calls

In which UIViewController method should I set to nil all the occurrences of the view controller as a delegate? Is it viewDidUnload (too early?), dealloc (too late?) or something else? ...

Get parent page values from the usercontrol

How to get the parent page values from the usercontrol. I have a usercontrol in a page. On click of the usercontrols button i wanna get some values from the page after executing a method. i need those values in my usercontrol. What is the best way to get the results of the page in the usercontrol. ...