예제 #1
0
        private void ReadDataCore(object zRefData)
        {
            var zReferenceData = zRefData as ProjectLayoutReference[];

            var listLines                = new List <List <string> >();
            var listDefineLines          = new List <List <string> >();
            var listReferenceDefineLines = new List <List <string> >();

            ReferenceReader zRefReader = null;

            if (null == zReferenceData || zReferenceData.Length == 0)
            {
                ReadDefaultProjectDefinitions(listDefineLines);
            }
            else
            {
                // 2 per reference + 1 for the project wide defines
                m_zReporterProxy.ProgressReset(0, zReferenceData.Length * 2 + 1, 0);

                for (int nIdx = 0; nIdx < zReferenceData.Length; nIdx++)
                {
                    var zReference   = zReferenceData[nIdx];
                    var listRefLines = new List <List <string> >();
                    zRefReader = ReferenceReaderFactory.GetReader(zReference, m_zReporterProxy.ProgressReporter);

                    if (zRefReader == null)
                    {
                        listLines.Clear();
                        m_zReporterProxy.AddIssue($"Failed to load reference: {zReference.RelativePath}");
                        break;
                    }

                    if (!zRefReader.IsValid())
                    {
                        m_zErrorReferenceReader = zRefReader;
                        listLines.Clear();
                        m_zReporterProxy.AddIssue($"Reference reader for reference is in an invalid state: {zReference.RelativePath}");
                        break;
                    }

                    var listReferenceActions = new List <Task>();

                    // 0 index is always the default project reference in the case of multi load
                    // only load it once
                    if (nIdx == 0)
                    {
                        listReferenceActions.Add(Task.Factory.StartNew(
                                                     () =>
                        {
                            if (!string.IsNullOrEmpty(ProjectManager.Instance.ProjectFilePath))
                            {
                                zRefReader.GetProjectDefineData(zReference, listDefineLines);
                                if (listDefineLines.Count == 0)
                                {
                                    m_zReporterProxy.AddIssue("No defines found for project file: {0}".FormatString(ProjectManager.Instance.ProjectFilePath));
                                }
                            }
                            else
                            {
                                m_zReporterProxy.AddIssue("No defines loaded for project -- project not yet saved.");
                            }
                            m_zReporterProxy.ProgressStep();
                        }));
                    }

                    listReferenceActions.Add(Task.Factory.StartNew(
                                                 () =>
                    {
                        zRefReader.GetReferenceData(zReference, listRefLines);
                        m_zReporterProxy.ProgressStep();
                    }));

                    listReferenceActions.Add(Task.Factory.StartNew(
                                                 () =>
                    {
                        zRefReader.GetDefineData(zReference, listReferenceDefineLines);
                        m_zReporterProxy.ProgressStep();
                    }));

                    Task.WaitAll(listReferenceActions.ToArray());

                    // check if there are existing lines (from prior references) and remove the column header from the latest ref data
                    if (listLines.Count > 0 && listRefLines.Count > 0)
                    {
                        listRefLines.RemoveAt(0);
                    }
                    listLines.AddRange(listRefLines);

                    zRefReader.FinalizeReferenceLoad();
                    m_zReporterProxy.ProgressStep();
                }
            }

            // Note: the readers trim out the first line for defines data
            listDefineLines.AddRange(listReferenceDefineLines);

            ProcessLines(
                listLines,
                listDefineLines,
                zReferenceData != null && zReferenceData.Length > 0,
                zRefReader?.ReferencePath);
        }
예제 #2
0
        private void ReadDataCore(object zRefData)
        {
            var zReferenceData = zRefData as ProjectLayoutReference[];

            var listLines       = new List <List <string> >();
            var listDefineLines = new List <List <string> >();

            ReferenceReader zRefReader = null;

            if (null == zReferenceData || zReferenceData.Length == 0)
            {
                ReadDefaultProjectDefinitions(listDefineLines);
            }
            else
            {
                WaitDialog.Instance.ProgressReset(0, 0, zReferenceData.Length * 2 + 1, 0);

                for (int nIdx = 0; nIdx < zReferenceData.Length; nIdx++)
                {
                    var zReference   = zReferenceData[nIdx];
                    var listRefLines = new List <List <string> >();
                    zRefReader = ReferenceReaderFactory.GetReader(zReference);

                    if (zRefReader == null)
                    {
                        listLines.Clear();
                        Logger.AddLogLine($"Failed to load reference: {zReference.RelativePath}");
                        break;
                    }
                    // 0 index is always the default reference in the case of multi load
                    if (nIdx == 0)
                    {
                        if (!string.IsNullOrEmpty(ProjectManager.Instance.ProjectFilePath))
                        {
                            zRefReader.GetProjectDefineData(zReference, listDefineLines);
                            if (listDefineLines.Count == 0)
                            {
                                Logger.AddLogLine(
                                    "No defines found for project file: {0}".FormatString(
                                        ProjectManager.Instance.ProjectFilePath));
                            }
                        }
                        else
                        {
                            Logger.AddLogLine("No defines loaded for project -- project not yet saved.");
                        }
                        WaitDialog.Instance.ProgressStep(0);
                    }

                    zRefReader.GetReferenceData(zReference, listRefLines);
                    if (listLines.Count > 0 && listRefLines.Count > 0)
                    {
                        // remove the columns row from any non-zero index references
                        listRefLines.RemoveAt(0);
                    }
                    listLines.AddRange(listRefLines);
                    WaitDialog.Instance.ProgressStep(0);

                    var nPriorCount = listDefineLines.Count;
                    zRefReader.GetDefineData(zReference, listDefineLines);
                    if (listDefineLines.Count == nPriorCount)
                    {
                        Logger.AddLogLine(
                            "No defines found for reference: {0}".FormatString(zReference.RelativePath));
                    }

                    zRefReader.FinalizeReferenceLoad();
                    WaitDialog.Instance.ProgressStep(0);
                }
            }

            ProcessLines(listLines, listDefineLines, zRefReader?.ReferencePath);
        }