public static bool update(this IObjVerEx obj, bool returnUpdatedMetadata = true, bool skipVafCalculation = false, int?modifiedby_userid = null, string[] replace_files = null)
        {
            if (obj == null)
            {
                return(false);
            }
            // Check if the objcet is deleted or destroyed
            if (obj.objVerEx.Deleted() || obj.objVerEx.IsDestroyed)
            {
                return(false);
            }
            ObjectVersionAndProperties checkedInObject =
                obj.objVerEx.Vault.ObjectOperations.GetLatestObjectVersionAndProperties(obj.objVerEx.ObjID, true);

            if (checkedInObject.VersionData.ObjectCheckedOut)
            {
                return(false);
            }
            //
            bool          checkedOutByVAF = false;
            ObjectVersion objVersion      = null;
            PropertyValue prop_modifiedby = null;

            try {
                prop_modifiedby = obj.objVerEx.GetProperty(PD_Last_modified_by.id);
                objVersion      = obj.objVerEx.Vault.ObjectOperations.CheckOut(obj.objVerEx.ObjID);
                checkedOutByVAF = true;
                //
                PropertyValues propsToUpdate = obj.objVerEx.Properties.Clone();
                if (checkedInObject.Properties.Exists(PD_Comment.id) && obj.objVerEx.Properties.Exists(PD_Comment.id) &&
                    obj.objVerEx.VersionComment == checkedInObject.Properties.GetProperty(PD_Comment.id).GetValueAsUnlocalizedText())
                {
                    propsToUpdate.Remove(propsToUpdate.IndexOf(PD_Comment.id));
                }
                if (skipVafCalculation)
                {
                    string keyword = string.Empty;
                    if (propsToUpdate.TryGetProperty(26, out PropertyValue kw))
                    {
                        keyword = kw.GetValueAsUnlocalizedText();
                    }
                    propsToUpdate.SetProperty(26, MFDataType.MFDatatypeText, $"{keyword}SKIP_VAF_CALCULATIONS");
                }
                ObjectVersionAndProperties objVerAndProps =
                    obj.objVerEx.Vault.ObjectPropertyOperations.SetAllProperties(objVersion.ObjVer, false, propsToUpdate);

                if (prop_modifiedby != null)
                {
                    if (modifiedby_userid != null)
                    {
                        prop_modifiedby.TypedValue.SetValue(MFDataType.MFDatatypeLookup, modifiedby_userid);
                    }
                    objVerAndProps = obj.objVerEx.Vault.ObjectPropertyOperations.SetLastModificationInfoAdmin(objVersion.ObjVer, true, prop_modifiedby.TypedValue, false, null);
                }

                //replace files
                if (replace_files?.Length > 0 && objVersion.ObjVer.Type == (int)MFBuiltInObjectType.MFBuiltInObjectTypeDocument)
                {
                    SourceObjectFiles objFiles = new SourceObjectFiles();
                    foreach (string file_name in replace_files)
                    {
                        FileInfo fi    = new FileInfo(file_name);
                        string   title = fi.Name.Replace(fi.Extension, "");
                        string   ext   = fi.Extension.Replace(".", "");
                        objFiles.AddFile(title, ext, fi.FullName);
                        if (objVersion.SingleFile)
                        {
                            IEnumerator fileEnum = objVersion.Files.GetEnumerator();
                            fileEnum.MoveNext();
                            obj.objVerEx.Vault.ObjectFileOperations.RenameFile(objVersion.ObjVer, (fileEnum.Current as ObjectFile).FileVer, title, ext, false);
                            break;
                        }
                    }
                    ObjVerEx checkedOutVerEx = new ObjVerEx(obj.objVerEx.Vault, objVersion);
                    checkedOutVerEx.ReplaceFiles(objFiles);
                }

                objVersion                  = obj.objVerEx.Vault.ObjectOperations.CheckIn(objVerAndProps.ObjVer);
                checkedOutByVAF             = false;
                obj.objVerEx.ObjVer.Version = objVersion.ObjVer.Version;
                //
                if (returnUpdatedMetadata)
                {
                    objVerAndProps = obj.objVerEx.Vault.ObjectOperations.GetLatestObjectVersionAndProperties(obj.objVerEx.ObjID, false);
                    obj.objVerEx   = new ObjVerEx(obj.objVerEx.Vault, objVerAndProps);
                    obj.ClearAllCachedProperties();
                }
            } catch (Exception ex) {
                throw ex;
            } finally {
                if (objVersion != null && checkedOutByVAF)
                {
                    // Undo checkout and enforces the operation.
                    obj.objVerEx.Vault.ObjectOperations.ForceUndoCheckout(objVersion.ObjVer);
                }
            }

            return(true);
        }