/// <summary> /// Add an attribute and write the values to the file /// </summary> /// <typeparam name="T"></typeparam> /// <param name="_name"></param> /// <param name="_value"></param> /// <returns></returns> public Hdf5Attribute Add <T>(string _name, T _value) { if (Exists(_name)) { throw new Hdf5AttributeAlreadyExistException(); } //If the parent is the file, then just create the attribute (file already open). if (ParentObject.Id.Equals(ParentObject.FileId)) { return(AttributeHelper.CreateAttributeAddToList(ParentObject.Id, this, _name, _value)); } Hdf5Attribute attribute = null; //Otherwise open the object and then call the function. var id = H5O.open(ParentObject.FileId.Value, ParentObject.Path.FullPath).ToId(); if (id.Value > 0) { attribute = AttributeHelper.CreateAttributeAddToList(id, this, _name, _value); H5O.close(id.Value); } return(attribute); }