Class Attr<T>
Represents an attribute of type T.
Inheritance
Inherited Members
Namespace: OpenSvg.Attributes
Assembly: OpenSvg.dll
Syntax
public abstract class Attr<T> : IAttr, IEquatable<IAttr>, IEquatable<Attr<T>> where T : notnull, IEquatable<T>
Type Parameters
Name | Description |
---|---|
T | The type of the attribute. |
Constructors
| Edit this page View SourceAttr(string, T, bool)
Initializes a new instance of the Attr<T> class.
Declaration
protected Attr(string name, T defaultValue, bool isConstant)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the attribute. |
T | defaultValue | The default value of the attribute. |
bool | isConstant | Whether the attribute is constant. |
Fields
| Edit this page View SourceDefaultValue
The default value of the attribute.
Declaration
public readonly T DefaultValue
Field Value
Type | Description |
---|---|
T |
Properties
| Edit this page View SourceIsConstant
Whether the attribute is constant.
Declaration
public bool IsConstant { get; }
Property Value
Type | Description |
---|---|
bool |
Name
The name of the attribute.
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
string |
ShouldBeSerialized
Gets a value indicating whether the attribute should be serialized.
Declaration
public bool ShouldBeSerialized { get; }
Property Value
Type | Description |
---|---|
bool |
Remarks
This property determines whether the attribute should be included in the serialization process.
Methods
| Edit this page View SourceDefaultEquals(T)
Whether the default value of the attribute equals the specified value.
Declaration
protected virtual bool DefaultEquals(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to compare to the default value. |
Returns
Type | Description |
---|---|
bool | Whether the default value of the attribute equals the specified value. |
Deserialize(string)
Deserializes an XML string to the value of the attribute.
Declaration
protected abstract T Deserialize(string xmlString)
Parameters
Type | Name | Description |
---|---|---|
string | xmlString | The XML string to deserialize. |
Returns
Type | Description |
---|---|
T | The deserialized value. |
Equals(Attr<T>?)
Whether the attribute equals another attribute.
Declaration
public bool Equals(Attr<T>? other)
Parameters
Type | Name | Description |
---|---|---|
Attr<T> | other | The attribute to compare to. |
Returns
Type | Description |
---|---|
bool | Whether the attribute equals another attribute. |
Equals(IAttr?)
Whether the attribute equals another attribute.
Declaration
public bool Equals(IAttr? other)
Parameters
Type | Name | Description |
---|---|---|
IAttr | other | The attribute to compare to. |
Returns
Type | Description |
---|---|
bool | Whether the attribute equals another attribute. |
Equals(object?)
Determines whether the specified object is equal to the current object.
Declaration
public override bool Equals(object? obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to compare with the current object. |
Returns
Type | Description |
---|---|
bool | true if the specified object is equal to the current object; otherwise, false. |
Overrides
| Edit this page View SourceGet()
Gets the value of the attribute.
Declaration
public T Get()
Returns
Type | Description |
---|---|
T | The value of the attribute. |
GetHashCode()
Returns the hash code of the attribute.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | The hash code of the attribute. |
Overrides
| Edit this page View SourceSerialize(T)
Serializes the value of the attribute to an XML string.
Declaration
protected abstract string Serialize(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to serialize. |
Returns
Type | Description |
---|---|
string | The XML string representation of the value. |
Set(T)
Sets the value of the attribute.
Declaration
public void Set(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to set. |
SetBySerializer(string)
Sets the value of the attribute from an XML string.
Declaration
public void SetBySerializer(string xmlString)
Parameters
Type | Name | Description |
---|---|---|
string | xmlString | The XML string. |
ToString()
Returns the XML string representation of the attribute.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | The XML string representation of the attribute. |
Overrides
| Edit this page View SourceToXmlString()
Returns the XML string representation of the attribute.
Declaration
public string ToXmlString()
Returns
Type | Description |
---|---|
string | The XML string representation of the attribute. |
ValueEquals(T)
Whether the value of the attribute equals the specified value.
Declaration
protected virtual bool ValueEquals(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to compare to the value of the attribute. |
Returns
Type | Description |
---|---|
bool | Whether the value of the attribute equals the specified value. |
Operators
| Edit this page View Sourceoperator ==(Attr<T>, Attr<T>)
Whether two attributes are equal.
Declaration
public static bool operator ==(Attr<T> left, Attr<T> right)
Parameters
Type | Name | Description |
---|---|---|
Attr<T> | left | The first attribute. |
Attr<T> | right | The second attribute. |
Returns
Type | Description |
---|---|
bool | Whether the two attributes are equal. |
operator !=(Attr<T>, Attr<T>)
Whether two attributes are not equal.
Declaration
public static bool operator !=(Attr<T> left, Attr<T> right)
Parameters
Type | Name | Description |
---|---|---|
Attr<T> | left | The first attribute. |
Attr<T> | right | The second attribute. |
Returns
Type | Description |
---|---|
bool | Whether the two attributes are not equal. |