Motley
Motley
CC#
Created by Zee on 9/28/2024 in #help
the namespace is not recognised
Good Luck!
16 replies
CC#
Created by Zee on 9/28/2024 in #help
the namespace is not recognised
So if both projects need access to something, you put it in the REST API project.
16 replies
CC#
Created by Zee on 9/28/2024 in #help
the namespace is not recognised
You should have your REST API standalone not depending on anything. Your application should be built on top of that.
16 replies
CC#
Created by Zee on 9/28/2024 in #help
the namespace is not recognised
Yup
16 replies
CC#
Created by Zee on 9/28/2024 in #help
the namespace is not recognised
Although... Honestly, I'm not sure why you are having an issue doing what you did.
16 replies
CC#
Created by Zee on 9/28/2024 in #help
the namespace is not recognised
I think you have that backwards. Move the models you need to use in your API project to the API project. Then make the App reference the API project.
16 replies
CC#
Created by Zee on 9/28/2024 in #help
the namespace is not recognised
Why is the API referencing things from the app?
16 replies
CC#
Created by Zee on 9/28/2024 in #help
the namespace is not recognised
No description
16 replies
CC#
Created by Zee on 9/28/2024 in #help
the namespace is not recognised
You have a warning in your dependencies
16 replies
CC#
Created by GooBad on 7/18/2024 in #help
What is the name of this Linting rule in Rider?
?? is the null-coalescing operator, but I'm not aware of any rul that specifically targets that. There might be, but I'm not aware of one.
9 replies
CC#
Created by prodijay on 6/21/2024 in #help
Unable to get logged in user with GetUserAsync
Are you running some sort of IdentityServer?
39 replies
CC#
Created by prodijay on 6/21/2024 in #help
Unable to get logged in user with GetUserAsync
This isn't the normal setup that I am used to. Typically for authenticated applications, once a user is authenticated, you can just get the user details like name, email, roles from the HttpContext.User without having to go through any sort of UserManager.
39 replies
CC#
Created by Cyclomatic on 6/21/2024 in #help
XML Deserialization
You can fairly easily refactor the code I put above to handle most structures.
28 replies
CC#
Created by Cyclomatic on 6/21/2024 in #help
XML Deserialization
I'd start with a class model that you want to actually represent your structure and then ask for help on how to parse the Xml into that structure.
28 replies
CC#
Created by Cyclomatic on 6/21/2024 in #help
XML Deserialization
Can node just have a content property that is the of type List<BaseElement>?
28 replies
CC#
Created by Cyclomatic on 6/21/2024 in #help
XML Deserialization
Can your book have multiple titles and headers or only one of each?
28 replies
CC#
Created by Cyclomatic on 6/21/2024 in #help
XML Deserialization
Try something like this?
public class Book : IXmlSerializable
{
public Header Header { get; set; }
public Title Title { get; set; }

public XmlSchema GetSchema() => null;

public void ReadXml(XmlReader reader)
{
reader.MoveToContent();
int index = 1; // Start index counting

while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element && reader.Name == "Header")
{
Header = new Header { Index = index++ };
Header.ReadXml(reader);
}
else if (reader.NodeType == XmlNodeType.Element && reader.Name == "Title")
{
Title = new Title { Index = index++ };
Title.ReadXml(reader);
}
}
}

public void WriteXml(XmlWriter writer)
{
// Implement serialization logic if needed
}
}

public class Header : BaseElement, IXmlSerializable
{
public string Text { get; set; }

public void ReadXml(XmlReader reader)
{
reader.ReadStartElement("Header");
Text = reader.ReadElementContentAsString("Text", "");
reader.ReadEndElement();
}

public void WriteXml(XmlWriter writer)
{
// Implement serialization logic if needed
}
}
public class Book : IXmlSerializable
{
public Header Header { get; set; }
public Title Title { get; set; }

public XmlSchema GetSchema() => null;

public void ReadXml(XmlReader reader)
{
reader.MoveToContent();
int index = 1; // Start index counting

while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element && reader.Name == "Header")
{
Header = new Header { Index = index++ };
Header.ReadXml(reader);
}
else if (reader.NodeType == XmlNodeType.Element && reader.Name == "Title")
{
Title = new Title { Index = index++ };
Title.ReadXml(reader);
}
}
}

public void WriteXml(XmlWriter writer)
{
// Implement serialization logic if needed
}
}

public class Header : BaseElement, IXmlSerializable
{
public string Text { get; set; }

public void ReadXml(XmlReader reader)
{
reader.ReadStartElement("Header");
Text = reader.ReadElementContentAsString("Text", "");
reader.ReadEndElement();
}

public void WriteXml(XmlWriter writer)
{
// Implement serialization logic if needed
}
}
28 replies
CC#
Created by Cyclomatic on 6/21/2024 in #help
XML Deserialization
I think you'd have to use a custom deserializer
28 replies
CC#
Created by Cyclomatic on 6/21/2024 in #help
XML Deserialization
That is very not xml like
28 replies
CC#
Created by prodijay on 6/21/2024 in #help
Unable to get logged in user with GetUserAsync
What is UserManager<T>? Is that a class you defined yourself?
39 replies