public EnumTypeMemberViewModel(EnumTypeViewModel parent, EnumTypeMember member) { _member = member; _name = String.Empty; _value = null; if (_member != null) { _name = member.Name.Value; _value = member.Value.Value; } Parent = parent; }
internal override bool ParseSingleElement(ICollection <XName> unprocessedElements, XElement elem) { if (elem.Name.LocalName == EnumTypeMember.ElementName) { var member = new EnumTypeMember(this, elem); member.Parse(unprocessedElements); AddMember(member); } else { return(base.ParseSingleElement(unprocessedElements, elem)); } return(true); }
protected override void InvokeInternal(CommandProcessorContext cpc) { string errorMessage; // Check if the EnumTypeMember is unique among its sibling. // Note that member names are case sensitive so it is perfectly legal to have members with the same names but differs in case (for e.g. member vs. MEMBER) if (ModelHelper.IsUniqueName(typeof(EnumTypeMember), EnumType, Name, true, out errorMessage) == false) { throw new CommandValidationFailedException(errorMessage); } var type = ModelHelper.UnderlyingEnumTypes.FirstOrDefault( t => String.CompareOrdinal(t.Name, EnumType.UnderlyingType.Value) == 0); Debug.Assert(type != null, "Type:" + EnumType.UnderlyingType.Value + " is not valid underlying type for an enum."); if (type != null) { // Check if the EnumTypeMember value is valid. if (String.IsNullOrWhiteSpace(Value) == false && ModelHelper.IsValidValueForType(type, Value) == false) { throw new CommandValidationFailedException( String.Format(CultureInfo.CurrentCulture, Resources.BadEnumTypeMemberValue, Value)); } var member = new EnumTypeMember(EnumType, null); member.LocalName.Value = Name; if (String.IsNullOrWhiteSpace(Value) == false) { member.Value.Value = Value; } EnumType.AddMember(member); XmlModelHelper.NormalizeAndResolve(member); } }
public EnumTypeMemberClipboardFormat(EnumTypeMember enumTypeMember) : base(enumTypeMember) { _memberName = enumTypeMember.Name.Value; _memberValue = enumTypeMember.Value.Value; }
internal void AddMember(EnumTypeMember member) { _members.Add(member); }
internal override bool ParseSingleElement(ICollection<XName> unprocessedElements, XElement elem) { if (elem.Name.LocalName == EnumTypeMember.ElementName) { var member = new EnumTypeMember(this, elem); member.Parse(unprocessedElements); AddMember(member); } else { return base.ParseSingleElement(unprocessedElements, elem); } return true; }
internal void AddMember(EnumTypeMember member) { _members.Add(member); }
public EnumTypeMemberClipboardFormat(EnumTypeMember enumTypeMember) : base(enumTypeMember) { _memberName = enumTypeMember.Name.Value; _memberValue = enumTypeMember.Value.Value; }