Example #1
0
        public override string ToString(bool shortVariant, Pullenti.Morph.MorphLang lang = null, int lev = 0)
        {
            StringBuilder res = new StringBuilder();

            if (Name != null)
            {
                res.Append(Name);
            }
            foreach (Pullenti.Ner.Slot r in Slots)
            {
                if (r.TypeName == ATTR_ATTR && r.Value != null)
                {
                    res.AppendFormat(", {0}", r.Value.ToString());
                }
            }
            foreach (Pullenti.Ner.Slot r in Slots)
            {
                if (r.TypeName == ATTR_REF && (r.Value is Pullenti.Ner.Referent) && (lev < 10))
                {
                    res.AppendFormat("; {0}", (r.Value as Pullenti.Ner.Referent).ToString(shortVariant, lang, lev + 1));
                }
            }
            PersonPropertyReferent hi = Higher;

            if (hi != null && hi != this && this.CheckCorrectHigher(hi, 0))
            {
                res.AppendFormat("; {0}", hi.ToString(shortVariant, lang, lev + 1));
            }
            return(res.ToString());
        }
Example #2
0
        public override bool CanBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ)
        {
            PersonPropertyReferent pr = obj as PersonPropertyReferent;

            if (pr == null)
            {
                return(false);
            }
            string n1 = Name;
            string n2 = pr.Name;

            if (n1 == null || n2 == null)
            {
                return(false);
            }
            bool eqBosses = false;

            if (n1 != n2)
            {
                if (typ == Pullenti.Ner.Core.ReferentsEqualType.DifferentTexts)
                {
                    return(false);
                }
                if (m_Bosses0.Contains(n1) && m_Bosses1.Contains(n2))
                {
                    eqBosses = true;
                }
                else if (m_Bosses1.Contains(n1) && m_Bosses0.Contains(n2))
                {
                    eqBosses = true;
                }
                else
                {
                    if (!n1.StartsWith(n2 + " ") && !n2.StartsWith(n1 + " "))
                    {
                        return(false);
                    }
                    eqBosses = true;
                }
                for (PersonPropertyReferent hi = Higher; hi != null; hi = hi.Higher)
                {
                    if ((++_tmpStack) > 20)
                    {
                    }
                    else if (hi.CanBeEquals(pr, typ))
                    {
                        _tmpStack--;
                        return(false);
                    }
                    _tmpStack--;
                }
                for (PersonPropertyReferent hi = pr.Higher; hi != null; hi = hi.Higher)
                {
                    if ((++_tmpStack) > 20)
                    {
                    }
                    else if (hi.CanBeEquals(this, typ))
                    {
                        _tmpStack--;
                        return(false);
                    }
                    _tmpStack--;
                }
            }
            if (Higher != null && pr.Higher != null)
            {
                if ((++_tmpStack) > 20)
                {
                }
                else if (!Higher.CanBeEquals(pr.Higher, typ))
                {
                    _tmpStack--;
                    return(false);
                }
                _tmpStack--;
            }
            if (this.FindSlot("@GENERAL", null, true) != null || pr.FindSlot("@GENERAL", null, true) != null)
            {
                return(this.ToString() == pr.ToString());
            }
            if (this.FindSlot(ATTR_REF, null, true) != null || pr.FindSlot(ATTR_REF, null, true) != null)
            {
                List <object> refs1 = new List <object>();
                List <object> refs2 = new List <object>();
                foreach (Pullenti.Ner.Slot s in Slots)
                {
                    if (s.TypeName == ATTR_REF)
                    {
                        refs1.Add(s.Value);
                    }
                }
                foreach (Pullenti.Ner.Slot s in pr.Slots)
                {
                    if (s.TypeName == ATTR_REF)
                    {
                        refs2.Add(s.Value);
                    }
                }
                bool eq   = false;
                bool noeq = false;
                for (int i = 0; i < refs1.Count; i++)
                {
                    if (refs2.Contains(refs1[i]))
                    {
                        eq = true;
                        continue;
                    }
                    noeq = true;
                    if (refs1[i] is Pullenti.Ner.Referent)
                    {
                        foreach (object rr in refs2)
                        {
                            if (rr is Pullenti.Ner.Referent)
                            {
                                if ((rr as Pullenti.Ner.Referent).CanBeEquals(refs1[i] as Pullenti.Ner.Referent, typ))
                                {
                                    noeq = false;
                                    eq   = true;
                                    break;
                                }
                            }
                        }
                    }
                }
                for (int i = 0; i < refs2.Count; i++)
                {
                    if (refs1.Contains(refs2[i]))
                    {
                        eq = true;
                        continue;
                    }
                    noeq = true;
                    if (refs2[i] is Pullenti.Ner.Referent)
                    {
                        foreach (object rr in refs1)
                        {
                            if (rr is Pullenti.Ner.Referent)
                            {
                                if ((rr as Pullenti.Ner.Referent).CanBeEquals(refs2[i] as Pullenti.Ner.Referent, typ))
                                {
                                    noeq = false;
                                    eq   = true;
                                    break;
                                }
                            }
                        }
                    }
                }
                if (eq && !noeq)
                {
                }
                else if (noeq && ((eq || refs1.Count == 0 || refs2.Count == 0)))
                {
                    if (typ == Pullenti.Ner.Core.ReferentsEqualType.DifferentTexts || n1 != n2)
                    {
                        return(false);
                    }
                    if (Higher != null || pr.Higher != null)
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else if (!eqBosses && n1 != n2)
            {
                return(false);
            }
            return(true);
        }