/// <summary> /// Parses a line that declares a Vendor-Specific attribute. /// </summary> private static void ParseVendorAttributeLine(IWritableDictionary dictionary, string[] tok, int lineNum) { if (tok.Length != 5) throw new IOException("syntax error on line " + lineNum); String vendor = tok[1].Trim(); String name = tok[2].Trim(); int code = Convert.ToInt32(tok[3].Trim()); String typeStr = tok[4].Trim(); Type type = GetAttributeTypeClass(code, typeStr); var at = new AttributeType(Convert.ToInt32(vendor), code, name, type); dictionary.AddAttributeType(at); }
/// <summary> /// Adds an AttributeType object to the cache. /// @param attributeType AttributeType object /// @exception ArgumentException duplicate attribute name/type code /// </summary> public void AddAttributeType(AttributeType attributeType) { if (attributeType == null) throw new ArgumentException("attribute type must not be null"); int vendorId = attributeType.VendorId; int typeCode = attributeType.TypeCode; String attributeName = attributeType.Name; if (_attributesByName.ContainsKey(attributeName)) throw new ArgumentException("duplicate attribute name: " + attributeName); Dictionary<int, AttributeType> vendorAttributes; if (!_attributesByCode.ContainsKey(vendorId)) { vendorAttributes = new Dictionary<int, AttributeType>(); _attributesByCode.Add(vendorId, vendorAttributes); } vendorAttributes = _attributesByCode[vendorId]; if (vendorAttributes.ContainsKey(typeCode)) throw new ArgumentException("duplicate type code: " + typeCode); _attributesByName.Add(attributeName, attributeType); vendorAttributes.Add(typeCode, attributeType); }