Exemple #1
0
        /// <summary>
        /// Update core data associated with the SDK MNode object
        /// </summary>
        /// <param name="megaNode">Node to update</param>
        /// <param name="externalUpdate">Indicates if is an update external to the app. For example from an `onNodesUpdate`</param>
        public virtual void Update(MNode megaNode, bool externalUpdate = false)
        {
            this.OriginalMNode          = megaNode;
            this.Handle                 = megaNode.getHandle();
            this.RestoreHandle          = megaNode.getRestoreHandle();
            this.RestoreNode            = this.MegaSdk.getNodeByHandle(megaNode.getRestoreHandle());
            this.Base64Handle           = megaNode.getBase64Handle();
            this.Type                   = megaNode.getType();
            this.Name                   = megaNode.getName();
            this.Size                   = this.MegaSdk.getSize(megaNode);
            this.CreationTime           = ConvertDateToString(megaNode.getCreationTime()).DateToString();
            this.TypeText               = this.GetTypeText();
            this.LinkExpirationTime     = megaNode.getExpirationTime();
            this.AccessLevel.AccessType = (MShareType)this.MegaSdk.getAccess(megaNode);

            // Needed to filtering when the change is done inside the app or externally and is received by an `onNodesUpdate`
            if (!externalUpdate || megaNode.hasChanged((int)MNodeChangeType.CHANGE_TYPE_PUBLIC_LINK))
            {
                this.IsExported = megaNode.isExported();
                this.ExportLink = this.IsExported ? megaNode.getPublicLink(true) : null;
            }

            if (this.Type == MNodeType.TYPE_FILE)
            {
                this.ModificationTime = ConvertDateToString(megaNode.getModificationTime()).DateToString();
            }
            else
            {
                this.ModificationTime = this.CreationTime;
            }

            if (ParentContainerType != ContainerType.FileLink && ParentContainerType != ContainerType.FolderLink)
            {
                CheckAndUpdateOffline(megaNode);
            }
        }