public EnumerationPair AddEnumerationPair(string name, string val, bool isDefault = false) { EnumerationPair node = new EnumerationPair(this) { Name = name, Value = val, IsDefault = isDefault }; this.NodeAddNewSubNode(node); return(node); }
private bool IsValueNotEmpty(EnumerationPair val) { if (val.Parent == null) { return(true); } if (string.IsNullOrWhiteSpace(val.Value)) { return(false); } return(true); }
private bool IsValueConvertable(EnumerationPair val) { if (string.IsNullOrWhiteSpace(val.Value)) { return(true); } if (val.Parent == null) { return(true); } Enumeration p = (Enumeration)val.Parent; switch (p.DataTypeEnum) { case common.EnumEnumerationType.BYTE_VALUE: byte b = 0; if (!byte.TryParse(val.Value, out b)) { return(false); } break; case common.EnumEnumerationType.INTEGER_VALUE: int i = 0; if (!Int32.TryParse(val.Value, out i)) { return(false); } break; case common.EnumEnumerationType.SHORT_VALUE: Int16 t = 0; if (!Int16.TryParse(val.Value, out t)) { return(false); } break; case common.EnumEnumerationType.STRING_VALUE: break; default: throw new ArgumentException(); } return(true); }
private bool IsUniqueName(EnumerationPair val) { if (val.Parent == null) { return(true); } if (string.IsNullOrWhiteSpace(val.Name)) // handled by another rule { return(true); } Enumeration p = (Enumeration)val.Parent; foreach (var t in p.ListEnumerationPairs) { if ((val.Guid != t.Guid) && (val.Name == t.Name)) { return(false); } } return(true); }
private bool IsUniqueValue(EnumerationPair val) { if (val.Parent == null) { return(true); } Enumeration p = (Enumeration)val.Parent; foreach (var t in p.ListEnumerationPairs) { if (string.IsNullOrWhiteSpace(val.Value)) { continue; } if ((val.Guid != t.Guid) && (val.Value == t.Value)) { return(false); } } return(true); }
public override ITreeConfigNode NodeAddNewSubNode(ITreeConfigNode node_impl = null) { EnumerationPair node = null; if (node_impl == null) { node = new EnumerationPair(this); } else { node = (EnumerationPair)node_impl; } this.ListEnumerationPairs.Add(node); if (node_impl == null) { this.GetUniqueName(EnumerationPair.DefaultName, node, this.ListEnumerationPairs); } this.SetSelected(node); return(node); }