Example #1
0
        public static List <String> loadSourceFileIntoList(String pathToSourceCodeFile, bool useFileCacheIfPossible)
        {
            if (useFileCacheIfPossible && DI.dFilesLines.ContainsKey(pathToSourceCodeFile))
            {
                return(DI.dFilesLines[pathToSourceCodeFile]);
            }
            // in case the file is a reference, try to map it
            string mappedSourceCodeFile = SourceCodeMappingsUtils.mapFile(pathToSourceCodeFile);
            var    lsSourceCode         = new List <string>();
            string sFileContents        = getFileContents(mappedSourceCodeFile);

            if (sFileContents != "")
            {
                sFileContents = sFileContents.Replace("\r\n", "\n").Replace("\n", Environment.NewLine);
                // fix the files only use \n for line breaks
                lsSourceCode.AddRange(sFileContents.Split(new[] { Environment.NewLine }, StringSplitOptions.None));
                if (false == DI.dFilesLines.ContainsKey(pathToSourceCodeFile))
                {
                    DI.dFilesLines.Add(pathToSourceCodeFile, lsSourceCode);
                }
                else
                {
                    DI.dFilesLines[pathToSourceCodeFile] = lsSourceCode;
                }
            }
            return(lsSourceCode);
        }
Example #2
0
 public static string tryToResolveFileLocation(string fileToMap, Control hostControl)
 {
     if (autoTryToFixSourceCodeFileReferences && false == File.Exists(fileToMap) && false == Directory.Exists(fileToMap))
     {
         return(SourceCodeMappingsUtils.mapFile(fileToMap, hostControl));
     }
     return(fileToMap);
 }
        }                                               // populated dinamically

        public override string ToString()
        {
            var mappedFile = SourceCodeMappingsUtils.mapFile(File);

            if (mappedFile.fileExists())
            {
                return(mappedFile.fileContents().lines(false)[Line - 1]);
            }
            return(Signature ?? "...Signature value not set...");
        }
Example #4
0
        public static long getFileSize(string fileToProcess)
        {
            string mappedSourceCodeFile = SourceCodeMappingsUtils.mapFile(fileToProcess);

            if (File.Exists(mappedSourceCodeFile))
            {
                var fileInfo = new FileInfo(mappedSourceCodeFile);
                return(fileInfo.Length);
            }
            return(-1);
        }
Example #5
0
        public static void tryToFixSourceCodeReferences(O2AssessmentData_OunceV6 oadO2AssessmentDataOunceV6)
        {
            PublicDI.log.debug("Trying To Fix Source Code References");
            SourceCodeMappings scmSourceCodeMappings = SourceCodeMappingsUtils.getSourceCodeMappings();

            foreach (SourceCodeMappingsMapping mMapping in scmSourceCodeMappings.Mapping)
            {
                fixAllFileReferencesOnAssessmentDataObject(oadO2AssessmentDataOunceV6, mMapping.replaceThisString,
                                                           mMapping.withThisString);
            }
        }
Example #6
0
        public static long getFilesSize(List <string> filesToProcess)
        {
            long filesSize = 0;

            foreach (var file in filesToProcess)
            {
                string mappedSourceCodeFile = SourceCodeMappingsUtils.mapFile(file);
                if (File.Exists(mappedSourceCodeFile))
                {
                    var fileInfo = new FileInfo(mappedSourceCodeFile);
                    filesSize += fileInfo.Length;
                }
            }
            return((filesSize == 0) ? -1 : filesSize);
        }
        static DI()
        {
            log        = PublicDI.log;
            reflection = new O2FormsReflectionASCX();
            config     = PublicDI.config;

            dFilteredFuntionSignatures = new Dictionary <string, FilteredSignature>();
            dFilesLines = new Dictionary <string, List <string> >();

            dO2Vars  = new Dictionary <string, object>();
            dRegExes = new Dictionary <string, Regex>();

            sourceCodeMappingFileName = "SourceCodeMappingsFile.xml";
            sourceCodeMappings        = SourceCodeMappingsUtils.getSourceCodeMappings();
            PathToGac = Path.Combine(Environment.GetEnvironmentVariable("windir") ?? "", "Assembly");//\\GAC_MSIL");
        }
        }                                               // populated dinamically

        public override string ToString()
        {
            var mappedFile = SourceCodeMappingsUtils.mapFile(File);

            try
            {
                if (mappedFile.fileExists())
                {
                    return(mappedFile.fileContents().lines(false).value(Line - 1));
                }
            }
            catch (Exception ex)
            {
                ex.log();
            }
            return(Signature ?? "...Signature value not set...");
        }
Example #9
0
 private void ascx_SourceCodeFileReferences_Load(object sender, EventArgs e)
 {
     ascx_DropObject1.setText("Drop Saved Assessment File (*.ozasmt or *.xml )here");
     SourceCodeMappingsUtils.loadSourceCodeMappings(dataGridView1);
     //  btTest_Click(null, null);
 }
Example #10
0
 private void btExistingMappingsSaveChanges_Click(object sender, EventArgs e)
 {
     SourceCodeMappingsUtils.saveSourceCodeMappings(SourceCodeMappingsUtils.getSourceCodeMappingsFromDataGridView(dataGridView1));
 }