コード例 #1
0
        private void TryToCreateXmlOutput()
        {
            CACmdLineFSEntityList <CACmdLineFileSource> inputFiles = iInputs.SourceFiles;
            //
            CISink xmlSink = FindXmlSink();

            if (xmlSink == null)
            {
                throw new CACmdLineException("XML Output Plugin Not Available", CAPlugin.KErrCommandLinePluginSinkNotAvailable);
            }

            CACmdLineFSEntityList <CACmdLineFileSource> sourceFileNames = iInputs.SourceFiles;
            int count = sourceFileNames.Count;

            // Emit progress banner
            iProgressReporter.StepBegin("Creating crash XML content...", KStepKeyWritingOutputXml, count);

            for (int i = 0; i < count; i++)
            {
                CACmdLineFileSource file = sourceFileNames[i];

                // If the file has a corresponding source then we know that crash item recognised it.
                if (file.Source == null)
                {
                    // File is not supported by crash item engine. Create dummy container which we'll
                    // serialize below.
                    CACmdLineSource cmdLineSource   = new CACmdLineSource(file.File);
                    CIContainer     failedContainer = CIContainer.NewErrorContainer(CrashItemEngine, cmdLineSource);
                    file.Add(failedContainer);
                }

                // We copy and remove all the file-level messages. These will be added to the container
                // (where appropriate) or then to an output entry otherwise.
                CACmdLineMessage[] fileMessages = file.ToArray();
                file.Clear();

                // At this point, the input file is guaranteed to have associated containers. Either
                // valid ones (created by crash item engine) or a single 'FAILED' one which we just
                // added above.
                foreach (CIContainer container in file.Containers)
                {
                    // Firstly, add any meta-data errors/messages/warnings to this container
                    // as crash item message entries
                    AddMetaDataMessagesToContainer(container);

                    // Now we can try to serialize the container to XML. This method will
                    // not throw an exception.
                    //
                    // If the operation succeeds, then the input file will have an associated
                    // container object (and associated xml output file name) and we need not
                    // do anymore.
                    //
                    // If it fails, then the input file will not be assigned the container
                    // object and therefore, later on, we'll invoke the XML Sink directly to
                    // create a stub 'FAILED' XML output file.
                    TryToCreateXmlOutput(xmlSink, container, file, fileMessages);
                }

                // Report progress as we work through the sources
                iProgressReporter.StepProgress(string.Empty, i, KStepKeyWritingOutputXml);
            }

            iProgressReporter.StepEnd(string.Empty, KStepKeyWritingOutputXml);
        }
コード例 #2
0
        public CIContainer CreateErrorContainer(CFFSource aDescriptor)
        {
            CIContainer item = CIContainer.NewErrorContainer(Engine, aDescriptor);

            return(item);
        }