示例#1
0
        private void ProcessTotal(StorageStatistics value)
        {
            var result = new StorageStatisticsByChat();

            result.ByFileType = new List <StorageStatisticsByFileType>();

            foreach (var chat in value.ByChat)
            {
                result.Count += chat.Count;
                result.Size  += chat.Size;

                foreach (var type in chat.ByFileType)
                {
                    var already = result.ByFileType.FirstOrDefault(x => x.FileType.TypeEquals(type.FileType));
                    if (already == null)
                    {
                        already = new StorageStatisticsByFileType(type.FileType, 0, 0);
                        result.ByFileType.Add(already);
                    }

                    already.Count += type.Count;
                    already.Size  += type.Size;
                }
            }

            TotalStatistics = result;
            IsLoading       = false;
        }
        private StorageStatistics ProcessTotal(StorageStatistics value)
        {
            var result = new StorageStatisticsByChat();

            result.ByFileType = new List <StorageStatisticsByFileType>();

            for (int i = 0; i < value.ByChat.Count; i++)
            {
                var chat = value.ByChat[i];

                result.Count += chat.Count;
                result.Size  += chat.Size;

                for (int j = 0; j < chat.ByFileType.Count; j++)
                {
                    var type = chat.ByFileType[j];

                    if (type.FileType is FileTypeProfilePhoto || type.FileType is FileTypeWallpaper)
                    {
                        result.Count -= type.Count;
                        result.Size  -= type.Size;

                        chat.Count -= type.Count;
                        chat.Size  -= type.Size;

                        chat.ByFileType.Remove(type);
                        j--;

                        continue;
                    }

                    var already = result.ByFileType.FirstOrDefault(x => x.FileType.TypeEquals(type.FileType));
                    if (already == null)
                    {
                        already = new StorageStatisticsByFileType(type.FileType, 0, 0);
                        result.ByFileType.Add(already);
                    }

                    already.Count += type.Count;
                    already.Size  += type.Size;
                }

                if (chat.ByFileType.IsEmpty())
                {
                    value.ByChat.Remove(chat);
                    i--;
                }
            }

            TotalStatistics = result;
            IsLoading       = false;

            return(value);
        }
示例#3
0
 private static Result StatImpl(IntPtr thisPtr, ref StorageStatistics.__Native statisticsPtr, StorageStatisticsFlags flags)
 {
     try
     {
         IStreamShadow     shadow     = ToShadow <IStreamShadow>(thisPtr);
         IStream           callback   = ((IStream)shadow.Callback);
         StorageStatistics statistics = callback.GetStatistics(flags);
         statistics.__MarshalTo(ref statisticsPtr);
     }
     catch (SharpGenException exception)
     {
         return(exception.ResultCode);
     }
     catch (Exception)
     {
         return(Result.Fail.Code);
     }
     return(Result.Ok);
 }
		private void AssertNumberOfFilesPerLevel(StorageStatistics statistics, params int[] numberOfFilesPerLevel)
		{
			for (var level = 0; level < numberOfFilesPerLevel.Length; level++)
			{
				Assert.Equal(numberOfFilesPerLevel[level], statistics.Files[level].Count);
			}
		}