Matheus
Matheus
CC#
Created by Matheus on 8/20/2024 in #help
Body request
I will try to do this, ty
27 replies
CC#
Created by Matheus on 8/20/2024 in #help
Body request
But my .net version is 8, idk if is the same thing
27 replies
CC#
Created by Matheus on 8/20/2024 in #help
Body request
Idk but I will see for you
27 replies
CC#
Created by Matheus on 8/20/2024 in #help
Body request
The entire context is authentication with HMAC
27 replies
CC#
Created by Matheus on 8/20/2024 in #help
Body request
Im a new developer with c#
27 replies
CC#
Created by Matheus on 8/20/2024 in #help
Body request
And how works parameter bind?
27 replies
CC#
Created by Matheus on 8/6/2024 in #help
XML in an API
ok, ty
20 replies
CC#
Created by Matheus on 8/6/2024 in #help
XML in an API
No description
20 replies
CC#
Created by Matheus on 8/6/2024 in #help
XML in an API
i saw here, have 2,2mb its so light, but i'm so confuse with the exceptions
20 replies
CC#
Created by Matheus on 8/6/2024 in #help
XML in an API
i'm looking for to know that
20 replies
CC#
Created by Matheus on 8/6/2024 in #help
XML in an API
i'm not sure, but i have more than 200 pages
20 replies
CC#
Created by Matheus on 8/6/2024 in #help
XML in an API
i was trying to do this, but i always receive exception about the length, so i decide to ask here
20 replies
CC#
Created by Matheus on 8/6/2024 in #help
XML in an API
because i have a XML and a I need to put the information in a database
20 replies
CC#
Created by Matheus on 8/6/2024 in #help
XML in an API
yes
20 replies
CC#
Created by Matheus on 8/6/2024 in #help
XML in an API
this is the main question, i'm not sure if i work this entire xml I lost performance
20 replies
CC#
Created by Matheus on 8/6/2024 in #help
XML in an API
So i want to break this xml in pieces
20 replies
CC#
Created by Matheus on 8/6/2024 in #help
XML in an API
because if I work with entire xml, i'm leave in memory and that's not good, right?
20 replies
CC#
Created by Matheus on 8/6/2024 in #help
XML in an API
i'm facing with a huge xml, you know?
20 replies
CC#
Created by Matheus on 8/6/2024 in #help
XML in an API
this is my service
public class CsnuService : ICsnuService
{
private readonly HttpClient _httpClient;

public CsnuService(HttpClient httpClient)
{
_httpClient = httpClient;
}

public async Task<IEnumerable<XElement>> GetIndividualElementsAsync(string url)
{
if (string.IsNullOrEmpty(url))
{
throw new ArgumentException("URL cannot be empty.", nameof(url));
}

using var response = await _httpClient.GetStreamAsync(url);
using var reader = XmlReader.Create(response);
return GetIndividualElements(reader);
}

public IEnumerable<XElement> GetIndividualElements(XmlReader reader)
{
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element && reader.Name == "INDIVIDUALS")
{
while (reader.ReadToFollowing("INDIVIDUAL"))
{
yield return (XElement)XElement.ReadFrom(reader);
}

}
}
}
}
public class CsnuService : ICsnuService
{
private readonly HttpClient _httpClient;

public CsnuService(HttpClient httpClient)
{
_httpClient = httpClient;
}

public async Task<IEnumerable<XElement>> GetIndividualElementsAsync(string url)
{
if (string.IsNullOrEmpty(url))
{
throw new ArgumentException("URL cannot be empty.", nameof(url));
}

using var response = await _httpClient.GetStreamAsync(url);
using var reader = XmlReader.Create(response);
return GetIndividualElements(reader);
}

public IEnumerable<XElement> GetIndividualElements(XmlReader reader)
{
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element && reader.Name == "INDIVIDUALS")
{
while (reader.ReadToFollowing("INDIVIDUAL"))
{
yield return (XElement)XElement.ReadFrom(reader);
}

}
}
}
}
20 replies