2 using Microsoft.Xna.Framework;
4 using System.Collections.Generic;
5 using System.Collections.Immutable;
6 using System.Diagnostics.CodeAnalysis;
23 [
return: NotNullIfNotNull(
"cxe")]
56 =>
Elements().Where(e =>
string.
Equals(name, e.Name.LocalName, StringComparison.OrdinalIgnoreCase));
68 [
return: NotNullIfNotNull(
"def")]
70 [
return: NotNullIfNotNull(
"def")]
72 [
return: NotNullIfNotNull(
"def")]
74 [
return: NotNullIfNotNull(parameterName:
"def")]
77 public string[]?
GetAttributeStringArray(
string key,
string[]? def,
bool convertToLowerInvariant =
false) =>
Element.GetAttributeStringArray(key, def, convertToLowerInvariant);
97 public (
T1, T2) GetAttributeTuple<T1, T2>(
string key, in (
T1, T2) def) =>
Element.GetAttributeTuple(key, def);
98 public (
T1, T2)[] GetAttributeTupleArray<T1, T2>(
string key, in (
T1, T2)[] def) =>
Element.GetAttributeTupleArray(key, def);
113 #warning TODO: update %ModDir% instances in case the content package changes
120 #warning TODO: update %ModDir% instances in case the content package changes
127 #warning TODO: update %ModDir% instances in case the content package changes
144 return a?.ContentPackage == b?.ContentPackage && a?.Element == b?.Element;
151 public static class ContentXElementExtensions
156 public static IEnumerable<ContentXElement> Elements(
this IEnumerable<ContentXElement> elements)
157 => elements.SelectMany(e => e.Elements());
void Add(ContentXElement elem)
override int GetHashCode()
override bool Equals(object? obj)
bool ComesAfter(ContentXElement other)
string? GetAttributeString(string key, string? def)
Identifier[] GetAttributeIdentifierArray(Identifier[] def, params string[] keys)
Range< int > GetAttributeRange(string key, in Range< int > def)
Point GetAttributePoint(string key, in Point def)
int?[] GetAttributeIntArray(string key, int[]? def)
IEnumerable< XAttribute > Attributes()
string ElementInnerText()
void AddAfterSelf(ContentXElement elem)
T GetAttributeEnum< T >(string key, in T def)
T[] GetAttributeEnumArray< T >(string key, T[] def)
void AddFirst(ContentXElement elem)
Vector4 GetAttributeVector4(string key, in Vector4 def)
IEnumerable< ContentXElement > Descendants()
Identifier[] GetAttributeIdentifierArray(string key, Identifier[] def, bool trim=true)
Color GetAttributeColor(string key, in Color def)
float GetAttributeFloat(string key, float def)
ContentPackage? ContentPackage
IEnumerable< ContentXElement > GetChildElements(string name)
static bool operator!=(in ContentXElement? a, in ContentXElement? b)
float?[] GetAttributeFloatArray(string key, float[]? def)
IEnumerable< ContentXElement > ElementsBeforeSelf()
string GetAttributeStringUnrestricted(string key, string def)
Identifier NameAsIdentifier()
IEnumerable< ContentXElement > Elements()
string ParseContentPathFromUri()
bool DoesAttributeReferenceFileNameAlone(string key)
readonly XElement Element
Vector2 GetAttributeVector2(string key, in Vector2 def)
ContentPath? GetAttributeContentPath(string key)
ushort GetAttributeUInt16(string key, ushort def)
IEnumerable< XAttribute > Attributes(string name)
ContentXElement? FirstElement()
static bool operator==(in ContentXElement? a, in ContentXElement? b)
ushort?[] GetAttributeUshortArray(string key, ushort[]? def)
Version GetAttributeVersion(string key, Version def)
Color?[] GetAttributeColorArray(string key, Color[]? def)
ContentXElement? GetChildElement(string name)
Color? GetAttributeColor(string key)
ContentXElement(ContentPackage? contentPackage, XElement element)
bool GetAttributeBool(string key, bool def)
float GetAttributeFloat(float def, params string[] keys)
int GetAttributeInt(string key, int def)
Rectangle GetAttributeRect(string key, in Rectangle def)
string?[] GetAttributeStringArray(string key, string[]? def, bool convertToLowerInvariant=false)
Identifier GetAttributeIdentifier(string key, Identifier def)
XAttribute? GetAttribute(string name)
void SetAttributeValue(string key, string val)
ImmutableHashSet< Identifier > GetAttributeIdentifierImmutableHashSet(string key, ImmutableHashSet< Identifier >? def, bool trim=true)
Identifier GetAttributeIdentifier(string key, string def)