Esempio n. 1
0
        public override void WriteOutputToDisk(byte[] bytes, string fileName = null, string fileExt = ".json")
        {
            var tn = fileName ?? GetType().Name;

            tn = NfPath.SafeFilename(tn);
            var dir = MyProgram == null ? NfSettings.AppData : MyProgram.LogDirectory;

            var iaaProgram = MyProgram as IaaProgram;

            if (iaaProgram == null)
            {
                base.WriteOutputToDisk(bytes, fileName, fileExt);
                return;
            }

            var rootAsmName = iaaProgram.RootAssembly?.GetName().Name;

            if (rootAsmName == null)
            {
                base.WriteOutputToDisk(bytes, fileName, fileExt);
                return;
            }

            rootAsmName = NfPath.SafeDirectoryName(rootAsmName);

            dir = Path.Combine(dir, rootAsmName);
            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            File.WriteAllBytes(Path.Combine(dir, tn + fileExt), bytes);
        }
Esempio n. 2
0
        public override void WriteOutputToDisk(byte[] bytes, string fileName = null, string fileExt = ".json")
        {
            if (string.IsNullOrWhiteSpace(_reassignAssemblySubjectName))
            {
                base.WriteOutputToDisk(bytes, fileName, fileExt);
                return;
            }

            var isFullAssemblyName = NfReflect.IsAssemblyFullName(_reassignAssemblySubjectName);
            var isFullPath         = Path.IsPathRooted(_reassignAssemblySubjectName);
            var isFileName         = _reassignAssemblySubjectName.EndsWith(".dll") ||
                                     _reassignAssemblySubjectName.EndsWith(".exe");

            if (isFullAssemblyName)
            {
                var assemblyName = new System.Reflection.AssemblyName(_reassignAssemblySubjectName);
                _reassignAssemblySubjectName = assemblyName.Name;
            }

            if (isFullPath)
            {
                var dirName = Path.GetDirectoryName(_reassignAssemblySubjectName);
                if (!string.IsNullOrWhiteSpace(dirName))
                {
                    _reassignAssemblySubjectName = _reassignAssemblySubjectName.Replace(dirName, "");
                }
            }

            if (isFileName)
            {
                var flname = Path.GetFileNameWithoutExtension(_reassignAssemblySubjectName);
                if (!string.IsNullOrWhiteSpace(flname))
                {
                    _reassignAssemblySubjectName = flname;
                }
            }

            var tn = fileName ?? GetType().Name;

            tn = NfPath.SafeFilename(tn);
            var dir = MyProgram == null ? NfSettings.AppData : MyProgram.LogDirectory;

            var rootAsmName = NfPath.SafeDirectoryName(_reassignAssemblySubjectName);

            dir = Path.Combine(dir, rootAsmName);
            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            File.WriteAllBytes(Path.Combine(dir, tn + fileExt), bytes);
        }