Asset.CreateNonNativeAsset
is a simple factory method to create an Asset instance of the right subtype.
https://github.com/elucidsoft/dotnet-stellar-sdk/blob/master/stellar-dotnet-sdk/Asset.cs#L19-L29
The values for code
and issuer
will be the same as the values you provided as parameters.
I suspect the reason you cannot access these values on the returned type is because the parent type Asset
is returned. It is realised in subtypes by AssetTypeNative
, AssetTypeCreditAlphaNum4
and AssetTypeCreditAlphaNum12
. The first of these three do not have code
and issuer
values, so the parent type doesn't have it either. I'm not familiar with C#, but I suspect you would need to detect the subtype and cast it before you can access the fields.
From memory, this is the approach taken in Java SDK too.
As an aside, I chose to use a different hierarchy when building the Scala SDK in order to avoid type problems like you describe:
Asset
+ NativeAsset
+ NonNativeAsset(code, issuer)
+ IssuedAsset4
+ IssuedAsset12
Asset(code, issuer)
only returns instances of NonNativeAsset
. In this way you can always pattern match or directly access the fields:
@ Asset("FRUIT", KeyPair.random) match {
case IssuedAsset4(code, issuer) => s"$code from ${issuer.accountId}"
case IssuedAsset12(code, issuer) => s"$code from ${issuer.accountId}"
}
res5: String = "FRUIT from GAKNBE6KCPJQZMJQCDVYNSSQU5B4BWIHGSDRBSHGYLWHE2D5H3TRWTUK"