delegation

How can I delegate an implementation to a mutable property in Kotlin?

你。 提交于 2019-12-07 07:57:14
问题 As to my understanding, the idea of delegating an implementation in Kotlin is to avoid code that looks like this: class MyClass(val delegate : MyInterface) : MyInterface { override fun myAbstractFun1() = delegate.myAbstractFun1() override fun myAbstractFun2() = delegate.myAbstractFun2() // ... } Instead, we can write the following code which should do the same: class MyClass(val delegate : MyInterface) : MyInterface by delegate Now, I'd like delegate to be a mutable variable, i.e. my code

Powershell v2 remoting and delegation

Deadly 提交于 2019-12-07 07:27:16
问题 I have installed Powershell V2 on 2 machines and run Enable-PsRemoting on both of them. Both machines are Win 2003 R2 and are joined to the same active directory domain and I can successfully run commands remotely. So PS remoting is working between the local server and remote server. But when I try to access a share on a 3rd server (dir \someOtherServer\builds), which is also Win 2003 R2 and joined to the same active directory, I get the error: Get-ChildItem : Cannot find path '

Scala forward or delegate methods to encapsulated object

笑着哭i 提交于 2019-12-07 06:12:10
问题 Is there any possibility to implicitly forward some of class methods to encapsulated object? case class Entity(id: Int, name: String,) { private lazy val lastScan = new LastScan def getLastScanDate = lastScan.getLastScanDate def updateLastScanDate = lastScan.updateLastScanDate } I want to avoid creating def updateLastScanDate = lastScan.updateLastScanDate just to forward methods to wrapped object. 回答1: In the plain language this is not possible. There used to be a compiler plugin by Kevin

Tool to generate interface implementation by delegation?

删除回忆录丶 提交于 2019-12-06 11:24:49
问题 I often need to implement an interface by delegating the implementation to a member of my class. This task is quite tedious because, even though Visual Studio generates stubs for the interface methods, I still have to write the code to delegate the implementation. It doesn't require much thinking, so it could probably be automated by a code generation tool... I'm probably not the first one to think of this, so there must be such a tool already, but I couldn't find anything on Google... Any

Clarity in classes implementing multiple interfaces (alternative to delegation):

独自空忆成欢 提交于 2019-12-06 05:00:27
问题 Let's say we've got the following: IFirst = Interface(IUnknown) function GetStuff: Integer; end; ISecond = Interface(IUnknown) function GetOtherStuff: Integer; end; TFirstSecond = class(TInterfacedObject, IFirst, ISecond) private function GetStuff: Integer; //implementation of IFirst function GetOtherStuff: Integer; //implementation of ISecond; end; I have never liked the fact that in TInterfacedObject there seems to be no way to distinguish between which methods implement which interfaces.

Method delegation in python

≯℡__Kan透↙ 提交于 2019-12-06 01:16:51
问题 I'm writing a small framework for orchestrating AWS clusters and there are some common hierarchical patterns that appear over and over again. One such pattern is gathering a collection of instances into a bigger object and then delegating some methods down to all the instances directly. So instead of copying and pasting the same boilerplate code over and over again I abstracted it with the following pattern: def __getattr__(self, item): if not item in self._allowed_items: raise

Impersonation and delegation (with SQL Server) in ASP.NET

南笙酒味 提交于 2019-12-05 16:51:45
I've written a simple ASP.NET application that works as a frontend for a simple MSSQL database. The application is accessible over the Internet. There are two physical servers involved: a WS2008R2 Active Directory domain controller which is also running MSQL Server 2008 R2, and another server, the webserver (WS2008R2/IIS7.5) where my application resides. The Application Pool for my application "FooPool" has its own AD User identity it runs under "FooUser". FooUser does not have any permission to access the SQL Server database, instead only my own personal user account "MyUser" has that

How can I delegate an implementation to a mutable property in Kotlin?

喜夏-厌秋 提交于 2019-12-05 11:32:56
As to my understanding, the idea of delegating an implementation in Kotlin is to avoid code that looks like this: class MyClass(val delegate : MyInterface) : MyInterface { override fun myAbstractFun1() = delegate.myAbstractFun1() override fun myAbstractFun2() = delegate.myAbstractFun2() // ... } Instead, we can write the following code which should do the same: class MyClass(val delegate : MyInterface) : MyInterface by delegate Now, I'd like delegate to be a mutable variable, i.e. my code looks like this: var delegate : MyInterface = MyImplementation() object MyObject : MyInterface by delegate

Impersonation and Delegation

对着背影说爱祢 提交于 2019-12-05 07:52:51
问题 I am using impersonation is used to access file on UNC share as below. var ctx = ((WindowsIdentity)HttpContext.Current.User.Identity).Impersonate(); string level = WindowsIdentity.GetCurrent().ImpersonationLevel); On two Windows 2003 servers using IIS6, I am getting different impersonation levels: Delegation on one server and Impersonation on the other server. This causes issues where I am unable to access the UNC share on the server with 'Impersonation' level. What could be causing this

NSURLSession delegation: How to implement my custom SessionDelegate class accordingly?

有些话、适合烂在心里 提交于 2019-12-05 03:27:30
问题 Got a singleton class, so called RequestManager, which shall handle requests made by different modules and background tasks of my application. @interface RequestFactory : NSObject - (void)requestDataWith:(NSString *)token id:(NSString *)id sender:(id<RequestFactoryDelegate>)sender; ... @end Then I got another class, so called SessionDelegate, which shall handle all the callbacks during the request. @interface SessionDelegate : NSObject <NSURLSessionDelegate, NSURLSessionTaskDelegate,