private T ConvertTo <T>(byte[] data) { if (null == data) { return(default(T)); } return(MetaDataConverter.ConvertTo <T>(data)); }
/// <summary> /// Set property to MetaObject. Modifies existing value or adds as a new value if existing tag is not found. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="tag"></param> /// <param name="value"></param> /// <param name="isRequired"></param> /// <param name="version"></param> /// <param name="createNewVersion"></param> /// <param name="encryptor">When encryptor is not null the value is encrypted.</param> public void SetProperty <T>(string tag, T value, int version = MetaDataRepository.LatestVersion, bool createNewVersion = false) { if (string.IsNullOrEmpty(tag)) { return; } MetaProperty property = null; if (createNewVersion) { property = this.GetProperty(tag, MetaDataRepository.LatestVersion); } else { property = this.GetProperty(tag, version); } if (null == property) { if (null == this.Properties) { this.Properties = new List <MetaProperty>(); } this.Properties.Add(new MetaProperty(tag, null != value ? MetaDataConverter.ConvertToByteArray <T>(value) : null)); } else { if (createNewVersion) { this.Properties.Add(new MetaProperty(tag, null != value ? MetaDataConverter.ConvertToByteArray <T>(value) : null, property.Version + 1)); } else { property.Value = null != value?MetaDataConverter.ConvertToByteArray <T>(value) : null; } } }