proxy-classes

Can't set “apply” trap to Proxy object

≡放荡痞女 提交于 2019-11-28 08:35:41
I created a Proxy object with an "apply" trap: var target = {}, handler = { apply: () => 42 } proxy = new Proxy(target, handler); Therefore, the Proxy object should be callable. However, it doesn't work: proxy(); // TypeError: proxy is not a function Why? According to the definition of the [[Call]] internal method of Proxy objects it should work: Let trap be GetMethod ( handler , "apply" ). Return Call ( trap , handler , « target , thisArgument , CreateArrayFromList ( argumentsList )»). However, there is a problem: not all Proxy objects have the [[Call]] method: A Proxy exotic object only has

Can I stop service reference generating ArrayOfString instead of string[]?

做~自己de王妃 提交于 2019-11-28 07:27:35
问题 I have a web method with a signature like this: public string[] ToUpper(string[] values) I am using the 'Add Service reference' in Visual Studio 2010 to generate a reference to my service. Unfortunately, this process creates a proxy class called 'ArrayOfString' and uses this type instead of the expected 'string[]' type. The generated async service call signature ends up looking like this: public void ToUpperAsync(Demo.ServiceReference.ArrayOfString values) { } public void ToUpperAsync(Demo

Could multiple proxy classes make up a STL-proof bitvector?

流过昼夜 提交于 2019-11-28 02:56:48
问题 It's well known that std::vector<bool> does not satisfy the Standard's container requirements, mainly because the packed representation prevents T* x = &v[i] from returning a pointer to a bool. My question is: can this be remedied/mitigated when the reference_proxy overloads the address-of operator& to return a pointer_proxy? The pointer-proxy could contain the same data as the reference_proxy in most implementations, namely a pointer into the packed data and a mask to isolate the particular

Force .NET webservice to use local object class, not proxy class

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-27 22:33:55
I have a webservice that I'm calling from a windows forms application (both .NET, both in the same solution), and I'd like my webservice to return a custom object from elsewhere in the project - it's a common object that they both share a reference to, as it's in the third project in my solution. When I call the webservice, it returns a "Person" object, but it's in the namespace of the webservice, and it's created from a proxy class that the webservice itself generated. As such, I can't manipulate it and return it to my program, which is expecting a "Person" object based on the shared copy of

django model polymorphism with proxy inheritance

浪尽此生 提交于 2019-11-27 16:41:39
问题 My Discount model describes common fields for all types of discounts in the system. I have some proxy models which describe concrete algorithm for culculating total. Base Discount class has a member field named type , which is a string identifing its type and its related class. class Discount(models.Model): TYPE_CHOICES = ( ('V', 'Value'), ('P', 'Percentage'), ) name = models.CharField(max_length=32) code = models.CharField(max_length=32) quantity = models.PositiveIntegerField() value =

How do I serialize all properties of an NHibernate-mapped object?

試著忘記壹切 提交于 2019-11-27 15:36:30
I have some web methods that return my objects back as serialized XML. It is only serializing the NHibernate-mapped properties of the object... anyone have some insight? It seems to be that the web methods are actually serializing the NHibernate proxies instead of my classes. I've tried using [XMLInclude] and [XMLElement], but the properties are still not serializing. I have a really horrible hackish way of getting around this, but I wondered if there was a better way! Something like this: <?xml version="1.0" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="StoryManager"

Typescript “this” inside a class method

与世无争的帅哥 提交于 2019-11-27 07:21:39
I know this is probably painfully basic, but i am having a tough time wrapping my head around it. class Main { constructor() { requestAnimationFrame(this.update); //fine } update(): void { requestAnimationFrame(this.update); //error, because this is window } } It appears to be the case that I need a proxy, so lets say using Jquery class Main { constructor() { this.updateProxy = $.proxy(this.update, this); requestAnimationFrame(this.updateProxy); //fine } updateProxy: () => void update(): void { requestAnimationFrame(this.updateProxy); //fine } } But coming from an Actionscript 3 background, I

How to test if an object is a Proxy?

微笑、不失礼 提交于 2019-11-27 04:28:46
I would like to test if a JavaScript object is a Proxy . The trivial approach if (obj instanceof Proxy) ... doesn't work here, nor does traversing the prototype chain for Proxy.prototype , since all relevant operations are effectively backed by the underlying target. Is it possible to test if an arbitrary object is a Proxy? In my current project I also needed a way of defining if something was already a Proxy, mainly because I didn't want to start a proxy on a proxy. For this I simply added a getter to my handler, which would return true if the requested variable was "__Proxy": function

Dynamically generate classes at runtime in php?

故事扮演 提交于 2019-11-27 03:04:45
问题 Here's what I want to do: $clsName = substr(md5(rand()),0,10); //generate a random name $cls = new $clsName(); //create a new instance function __autoload($class_name) { //define that instance dynamically } Obviously this isn't what I'm actually doing, but basically I have unknown names for a class and based on the name, I want to generate the class with certain properties etc. I've tried using eval() but it is giving me fits over private and $this-> references... //edit Ok, obviously my

Can't set “apply” trap to Proxy object

白昼怎懂夜的黑 提交于 2019-11-27 02:17:37
问题 I created a Proxy object with an "apply" trap: var target = {}, handler = { apply: () => 42 } proxy = new Proxy(target, handler); Therefore, the Proxy object should be callable. However, it doesn't work: proxy(); // TypeError: proxy is not a function Why? 回答1: According to the definition of the [[Call]] internal method of Proxy objects it should work: Let trap be GetMethod( handler , "apply" ). Return Call( trap , handler , « target , thisArgument , CreateArrayFromList( argumentsList )»).