Esempio n. 1
0
        public static DecreePartReferent CreateRangeReferent(DecreePartReferent min, DecreePartReferent max)
        {
            DecreePartReferent res = min.Clone() as DecreePartReferent;
            int cou = 0;

            foreach (Pullenti.Ner.Slot s in res.Slots)
            {
                Pullenti.Ner.Slot ss = max.FindSlot(s.TypeName, null, true);
                if (ss == null)
                {
                    return(null);
                }
                if (ss.Value == s.Value)
                {
                    continue;
                }
                if (max.FindSlot(s.TypeName, s.Value, true) != null)
                {
                    continue;
                }
                if ((++cou) > 1)
                {
                    return(null);
                }
                res.UploadSlot(s, string.Format("{0}-{1}", s.Value, ss.Value));
            }
            if (cou != 1)
            {
                return(null);
            }
            return(res);
        }
Esempio n. 2
0
        public override string ToString(bool shortVariant, Pullenti.Morph.MorphLang lang = null, int lev = 0)
        {
            StringBuilder res = new StringBuilder();
            List <string> nws = NewItems;

            if (nws.Count > 0)
            {
                foreach (string p in nws)
                {
                    DecreePartReferent dpr = new DecreePartReferent();
                    int ii = p.IndexOf(' ');
                    if (ii < 0)
                    {
                        dpr.AddSlot(p, "", false, 0);
                    }
                    else
                    {
                        dpr.AddSlot(p.Substring(0, ii), p.Substring(ii + 1), false, 0);
                    }
                    res.AppendFormat(" новый '{0}'", dpr.ToString(true, null, 0));
                }
            }
            if (Kind != DecreeChangeValueKind.Undefined)
            {
                res.AppendFormat(" {0}", Pullenti.Ner.Decree.Internal.MetaDecreeChangeValue.KindFeature.ConvertInnerValueToOuterValue(Kind.ToString(), lang).ToString().ToLower());
            }
            if (Number != null)
            {
                res.AppendFormat(" {0}", Number);
            }
            string val = Value;

            if (val != null)
            {
                if (val.Length > 100)
                {
                    val = val.Substring(0, 100) + "...";
                }
                res.AppendFormat(" '{0}'", val);
                res.Replace('\n', ' ');
                res.Replace('\r', ' ');
            }
            return(res.ToString().Trim());
        }
Esempio n. 3
0
        bool _CanBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ, bool ignoreGeo)
        {
            DecreePartReferent dr = obj as DecreePartReferent;

            if (dr == null)
            {
                return(false);
            }
            if (Owner != null && dr.Owner != null)
            {
                if (Owner != dr.Owner)
                {
                    return(false);
                }
            }
            else if (typ == Pullenti.Ner.Core.ReferentsEqualType.DifferentTexts)
            {
                return(false);
            }
            else
            {
                string ty1 = (Owner == null ? LocalTyp : Owner.Typ);
                string ty2 = (dr.Owner == null ? dr.LocalTyp : dr.Owner.Typ);
                if (ty1 != ty2)
                {
                    ty1 = (Owner == null ? LocalTyp : Owner.Typ0);
                    ty2 = (dr.Owner == null ? dr.LocalTyp : dr.Owner.Typ0);
                    if (ty1 != ty2)
                    {
                        return(false);
                    }
                }
            }
            if (Clause != dr.Clause)
            {
                if (typ == Pullenti.Ner.Core.ReferentsEqualType.ForMerging && ((Clause == null || dr.Clause == null)))
                {
                }
                else
                {
                    return(false);
                }
            }
            if (Part != dr.Part)
            {
                if (typ == Pullenti.Ner.Core.ReferentsEqualType.ForMerging && ((Part == null || dr.Part == null)))
                {
                }
                else
                {
                    return(false);
                }
            }
            if (Paragraph != dr.Paragraph)
            {
                if (typ == Pullenti.Ner.Core.ReferentsEqualType.ForMerging && ((Paragraph == null || dr.Paragraph == null)))
                {
                }
                else
                {
                    return(false);
                }
            }
            if (SubParagraph != dr.SubParagraph)
            {
                if (typ == Pullenti.Ner.Core.ReferentsEqualType.ForMerging && ((SubParagraph == null || dr.SubParagraph == null)))
                {
                }
                else
                {
                    return(false);
                }
            }
            if (Item != dr.Item)
            {
                if (typ == Pullenti.Ner.Core.ReferentsEqualType.ForMerging && ((Item == null || dr.Item == null)))
                {
                }
                else
                {
                    return(false);
                }
            }
            if (SubItem != dr.SubItem)
            {
                if (typ == Pullenti.Ner.Core.ReferentsEqualType.ForMerging && ((SubItem == null || dr.SubItem == null)))
                {
                }
                else
                {
                    return(false);
                }
            }
            if (Notice != dr.Notice)
            {
                if (typ == Pullenti.Ner.Core.ReferentsEqualType.ForMerging && ((Notice == null || dr.Notice == null)))
                {
                }
                else
                {
                    return(false);
                }
            }
            if (Indention != dr.Indention)
            {
                if (typ == Pullenti.Ner.Core.ReferentsEqualType.ForMerging && ((Indention == null || dr.Indention == null)))
                {
                }
                else
                {
                    return(false);
                }
            }
            if (SubIndention != dr.SubIndention)
            {
                if (typ == Pullenti.Ner.Core.ReferentsEqualType.ForMerging && ((SubIndention == null || dr.SubIndention == null)))
                {
                }
                else
                {
                    return(false);
                }
            }
            if (Appendix != dr.Appendix)
            {
                if (Appendix != null && dr.Appendix != null)
                {
                    return(false);
                }
                if (Clause == null && Paragraph == null && Item == null)
                {
                    return(false);
                }
            }
            if (Chapter != dr.Chapter)
            {
                if (Chapter != null && dr.Chapter != null)
                {
                    return(false);
                }
                if (Clause == null && Paragraph == null && Item == null)
                {
                    return(false);
                }
            }
            if (Section != dr.Section)
            {
                if (Section != null && dr.Section != null)
                {
                    return(false);
                }
                if ((Clause == null && Paragraph == null && Item == null) && SubSection == null)
                {
                    return(false);
                }
            }
            if (SubSection != dr.SubSection)
            {
                if (SubSection != null && dr.SubSection != null)
                {
                    return(false);
                }
                if (Clause == null && Paragraph == null && Item == null)
                {
                    return(false);
                }
            }
            if (Subprogram != null || dr.Subprogram != null)
            {
                if (Name != dr.Name)
                {
                    return(false);
                }
                return(true);
            }
            if (Addagree != null || dr.Addagree != null)
            {
                if (Addagree != dr.Addagree)
                {
                    return(false);
                }
            }
            if (DocPart != dr.DocPart)
            {
                if (typ == Pullenti.Ner.Core.ReferentsEqualType.ForMerging && ((DocPart == null || dr.DocPart == null)))
                {
                }
                else
                {
                    return(false);
                }
            }
            if (Page != dr.Page)
            {
                return(false);
            }
            return(true);
        }
