forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMetaAttribute.cs
62 lines (52 loc) · 1 KB
/
MetaAttribute.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.Collections.Generic;
using NHibernate.Util;
namespace NHibernate.Mapping
{
/// <summary>
/// A meta attribute is a named value or values.
/// </summary>
[Serializable]
public class MetaAttribute
{
private readonly string name;
private readonly List<string> values= new List<string>();
public MetaAttribute(string name)
{
this.name = name;
}
public string Name
{
get { return name; }
}
public IList<string> Values
{
get { return values.AsReadOnly(); }
}
public string Value
{
get
{
if (values.Count != 1)
throw new ArgumentException("No unique value");
return values[0];
}
}
public bool IsMultiValued
{
get { return values.Count > 1; }
}
public void AddValue(string value)
{
values.Add(value);
}
public void AddValues(IEnumerable<string> range)
{
values.AddRange(range);
}
public override string ToString()
{
return string.Format("[{0}={1}]", name, CollectionPrinter.ToString(values));
}
}
}