void ValidateAnnotation(BindpointDesc d, Bindings bindings) { List <uint> bindingsForSpace; if (bindings.TryGetValue(d.Space, out bindingsForSpace)) { if (bindingsForSpace.Contains(d.Reg)) { throw new DuplicateBindpointException("Bindpoint of type " + d.GetType() + " in duplicated in space " + d.Space + ", register " + d.Reg); } bindingsForSpace.Add(d.Reg); return; } bindings.Add(d.Space, new List <uint> { d.Reg }); }
public bool CheckAnnotations(IBindable cb, out BindpointDesc outDesc) { uint register = 0; uint space = 0; outDesc = null; List <Annotation> annotations = cb.Annotations; if (annotations == null) { return(false); } var bindToAnnotation = annotations.FirstOrDefault(annot => annot.Name == "bindTo"); bool regParseSucess = false; if (bindToAnnotation.Value != null) { regParseSucess = uint.TryParse(bindToAnnotation.Value, out register); } if (!regParseSucess) { return(false); } var spaceAnnotation = annotations.FirstOrDefault(annot => annot.Name == "space"); if (spaceAnnotation.Value != null) { uint.TryParse(spaceAnnotation.Value, out space); } outDesc = new BindpointDesc(register, space); ValidateAnnotation(outDesc, m_allBindings[cb.ResourceBindpointType]); return(true); }