Esempio n. 4
0
 // Добавить информацию о вышележащих элементах
 internal void AddHighLevelInfo(DecreePartReferent dp)
 {
     if (dp.Addagree != null && Addagree == null)
     {
         Addagree = dp.Addagree;
     }
     else if (dp.Addagree != Addagree)
     {
         return;
     }
     if (dp.Appendix != null && Appendix == null)
     {
         Appendix = dp.Appendix;
     }
     else if (Appendix != dp.Appendix)
     {
         return;
     }
     if (dp.DocPart != null && DocPart == null)
     {
         DocPart = dp.DocPart;
     }
     else if (DocPart != dp.DocPart)
     {
         return;
     }
     if (dp.Section != null && Section == null && this._hasLessLevelAttr(ATTR_SECTION))
     {
         Section = dp.Section;
     }
     else if (Section != dp.Section)
     {
         return;
     }
     if (dp.SubSection != null && SubSection == null && this._hasLessLevelAttr(ATTR_SUBSECTION))
     {
         SubSection = dp.SubSection;
     }
     else if (SubSection != dp.SubSection)
     {
         return;
     }
     if (dp.Chapter != null && Chapter == null && this._hasLessLevelAttr(ATTR_CHAPTER))
     {
         Chapter = dp.Chapter;
     }
     else if (dp.Chapter != Chapter)
     {
         return;
     }
     if (dp.Paragraph != null && Paragraph == null && this._hasLessLevelAttr(ATTR_PARAGRAPH))
     {
         Paragraph = dp.Paragraph;
     }
     else if (Paragraph != dp.Paragraph)
     {
         return;
     }
     if (dp.SubParagraph != null && SubParagraph == null && this._hasLessLevelAttr(ATTR_SUBPARAGRAPH))
     {
         SubParagraph = dp.SubParagraph;
     }
     else if (SubParagraph != dp.SubParagraph)
     {
         return;
     }
     if (dp.Clause != null && Clause == null && this._hasLessLevelAttr(ATTR_CLAUSE))
     {
         Clause = dp.Clause;
     }
     else if (dp.Clause != Clause)
     {
         return;
     }
     if (dp.Part != null && Part == null && this._hasLessLevelAttr(ATTR_PART))
     {
         Part = dp.Part;
     }
     else if (dp.Part != Part)
     {
         return;
     }
     if (dp.Item != null && Item == null && this._hasLessLevelAttr(ATTR_ITEM))
     {
         if (SubItem != null && SubItem.IndexOf('.') > 0)
         {
         }
         else
         {
             Item = dp.Item;
         }
     }
     else if (dp.Item != Item)
     {
         return;
     }
     if (dp.SubItem != null && SubItem == null && this._hasLessLevelAttr(ATTR_SUBITEM))
     {
         SubItem = dp.SubItem;
     }
     else if (dp.SubItem != SubItem)
     {
         return;
     }
     if (dp.Indention != null && Indention == null && this._hasLessLevelAttr(ATTR_INDENTION))
     {
         Indention = dp.Indention;
     }
 }