Exemplo n.º 1
0
        public virtual XElement GetDiagnosticInfo(DiagnosableParameters parameters)
        {
            this.Arguments = Activator.CreateInstance <TArgument>();
            TArgument arguments = this.Arguments;

            return(arguments.RunDiagnosticOperation(delegate
            {
                TArgument arguments2 = this.Arguments;
                arguments2.Initialize(parameters);
                object diagnosticResult = this.GetDiagnosticResult();
                if (diagnosticResult == null)
                {
                    XName name = this.GetDiagnosticComponentName();
                    TArgument arguments3 = this.Arguments;
                    return new XElement(name, new XText(arguments3.GetSupportedArguments()));
                }
                XDocument xdocument = new XDocument();
                using (XmlWriter xmlWriter = xdocument.CreateWriter())
                {
                    XmlObjectSerializer xmlObjectSerializer = this.CreateSerializer(diagnosticResult.GetType());
                    xmlObjectSerializer.WriteObject(xmlWriter, diagnosticResult);
                }
                return xdocument.Root;
            }));
        }
Exemplo n.º 2
0
 public void Initialize(DiagnosableParameters parameters)
 {
     this.Initialize(parameters.Argument);
 }
Exemplo n.º 3
0
        XElement IDiagnosable.GetDiagnosticInfo(DiagnosableParameters parameters)
        {
            XElement xelement = new XElement(this.ComponentName);
            SICDiagnosticArgument arguments = this.CreateDiagnosticArgumentParser();

            try
            {
                arguments.Initialize(parameters);
            }
            catch (DiagnosticArgumentException ex)
            {
                xelement.Add(new XElement("Error", "Encountered exception: " + ex.Message));
                xelement.Add(new XElement("Help", "Supported arguments: " + arguments.GetSupportedArguments()));
                return(xelement);
            }
            List <ServiceIssue> list = null;

            if (arguments.HasArgument("invokescan"))
            {
                this.InvokeScan();
            }
            lock (this.cacheLock)
            {
                xelement.Add(new object[]
                {
                    new XElement("ScanFrequency", this.FullScanFrequency.ToString()),
                    new XElement("IssueLimit", this.IssueLimit),
                    new XElement("IsScanning", this.isScanning),
                    new XElement("IsEnabled", this.ScanningIsEnabled),
                    new XElement("LastScanStartTime", this.lastScanStartTime),
                    new XElement("LastScanDuration", this.lastScanDuration.TotalMilliseconds),
                    new XElement("NumberOfIssues", this.issueCache.Count)
                });
                if (this.LastScanError != null)
                {
                    xelement.Add(new object[]
                    {
                        new XElement("LastScanErrorName", this.LastScanError.GetType().Name),
                        new XElement("LastScanErrorMessage", this.LastScanError.Message)
                    });
                }
                if (arguments.HasArgument("issue"))
                {
                    list = new List <ServiceIssue>(this.issueCache.Values);
                }
            }
            if (list != null)
            {
                int      argumentOrDefault = arguments.GetArgumentOrDefault <int>("maxsize", list.Count);
                XElement xelement2         = new XElement("ServiceIssues");
                using (IEnumerator <ServiceIssue> enumerator = list.Take(argumentOrDefault).GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        ServiceIssue issue = enumerator.Current;
                        xelement2.Add(arguments.RunDiagnosticOperation(() => issue.GetDiagnosticInfo(arguments)));
                    }
                }
                xelement.Add(xelement2);
            }
            if (arguments.ArgumentCount == 0)
            {
                xelement.Add(new XElement("Help", "Supported arguments: " + arguments.GetSupportedArguments()));
            }
            return(xelement);
        }