{
public struct CustomModifiers : IEquatable<CustomModifiers>, IEnumerable<CustomModifiers.Entry>
{
- private static readonly Type ModOpt = new MarkerType();
- private static readonly Type ModReq = new MarkerType();
- private static readonly Type Initial = ModOpt;
+ // note that FromReqOpt assumes that Initial == ModOpt
+ private static Type Initial { get { return MarkerType.ModOpt; } }
private readonly Type[] types;
internal CustomModifiers(List<CustomModifiersBuilder.Item> list)
{
- bool required = Initial == ModReq;
+ bool required = Initial == MarkerType.ModReq;
int count = list.Count;
foreach (CustomModifiersBuilder.Item item in list)
{
}
}
types = new Type[count];
- required = Initial == ModReq;
+ required = Initial == MarkerType.ModReq;
int index = 0;
foreach (CustomModifiersBuilder.Item item in list)
{
if (item.required != required)
{
required = item.required;
- types[index++] = required ? ModReq : ModOpt;
+ types[index++] = required ? MarkerType.ModReq : MarkerType.ModOpt;
}
types[index++] = item.type;
}
{
this.types = types;
this.index = -1;
- this.required = Initial == ModReq;
+ this.required = Initial == MarkerType.ModReq;
}
void System.Collections.IEnumerator.Reset()
{
this.index = -1;
- this.required = Initial == ModReq;
+ this.required = Initial == MarkerType.ModReq;
}
public Entry Current
{
return false;
}
- else if (types[index] == ModOpt)
+ else if (types[index] == MarkerType.ModOpt)
{
required = false;
index++;
}
- else if (types[index] == ModReq)
+ else if (types[index] == MarkerType.ModReq)
{
required = true;
index++;
Type[] result = types;
for (int i = 0; i < types.Length; i++)
{
- if (types[i] == ModOpt || types[i] == ModReq)
+ if (types[i] == MarkerType.ModOpt || types[i] == MarkerType.ModReq)
{
continue;
}
Type mode = Initial;
do
{
- Type cmod = br.ReadByte() == Signature.ELEMENT_TYPE_CMOD_REQD ? ModReq : ModOpt;
+ Type cmod = br.ReadByte() == Signature.ELEMENT_TYPE_CMOD_REQD ? MarkerType.ModReq : MarkerType.ModOpt;
if (mode != cmod)
{
mode = cmod;
List<Type> list = null;
if (opt != null && opt.Length != 0)
{
+ Debug.Assert(Initial == MarkerType.ModOpt);
list = new List<Type>(opt);
}
if (req != null && req.Length != 0)
{
list = new List<Type>();
}
- list.Add(ModReq);
+ list.Add(MarkerType.ModReq);
list.AddRange(req);
}
if (list == null)