Пример #1
0
        public static Generalization[] Generate(string str1, string str2, TimeSpan time)
        {
            List <Generalization>         gens = new List <Generalization>();
            List <SequentialIntFunction>  sifs = new List <SequentialIntFunction>();
            List <SequentialCharFunction> scfs = new List <SequentialCharFunction>();
            List <ConstantTextFunction>   ctfs = new List <ConstantTextFunction>();
            string expression = string.Empty;

            // SequentialIntFunction
            if (SequentialIntFunction.Generate(str1, str2, out expression, out sifs))
            {
                //foreach (SequentialIntFunction func in sifs)
                //    gens.Add(new TextGeneralization(expression, func, str2));
                gens.Add(new TextGeneralization(expression, sifs.ToArray(), str2, time, 2));
            }
            // SequentialCharFunction
            if (SequentialCharFunction.Generate(str1, str2, out expression, out scfs))
            {
                //foreach (SequentialCharFunction func in scfs)
                //    gens.Add(new TextGeneralization(expression, func, str2));
                gens.Add(new TextGeneralization(expression, scfs.ToArray(), str2, time, 2));
            }
            // ConstantTextFunction
            if (ConstantTextFunction.Generate(str1, str2, out expression, out ctfs))
            {
                //foreach (ConstantTextFunction func in ctfs)
                //    gens.Add(new TextGeneralization(expression, func, str2));
                gens.Add(new TextGeneralization(expression, ctfs.ToArray(), str2, time, 2));
            }
            return(gens.ToArray());
        }
Пример #2
0
        public static Generalization[] Generate(string str1, string str2, TimeSpan time)
        {
            List <Generalization> gens = new List <Generalization>();

            bool   is_file;
            string folder1, folder2;

            if (Directory.Exists(str2))
            {
                is_file = false;
                folder1 = Directory.GetParent(str1).FullName;
                folder2 = Directory.GetParent(str2).FullName;
            }
            else
            {
                is_file = true;
                folder1 = Path.GetDirectoryName(str1);
                folder2 = Path.GetDirectoryName(str2);
            }

            // if both files have the same directory, then there might be a generalization
            if (folder1 == folder2)
            {
                List <SequentialIntFunction>  sifs = new List <SequentialIntFunction>();
                List <SequentialCharFunction> scfs = new List <SequentialCharFunction>();
                List <ConstantTextFunction>   ctfs = new List <ConstantTextFunction>();
                string expression = string.Empty;

                string file1 = Path.GetFileName(str1);
                string file2 = Path.GetFileName(str2);

                // SequentialIntFunction
                if (SequentialIntFunction.Generate(file1, file2, out expression, out sifs))
                {
                    //foreach (SequentialIntFunction func in sifs)
                    //    gens.Add(new FileCreateGeneralization(expression, func, str2));
                    gens.Add(new FileCreateGeneralization(expression, sifs.ToArray(), file2, time, 2));
                }
                // SequentialCharFunction
                if (SequentialCharFunction.Generate(file1, file2, out expression, out scfs))
                {
                    //foreach (SequentialCharFunction func in scfs)
                    //    gens.Add(new FileCreateGeneralization(expression, func, str2));
                    gens.Add(new FileCreateGeneralization(expression, scfs.ToArray(), file2, time, 2));
                }
                // ConstantTextFunction
                if (ConstantTextFunction.Generate(file1, file2, out expression, out ctfs))
                {
                    //foreach (ConstantTextFunction func in ctfs)
                    //    gens.Add(new FileCreateGeneralization(expression, func, str2));
                    gens.Add(new FileCreateGeneralization(expression, ctfs.ToArray(), file2, time, 2));
                }
            }
            return(gens.ToArray());
        }
Пример #3
0
        public static Generalization[] Generate(string str1, string str2, TimeSpan time)
        {
            List <Generalization> gens = new List <Generalization>();

            bool   is_file;
            string folder1, folder2;

            if (Directory.Exists(str2))
            {
                is_file = false;
                folder1 = Directory.GetParent(str1).FullName;
                folder2 = Directory.GetParent(str2).FullName;
            }
            else
            {
                is_file = true;
                folder1 = Path.GetDirectoryName(str1);
                folder2 = Path.GetDirectoryName(str2);
            }

            // if both files have the same directory, then there might be a generalization
            if (folder1 == folder2)
            {
                List <ConstantFileFunction>    cff  = new List <ConstantFileFunction>();
                List <ConstantFileFunctionEx>  cffe = new List <ConstantFileFunctionEx>();
                List <SequentialIntFunction>   sifs = new List <SequentialIntFunction>();
                List <SequentialCharFunction>  scfs = new List <SequentialCharFunction>();
                List <ConstantFileExtFunction> cfef = new List <ConstantFileExtFunction>();
                List <ConstantTextFunction>    ctfs = new List <ConstantTextFunction>();
                string expression = string.Empty;

                string file1 = Path.GetFileNameWithoutExtension(str1);
                string file2 = Path.GetFileNameWithoutExtension(str2);

                List <string> extensions = new List <string>();

                // detect which file extensions show the operations be applied to
                if (is_file)
                {
                    if (Path.GetExtension(str1) == Path.GetExtension(str2) && Path.GetExtension(str1) != string.Empty)
                    {
                        extensions.Add(Path.GetExtension(str2));
                    }
                    extensions.Add(".*");
                }

                // SequentialIntFunction
                if (SequentialIntFunction.Generate(file1, file2, out expression, out sifs))
                {
                    gens.Add(new FileDeleteGeneralization(expression, sifs.ToArray(), str2, time, 2));
                }
                // SequentialCharFunction
                if (SequentialCharFunction.Generate(file1, file2, out expression, out scfs))
                {
                    gens.Add(new FileDeleteGeneralization(expression, scfs.ToArray(), str2, time, 2));
                }
                // ConstantFileFunction
                if (ConstantFileFunction.Generate(file1, file2, folder2, extensions.ToArray(), out expression, out cff))
                {
                    gens.Add(new FileDeleteGeneralization(expression, cff.ToArray(), str2, time, 2));
                }
                // ConstantFileFunctionEx
                if (ConstantFileFunctionEx.Generate(file1, file2, folder2, extensions.ToArray(), out expression, out cffe))
                {
                    gens.Add(new FileDeleteGeneralization(expression, cffe.ToArray(), str2, time, 2));
                }
                // ConstantFileExtFunction
                if (ConstantFileExtFunction.Generate(folder2, extensions.ToArray(), out expression, out cfef))
                {
                    gens.Add(new FileDeleteGeneralization(expression, cfef.ToArray(), str2, time, 2));
                }
                // ConstantTextFunction
                if (ConstantTextFunction.Generate(file1, file2, out expression, out ctfs))
                {
                    gens.Add(new FileDeleteGeneralization(expression, ctfs.ToArray(), str2, time, 2));
                }
            }
            return(gens.ToArray());
        }