public static NodeViewModel CreateNew(MegaSDK megaSdk, AppInformation appInformation, MNode megaNode, ContainerType parentContainerType, ObservableCollection <IMegaNode> parentCollection = null, ObservableCollection <IMegaNode> childCollection = null) { if (megaNode == null) { return(null); } try { switch (megaNode.getType()) { case MNodeType.TYPE_UNKNOWN: break; case MNodeType.TYPE_FILE: { if (megaNode.hasThumbnail() || megaNode.hasPreview() || ImageService.IsImage(megaNode.getName())) { return(new ImageNodeViewModel(megaSdk, appInformation, megaNode, parentContainerType, parentCollection, childCollection)); } return(new FileNodeViewModel(megaSdk, appInformation, megaNode, parentContainerType, parentCollection, childCollection)); } case MNodeType.TYPE_FOLDER: case MNodeType.TYPE_ROOT: case MNodeType.TYPE_RUBBISH: { return(new FolderNodeViewModel(megaSdk, appInformation, megaNode, parentContainerType, parentCollection, childCollection)); } case MNodeType.TYPE_INCOMING: break; } } catch (Exception) { return(null); } return(null); }
public static NodeViewModel CreateNew(MegaSDK megaSdk, AppInformation appInformation, MNode megaNode, FolderViewModel folder = null, ObservableCollection <IBaseNode> parentCollection = null, ObservableCollection <IBaseNode> childCollection = null) { if (megaNode == null) { return(null); } try { if (folder == null) { if (megaSdk.isInCloud(megaNode)) { folder = new FolderViewModel(megaSdk, ContainerType.CloudDrive); } if (megaSdk.isInRubbish(megaNode)) { folder = new FolderViewModel(megaSdk, ContainerType.RubbishBin); } if (megaSdk.isInShare(megaNode)) { folder = new FolderViewModel(megaSdk, ContainerType.InShares); } if (megaSdk.isOutShare(megaNode)) { folder = new FolderViewModel(megaSdk, ContainerType.OutShares); } } switch (megaNode.getType()) { case MNodeType.TYPE_UNKNOWN: break; case MNodeType.TYPE_FILE: if (megaNode.hasThumbnail() || megaNode.hasPreview() || ImageService.IsImage(megaNode.getName())) { return(new ImageNodeViewModel(megaSdk, appInformation, megaNode, folder, parentCollection, childCollection)); } return(new FileNodeViewModel(megaSdk, appInformation, megaNode, folder, parentCollection, childCollection)); case MNodeType.TYPE_ROOT: case MNodeType.TYPE_RUBBISH: return(new FolderNodeViewModel(megaSdk, appInformation, megaNode, folder, parentCollection, childCollection)); case MNodeType.TYPE_FOLDER: return(new FolderNodeViewModel(megaSdk, appInformation, megaNode, folder, parentCollection, childCollection)); case MNodeType.TYPE_INCOMING: break; } } catch (Exception) { return(null); } return(null); }