Beispiel #1
0
        public static IItem Create(string fullPath)
        {
            var item = new LocalItem
            {
                FullPath = fullPath
            };
            var isRoot = IsRoot(fullPath);

            item.Type = isRoot ? ItemTypes.LocaDrive :
                        IsFolder(fullPath) ? ItemTypes.Folder :
                        ItemFactoryHelper.GetFileType(fullPath);
            if (isRoot)
            {
                item.Name = fullPath.Replace(Path.DirectorySeparatorChar, ' ').Trim();
            }
            else
            {
                if (fullPath.Last() == Path.DirectorySeparatorChar)
                {
                    fullPath = fullPath.Remove(fullPath.Length - 1);
                }
                item.Name = Path.GetFileName(fullPath);
            }
            return(item);
        }
 public static IItem CreateChild(DriveItem driveItem, OneDriveItem parent) {
     var item = IocContainer.Default.GetTransient<OneDriveItem>();
     item.Id = driveItem.Id;
     item.Name = driveItem.Name;
     item.Type = IsFolder(driveItem) ? ItemTypes.Folder :
                         ItemFactoryHelper.GetFileType(driveItem.Name);
     item.FullPath = Path.Combine(parent.FullPath, item.Name);
     item.UserId = parent.UserId;
     return item;
 }