2021年1月25日星期一

Provide an implementation of a C# abstract class in PowerShell

I'm trying to create a PowerShell-class implementation of an abstract class' function:

class ReadList : Intacct.SDK.Functions.AbstractFunction {        [string]$ObjectName            ReadList ([string]$ObjectName) {          $this.ObjectName = $ObjectName      }        [void] WriteXml ( [Intacct.SDK.Xml.IaXmlWriter]$xml ) {            $xml.WriteStartDocument()                    $xml.WriteStartElement("get_list")          $xml.WriteAttributeString("object",$this.ObjectName)              $xml.WriteEndElement() # </get_list>                 $xml.WriteEndDocument()          $xml.Flush()          $xml.Close()        }    }  

When I attempt to use it, I get a run-time exception:

Error during creation of type "ReadList". Error message: Method 'WriteXml' in type 'ReadList' from assembly 'PowerShell Class Assembly, Version=1.0.0.1, | Culture=neutral, PublicKeyToken=null' does not have an implementation.

I've tried adding the ref tag:

[void] WriteXml ( [Intacct.SDK.Xml.IaXmlWriter][ref]$xml ) {  

But I get a different error:

Multiple type constraints are not allowed on a method parameter.

Am I doing something wrong, or is what I'm trying to do not supported?

https://stackoverflow.com/questions/65888312/provide-an-implementation-of-a-c-sharp-abstract-class-in-powershell January 26, 2021 at 12:07AM

没有评论:

发表评论