Пример #1
0
        public void AddLineAndUpdate3_error(IAddLine iFace, out string allOut)
        {
            lock (this)
            {
                if (iFace == null)
                {
                    throw new Exception("iFace == null");
                }
                if (IAddLines == null)
                {
                    throw new Exception("IAddLines == null");
                }

                if (iFace.MergeSupported)
                {
                    IAddLine old   = IAddLines.ContainsKey(iFace.DisplayItem) ? IAddLines[iFace.DisplayItem] : null;
                    IAddLine newIf = iFace.MergeAddLine(old);

                    if (old == null)
                    {
                        IAddLines.Add(newIf.DisplayItem, newIf);
                    }
                    else
                    {
                        IAddLines[newIf.DisplayItem] = newIf;
                    }
                }
                else if (IAddLines.ContainsKey(iFace.DisplayItem))
                {
                    IAddLines[iFace.DisplayItem] = iFace;
                }
                else
                {
                    IAddLines.Add(iFace.DisplayItem, iFace);
                }

                StringBuilder sb = new StringBuilder();
                foreach (KeyValuePair <eDisplayItem, IAddLine> i in IAddLines)
                {
                    try
                    {
                        sb.AppendLine(i.Value.ToInfoLine());
                    }
                    catch (Exception ex)
                    {
                        sb.AppendLine("--Exception --");
                    }
                }

                allOut = sb.ToString();
            }
        }
Пример #2
0
        public void AddLineAndUpdate3(IAddLine iFace, out string allOut, StringBuilder debug)
        {
            lock (this)
            {
                if (iFace == null)
                {
                    throw new Exception("iFace == null");
                }
                if (IAddLines == null)
                {
                    throw new Exception("IAddLines == null");
                }

                if (iFace.MergeSupported)
                {
                    IAddLine old   = IAddLines.ContainsKey(iFace.DisplayItem) ? IAddLines[iFace.DisplayItem] : null;
                    IAddLine newIf = iFace.MergeAddLine(old);

                    if (newIf == null)
                    {
                        throw new Exception("newIf == null");
                    }

                    if (old == null)
                    {
                        IAddLines.Add(newIf.DisplayItem, newIf);
                    }
                    else
                    {
                        IAddLines[newIf.DisplayItem] = newIf;
                    }
                }
                else if (IAddLines.ContainsKey(iFace.DisplayItem))
                {
                    IAddLines[iFace.DisplayItem] = iFace;
                }
                else
                {
                    IAddLines.Add(iFace.DisplayItem, iFace);
                }

                foreach (eDisplayItem report in iFace.ReportTo)
                {
                    IAddLine other = IAddLines.FirstOrDefault(i => i.Key == report).Value;
                    other?.IncomingReport(iFace);
                }

                StringBuilder sb = new StringBuilder();
                foreach (KeyValuePair <eDisplayItem, IAddLine> i in IAddLines)
                {
                    try
                    {
                        sb.AppendLine(i.Value.ToInfoLine());
                    }
                    catch (Exception ex)
                    {
                        sb.AppendLine("--Exception --");
                    }
                }

                allOut = sb.ToString();
            }
        }