proxy-classes

Object hierarchy returned by WCF Service is different than expected

牧云@^-^@ 提交于 2019-12-04 17:18:12
My understanding may be wrong, but I thought once you applied the correct attributes the DataContractSerializer would render fully-qualified instances back to the caller. The code runs and the objects return. But oddly enough, once I look at the returned objects I noticed the namespacing disappeared and the object-hierarchy being exposed through the (web applications) service reference seems to become "flat" (somehow). Now, I expect this from a web-service…but not through WCF. Of course, my understanding of what WCF can do may be wrong. ...please keep in mind I'm still experimenting with all

How do I make a class, which I can't change, implement an interface?

吃可爱长大的小学妹 提交于 2019-12-04 09:44:41
问题 I have a class from another library that is closed-source, but I want to be able to use an interface for it. The reason being that I don't want to do instanceof checks or null -checks everywhere, but I also don't want to extend the existing class. For example, let's say I have this code: public class Example { // QuietFoo is from another library that I can't change private static QuietFoo quietFoo; // LoudFoo is my own code and is meant to replace QuietFoo private static LoudFoo loudFoo;

How to use java proxy in scala

时间秒杀一切 提交于 2019-12-04 04:29:34
I have an interface as Iface that has two methods written in java. That interface is an inner interface of Zzz class. I have written the invocation handler in scala. Then I tried to create a new proxy instance in scala like below. val handler = new ProxyInvocationHandler // this handler implements //InvocationHandler interface val impl = Proxy.newProxyInstance( Class.forName(classOf[Iface].getName).getClassLoader(), Class.forName(classOf[Iface].getName).getClasses, handler ).asInstanceOf[Iface] But here the compiler says that $Proxy0 cannot be cast to xxx.yyy.Zzz$Iface How can I do this with

Why does Django create migration files for proxy models?

有些话、适合烂在心里 提交于 2019-12-04 01:10:02
I just created a proxy model and was surprised that manage.py makemigrations creates a new migration file with a migrations.CreateModel operation. A proxy model does not create a new database table, it's just a different python interface to the same dataset and indeed manage.py sqlmigrate my_app_label 0042 returns nothing. I thought that it might be used to create the proxy model ContentType but those are created on demand if they don't exist. Is it used to trigger the creation of the proxy model permissions? There's a 6 year old open bug on proxy model permissions so I'm not really sure how

Loading from database without proxy classes?

南楼画角 提交于 2019-12-03 13:29:28
In Entity Framework 4 Is it possible to choose to load some queries into a POCO without it using proxy classes? (For the purpose of caching that object for future read only use). I am using the Repository - Service pattern. By this I mean: var order = _orderService.GetById(1); // after order is loaded then we can see in the debugger that: // order.Customer is of type System.Data.Entity.DynamicProxy.Customer_17631AJG_etc What I want is for the order.Customer to actually use the POCO type MyApp.Models.Entities.Customer instead of a proxy to that type. EDIT: Based on Ladislav's suggestion to add

Passing temporaries as non-const references in C++

我怕爱的太早我们不能终老 提交于 2019-12-03 07:40:17
问题 I have the following piece of code, as an example dec_proxy attempts to reverse the effects of the increment operator upon the type that is executed in a complex function call foo - which btw I cannot change the interface of. #include <iostream> template<typename T> class dec_proxy { public: dec_proxy(T& t) :t_(t) {} dec_proxy<T>& operator++() { --t_; return *this; } private: T& t_; }; template<typename T, typename S, typename R> void foo(T& t, S& s, R& r) { ++t; ++s; ++r; } int main() { int

Why won't DynamicProxy's interceptor get called for *each* virtual method call?

*爱你&永不变心* 提交于 2019-12-03 03:25:37
An example explains it best : public interface IA { void foo(); void bar(); } public class A : IA { public virtual void foo(){ Console.Write("foo"); bar(); //call virtual method } public virtual void bar(){ Console.Write("bar"); } } public class Interceptor : IInterceptor { public void Intercept(IInvocation invocation) { Console.WriteLine("Intercepted: " + invocation.Method.Name); invocation.Proceed(); } } Main(){ IA a = new A(); //proxy-ing an interface, given an implementation IA proxy = new Castle.DynamicProxy.ProxyGenerator() .CreateInterfaceProxyWithTarget(a, new Interceptor()); proxy.foo

Generating a JS-client based on a ASP.NET WebAPI Controller

非 Y 不嫁゛ 提交于 2019-12-02 16:57:11
In modern web-projects that use RESTful API's we often see AJAX-calls like the one below littered around our JavaScript-files. $.ajax({ type: "POST", url: myapp.baseUrl + 'Api/Note', data: ko.mapping.toJSON(note), contentType: 'application/json', }).done(function (response) { // do something }).fail(function (jqxhr) { // do something else }); I love WebAPI, I love Knockout and I love tying the two together. However these AJAX-calls are quite verbose and contain all kinds of details that I am not really interested in. So instead, I create a wrapper around these methods: myapp.api.saveNote(note)

Date Conversion issue from webservice

萝らか妹 提交于 2019-12-02 13:01:41
I am consuming a Web Service which will return datetime fields in response object. My reference.cs file has, private System.DateTime timestampField; public System.DateTime Timestamp { get { return this.timestampField; } set { this.timestampField = value; } } In SOAP UI when I called the service I see it's returning as 2014-06-09T21:24:56+00:00 , 2014-06-17T05:42:00-04:00 I have different Offsets for Different values.. But from my .NET App when I am calling it's converting to some other value as 6/9/2014 5:24:56 PM but it should be whose actual value is 6/9/2014 9:24 pm . How can I fix this?

Why does Doctrine\\ORM\\Configuration's “DoctrineProxies” Object contain the Universe?

☆樱花仙子☆ 提交于 2019-12-02 12:20:13
In my ORM code I have an Entity with a field fined like so: //part of entity class Item: /** @Column(name="product_id", type="integer") */ private $productId; I then executed this code: //3 lines ~straight out of Doctrine configuration to get EntityManager include 'config/doctrine-config.php'; $config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode); $em = EntityManager::create($dbParams, $config); //my own code to retrieve an entity instance: $instance = $em->find(Item::class, 2); print_r($instance); And this is the output I get (skipping few other similar properties):