Getting "ArrayOf" added to arrays of ActiveRecord objects in the XML view returned by asp.net webservice using Mono

ASP.net Web Method:

[WebMethod()]
public Data.Subtitle[] GetAll()
{
    return Data.Subtitle.FindAll();
}

Here's the Subtitle class:

[ActiveRecord("Subtitle")]
public class Subtitle : ActiveRecordBase<Subtitle>
{
    [PrimaryKey(PrimaryKeyType.Assigned)]
    public int SubId {get;set;}

    [Property()]
    public int SubStreamId {get;set;}

    [Property()]
    public string SubTimeStart {get;set;}

    [Property()]
    public string SubTimeEnd {get;set;}

    [Property()]
    public string SubText {get;set;}

    public Subtitle () { }
}

And here the XML returns:

<?xml version="1.0" encoding="utf-8"?>
<ArrayOfSubtitle xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">
  <Subtitle>
    <SubId>862</SubId>
    <SubStreamId>1</SubStreamId>
    <SubTimeStart>00:01:04.4450000</SubTimeStart>
    <SubTimeEnd>00:01:08.2450000</SubTimeEnd>
    <SubText>Wikus van de Merwe
MNU Alien Affairs

</SubText>
  </Subtitle>
  <Subtitle>
    <SubId>863</SubId>
    <SubStreamId>1</SubStreamId>
    <SubTimeStart>00:02:11.3430000</SubTimeStart>
    <SubTimeEnd>00:02:14.8430000</SubTimeEnd>
    <SubText>Sarah Livingstone
Sociologist, Kempton Park University

</SubText>
</Subtitle>

I like the simplicity of representing data objects as web services with a single line of code, but I cannot get an array of objects Subtitleserialized without the "ArrayOf" prefix. My trips through Google pointed me to WCF objects that are not available in Mono, or manual serialization that I am trying to avoid.

Is there an easy way to represent an array of Subtitle objects as <Subtitles>in Mono?

+3
source share
1

: . xml , , , xml

var arr = myStr.Split(new char[] {'\n'}, StringSplitOptions.None);
var arr2 = "";
for (int i = 2; i < arr.Count()-1;i++ )
{
    arr2 += arr[i];
}

0 (xml), 1 (arrayofsubtitle) last (/arrayofsubtitle):

: - 3

+1

Source: https://habr.com/ru/post/1723277/


All Articles