Exemplo n.º 1
0
        public static AssemblyDataCollection CreateFolderList(object o)
        {
            JavaBuilderEventArgs args = o as JavaBuilderEventArgs;

            CancellationToken = args.CancellationToken;
            logLevel          = args.LogLevel;

            string jdkFolder    = args.JDKFolder;
            string originFolder = args.OriginFolder;

            try
            {
                var folders = CreateFolderList(args.OriginFolder);
                AssemblyDataCollection coll = new AssemblyDataCollection();
                foreach (var folder in folders)
                {
                    AssemblyData data = new AssemblyData();
                    if (folder.Equals(Const.FileNameAndDirectory.CommonDirectory))
                    {
                        data.IsSelected       = true;
                        data.Framework        = Const.Framework.All;
                        data.AssemblyFullName = folder;
                        data.FolderName       = folder;
                    }
                    else
                    {
#if NET_CORE
                        var relFolder = Const.Framework.NETCoreFolder;
#else
                        var relFolder = Const.Framework.NETFrameworkFolder;
#endif
                        data.AssemblyFullName = folder;
                        data.FolderName       = Path.Combine(relFolder, folder);
#if NET_CORE
                        data.Framework = Const.Framework.NETCore;
#else
                        data.Framework = Const.Framework.NETFramework;
#endif
#if ENABLE_REFERENCE_BUILDER
                        var refPath = Path.Combine(args.OriginFolder, relFolder, folder, Const.FileNameAndDirectory.ReferencesFile);
                        var refData = File.ReadAllLines(refPath);
                        data.ReferencedAssemblies = new List <string>(refData);
#endif
                    }
                    coll.Add(data);
                }
                return(coll);
            }
            catch (Exception ex)
            {
                AppendToConsole(LogLevel.Error, "Error {0}", ex.Message);
                return(new AssemblyDataCollection());
            }
            finally
            {
                EndOperationHandler?.Invoke(null, new EndOperationEventArgs(string.Empty));
            }
        }
Exemplo n.º 2
0
        public static AssemblyDataCollection CreateFolderList(object o)
        {
            bool failed = false;
            FolderBuilderEventArgs args = o as FolderBuilderEventArgs;

            CancellationToken = args.CancellationToken;
            logLevel          = args.LogLevel;

            if (!Path.IsPathRooted(args.SourceFolder))
            {
                args.SourceFolder = Path.Combine(args.RootFolder, args.SourceFolder);
            }

            string originFolder = Path.Combine(args.SourceFolder, Const.FileNameAndDirectory.SourceDirectory);

            try
            {
                var folders = CreateFolderList(originFolder);
                AssemblyDataCollection coll = new AssemblyDataCollection();
                AssemblyData           data = new AssemblyData();
                data.IsSelected       = true;
                data.Framework        = Const.Framework.All;
                data.AssemblyFullName = Const.FileNameAndDirectory.CommonDirectory;
                data.FolderName       = Const.FileNameAndDirectory.CommonDirectory;
                coll.Add(data);
                foreach (var folder in folders)
                {
                    data = new AssemblyData();
                    if (folder.Equals(Const.FileNameAndDirectory.CommonDirectory))
                    {
                        continue;
                    }

                    var relFolder = Const.Framework.RuntimeFolder;
                    data.AssemblyFullName = folder;
                    data.FolderName       = Path.Combine(relFolder, folder);

                    data.Framework = Const.Framework.Runtime;

#if ENABLE_REFERENCE_BUILDER
                    var refPath = Path.Combine(args.OriginFolder, relFolder, folder, Const.FileNameAndDirectory.ReferencesFile);
                    var refData = File.ReadAllLines(refPath);
                    data.ReferencedAssemblies = new List <string>(refData);
#endif

                    coll.Add(data);
                }
                return(coll);
            }
            catch (OperationCanceledException ex)
            {
                AppendToConsole(LogLevel.Error, "Error {0}", ex.Message);
                return(new AssemblyDataCollection());
            }
            catch (Exception ex)
            {
                AppendToConsole(LogLevel.Error, "Error {0}", ex.Message);
                failed = true;
                return(new AssemblyDataCollection());
            }
            finally
            {
                EndOperationHandler?.Invoke(null, new EndOperationEventArgs(string.Empty, failed));
            }
        }