public void Add(ISoilPart part, int proportion) { if (proportion < 0) { throw new ArgumentOutOfRangeException("proportion", proportion, "Can not add negative proportion of soil part."); } if (proportion == 0) { return; } if (dict.ContainsKey(part)) { dict[part] += proportion; } else { dict.Add(part, proportion); } if (!inEditing) { ReduceProportions(); } }
public void Remove(ISoilPart part, int proportion) { if (proportion < 0) { throw new ArgumentOutOfRangeException("proportion", proportion, "Can not remove negative proportion of soil part."); } if (proportion == 0) { return; } if (dict.ContainsKey(part)) { dict[part] -= proportion; if (dict[part] <= 0) { dict.Remove(part); } } if (!inEditing) { ReduceProportions(); } }
public void Set(ISoilPart part, int proportion) { if (proportion < 0) { throw new ArgumentOutOfRangeException("proportion", proportion, "Can not set negative proportion of soil part."); } if (proportion == 0) { dict.Remove(part); } else { dict[part] = proportion; } if (!inEditing) { ReduceProportions(); } }
public int PartsOf(ISoilPart part) { return(dict.GetValueOrDefault(part)); }
public int this[ISoilPart part] { get { return(PartsOf(part)); } }