Creating an NRaas project Returning list from methodstore

Talk nerdy to us here.
Post Reply
User avatar
Chain_Reaction
Site Admin
Reactions:
Posts: 7595
Joined: December 30th, 2011, 6:00 pm
Answers: 81
Contact:

Returning list from methodstore

Post by Chain_Reaction » February 2nd, 2014, 2:21 pm

Is it possible to invoke a method using methodstore that returns a list of a type defined in the mod that is returning the list? Cause methodstore wants a type and I'm not sure what to give it... Or am I attempting the impossible again? :-)

User avatar
JunJayMdM
Reactions:
Posts: 262
Joined: April 2nd, 2012, 6:00 pm

Post by JunJayMdM » February 2nd, 2014, 2:33 pm

There are ways but that depends on what you're going to do with it after invoking it. You could go with "object" but it might be too generic. What's the type you're talking about?

User avatar
Chain_Reaction
Site Admin
Reactions:
Posts: 7595
Joined: December 30th, 2011, 6:00 pm
Answers: 81
Contact:

Post by Chain_Reaction » February 2nd, 2014, 10:49 pm

I am trying to return the list of SkillStamps from MasterController (MasterController.Settings.SkillStamps). I will be doing foreach on it after.

User avatar
JunJayMdM
Reactions:
Posts: 262
Joined: April 2nd, 2012, 6:00 pm

Post by JunJayMdM » February 3rd, 2014, 4:42 am

MasterController.Settings is an instance of MasterControllerSpace.PersistedSettings and I wouldn't use MethodStore on that, especially considering that you'll be dealing with Persistable fields.
Anyway, all the fields in Settings are stored in Persistence so they can be exported and imported. There's probably a way to import the SkillStamps from MasterController by using Persistence but that would require the other assembly to have the same class, otherwise those types won't be recognized, unless you treat them as "object", but they would become pretty useless

User avatar
Chain_Reaction
Site Admin
Reactions:
Posts: 7595
Joined: December 30th, 2011, 6:00 pm
Answers: 81
Contact:

Post by Chain_Reaction » February 3rd, 2014, 3:34 pm

Hmm. Okay, let me see what I can fish up on the persistence class. I just want to use/display them, not alter.

User avatar
JunJayMdM
Reactions:
Posts: 262
Joined: April 2nd, 2012, 6:00 pm

Post by JunJayMdM » February 3rd, 2014, 3:53 pm

You'd still need something to represent it in the assembly. If not the SkillStamp class, an interface located in NRaas.Common with a couple of properties or method to retrieve the values you want. This way you can find the types by having SkillStamp implement the interface and with MethodStore invoke the method to get the list

User avatar
JunJayMdM
Reactions:
Posts: 262
Joined: April 2nd, 2012, 6:00 pm

Post by JunJayMdM » February 3rd, 2014, 3:57 pm

P.S. You'd still require an external static method that you can invoke, such as :

<!-- ws:start:WikiTextCodeRule:0:
<pre class="text">public static List&lt;ISkillStamp&gt; GetSkillStamps()<br/>{<br/> // iterate over the list of skillstamps, cast to ISkillStamp, add to new list<br/>}</pre>
-->
<style type="text/css"><!--
/**
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
*/
.text {font-family:monospace;}
.text .imp {font-weight: bold; color: red;}
.text span.xtra { display:block; }

-->
</style><pre class="text">public static List<ISkillStamp> GetSkillStamps()
{
// iterate over the list of skillstamps, cast to ISkillStamp, add to new list
}</pre>


Post Reply