Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Welcome, Guest. Please login or register.
November 24, 2017, 02:30:43 AM
Home Help Search Login Register
News: Please DM @puremvc on Twitter to gain forum access. Spambots are why we can't have nice things.
Pages: [1]
Print
Author Topic: NAME property of Proxies  (Read 6059 times)
swidnikk
Courseware Beta
Jr. Member
***
Posts: 13


View Profile Email
« on: November 02, 2009, 12:15:53 PM »

I've used PureMVC AS3 Multicore for sometime now and am playing around with C# port.

The Proxy pattern has a public static NAME property with a default value of "Proxy", however after creating an instance of the proxy class (or a subclass) this NAME property is left as its default value.

This means in a command when I want to retrieve a proxy, I must manage my proxy names, where as, if I'm not mistaken, in AS3, the NAME static variable is reassigned in the constructor to reflect a particular proxy instance's given name. In this way I can retrieve a proxy by Facade.RetrieveProxy( MyProxy.Name ).

Is it by design that the static NAME variable is not reassigned in the constructor?
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW
« Reply #1 on: November 04, 2009, 08:20:25 AM »

The NAME variable is not overwritten in the constructor in AS3. Instead it is passed to the superclass (Proxy) where it is set as the proxyName property, which the framework requests from the class by calling getProxyName();

Looking at the C# source for Proxy, I can see it uses three overloaded constructors to allow calling with:
  *  no arguments (constructs with NAME and no data),
  *  a proxy name only (constructs with supplied name and no data),
  *  or a proxy name and an object (constructs with supplied name and data)

This seems ok to me if NAME can be overridden in the subclass.

-=Cliff>
Logged
adamczak
Moderator
Jr. Member
*****
Posts: 10


View Profile Email
« Reply #2 on: November 13, 2009, 02:10:25 AM »

If you actually compare the sources of the ActionScript Proxy and C# Proxy, the code for the static NAME variable and the constructors are almost exactly the same (the three constructor overload correspond to the default values allowed in the ActionScript constructor).  The way to typically use a name on the proxy, is that you create a "public new const string NAME" on your subclass with a class specific value, and you use that NAME variable to retrieve or remove proxies.  This is the same usage pattern used in the ActionScript implementation.

Andy
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW
« Reply #3 on: November 13, 2009, 01:10:21 PM »

Yep. And this is the way it works with AS3 as well. The NAME on the superclass is just so that if you don't pass anything something gets registered.

-=Cliff>
Logged
Pages: [1]
Print
Jump to: