Example #1
0
        public static My_List StructFiles(string[] splitStr, My_List textList, My_List imageList, My_List movieList, My_List size)
        {
            for (int i = 0; i < splitStr.Length; i++)
            {
                string[] fileName = splitStr[i].Split(':');
                string   typeFile = fileName[0].Trim();
                switch (typeFile)
                {
                case "Text":
                    TextFile textFiles = new TextFile();
                    textFiles.SplitStr(fileName[1], ref size);
                    textList.Add(textFiles);
                    break;

                case "Image":
                    Image images = new Image();
                    images.SplitStr(fileName[1]);
                    imageList.Add(images);
                    break;

                case "Movie":
                    Movie movies = new Movie();
                    movies.SplitStr(fileName[1]);
                    movieList.Add(movies);
                    break;
                }
            }
            return(size);
        }
Example #2
0
        public My_List SortSize(My_List size, My_List textFile)
        {
            object temp;

            string[] sizeArray = new string[size.Count];
            for (int x = 0; x < size.Count; x++)
            {
                sizeArray[x] = size[x].ToString();
            }
            for (int j = 0; j < sizeArray.Length; j++)
            {
                for (int i = 0; i < sizeArray.Length - j - 1; i++)
                {
                    string temp1 = sizeArray[i].Split('B')[0];
                    string temp2 = sizeArray[i + 1].Split('B')[0];
                    if (double.TryParse(temp1, out double sizei))
                    {
                        if (double.TryParse(temp2, out double size1))
                        {
                            if (sizei > size1)
                            {
                                temp            = textFile[i];
                                textFile[i]     = textFile[i + 1];
                                textFile[i + 1] = temp;
                            }
                        }
                    }
                }
            }
            return(textFile);
        }
Example #3
0
 public My_List SplitStr(string textStr, ref My_List size)
 {
     string[] nameSizeContent = textStr.Split(';');
     base.SplitStr(nameSizeContent[0]);
     Extension = nameSizeContent[0].Split('.')[1].Split('(')[0];
     Content   = nameSizeContent[1];
     size.Add(Size);
     return(size);
 }
Example #4
0
 public static void Print <T>(My_List files, string typeFile) where T : File
 {
     Console.WriteLine(typeFile);
     for (int i = 0; i < files.Count; i++)
     {
         if (files[i] is T file)
         {
             file.Print();
         }
     }
 }
Example #5
0
        static void Main(string[] args)
        {
            string text = @"Text: file.txt(6B); Some string content
            Image: img.bmp(19MB); 1920х1080
            Text:data.txt(12B); Another string
            Text:data1.txt(7B); Yet another string
            Movie:logan.2017.mkv(19GB); 1920х1080; 2h12m";

            My_List  textList  = new My_List();
            My_List  imageList = new My_List();
            My_List  movieList = new My_List();
            TextFile textF     = new TextFile();
            My_List  size      = new My_List();

            string[] split = text.Split('\n');
            StructFiles(split, textList, imageList, movieList, size);
            My_List textListSort = textF.SortSize(size, textList);

            Print <TextFile>(textListSort, "Text files");
            Print <Movie>(movieList, "Movies");
            Print <Image>(imageList, "Images");

            Console.ReadLine();
        }