locked
parameter domain for array in cord file RRS feed

  • Question

  • I have an action which takes string array as input parameter in my model.

    For example:

    static void AddMultiplePhotos(string[] multiplePhotos)

    {

    Contracts.Requires(errorMessage == null);

    foreach(string photo in multiplePhotos)

    {

    if(!allPhotos.Contains(photo))

    allPhotos.Add(photo);

    }

    }

    Parameter domain in cord file:

    action abstract static void Adapter.AddMultiplePhotos(string[] multiplePhotos)

    where {.

    Combination.In(multiplePhotos, {"photo1","photo2"});

    .};

    This is not working. Please let me know how to write parameter domain in cord file for action which takes string array as input parameter.

     

    Friday, May 7, 2010 6:54 AM

Answers

  • Hi Lei,

    It works. Thanks for mentioning about using Microsoft.Modeling;. Otherwise I would end up in another error.

    Friday, May 14, 2010 3:47 AM

All replies

  • Hello Sathaiah:

    Spec Explorer does not allow arrays as parameters. Rule method parameter types are restricted to primitive types, structs, compound values, native types and model object types that have a valid binding to an implementation object type. Types such as Array, SetContainer and SequenceContainer cannot be used as action parameter anymore.

    Thanks,

    Rob

    Monday, May 10, 2010 3:24 PM
  • Hi Rob,

    So is there any other solution to the above problem. I mean can I replace array with some other input parameter type to make the above model work?

    Wednesday, May 12, 2010 6:55 AM
  • Hi Sathaiah,

       I think "Sequence" could be work around

    action

     

     

    abstract static void Adapter.AddMultiplePhotos(Sequence<string> multiplePhotos) where multiplePhotos in {Sequence<string>{"photo1","photo2"}};

    Don't forget using Microsoft.Modeling;

    I am sure you have known the difference between Sequence and SequenceContainer. since your last qustion. :)

    http://social.msdn.microsoft.com/Forums/en-US/specexplorer/thread/cb9d0f9c-1cf9-48d2-ab57-5e1be3bb8d8a

    hope helpful

    Lei

    Thursday, May 13, 2010 9:31 AM
  • Hi Lei,

    It works. Thanks for mentioning about using Microsoft.Modeling;. Otherwise I would end up in another error.

    Friday, May 14, 2010 3:47 AM