Representation of the ANY data type
fieranmason@gmail.com
#1 Posted : Monday, October 28, 2013 11:55:42 AM(UTC)
Rank: Member

Groups: Registered
Joined: 7/8/2013(UTC)
Posts: 22
Points: 66
Location: University of Victoria

Thanks: 5 times
Was thanked: 0 time(s) in 0 post(s)
Hello Everest,

We are considering the implications of using the ANY data type and would like to know what to expect from the ToString method. Is it true that the ToString method will produce a human readable string representation of all values that could be assigned to a reference of type ANY?

Regards
Fieran
justin.fyfe1
#2 Posted : Monday, October 28, 2013 12:01:27 PM(UTC)

Rank: Administration

Medals: Mobile Tech Grasshopper: Mobile Tech GrasshopperHealth Informatics MVP

Groups: Registered, Administrators
Joined: 7/22/2010(UTC)
Posts: 96
Points: 297
Man
Location: Hamilton, ON

Thanks: 2 times
Was thanked: 17 time(s) in 17 post(s)
Hi Fieran,

The ANY type is just a placeholder. Technically whenever you encounter a property with ANY Everest will populate the property with what the actual type was, so a call to ToString() will call the ToString() method of the class. For example this code:

Code:

Console.WriteLine(class.Value.ToString())


When this XML is present:

Code:

<value xsi:type="PQ" value="12" unit="[ft_i]"/>


Will result in the PQ class' ToString() method being printed (i.e. "12 [ft_i]")

Whereas

Code:

<value xsi:type="RTO_PQ">
     <numerator value="12" unit="[ft_i]"/>
     <denominator value="1" unit="s"/>
</value>


Would call the RTO<PQ> class' ToString() method being called (result in "12 [ft_i] / 1 s").

I believe all the data types have a ToString() method implementation, the exceptions being the more wacky types like SXPR, QSET, NPPD, etc. I can double check for you but it should work. If not, you can just post an issue here and we'll implement it or take a look at why an implementation wasn't completed.

Cheers
-Justin
1 user thanked justin.fyfe1 for this useful post.
fieranmason@gmail.com on 10/29/2013(UTC)
fieranmason@gmail.com
#3 Posted : Tuesday, October 29, 2013 11:11:10 AM(UTC)
Rank: Member

Groups: Registered
Joined: 7/8/2013(UTC)
Posts: 22
Points: 66
Location: University of Victoria

Thanks: 5 times
Was thanked: 0 time(s) in 0 post(s)
Thanks Justin
Exactly what we hoped for.

Fieran
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

SoClean Theme By Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.126 seconds.