Example #1
0
        internal void DeserializeLazy(ByteArrayWrapper str, MorphEngine me, ref int pos)
        {
            this._deserializeBase(str, ref pos);
            int cou = str.DeserializeShort(ref pos);

            if (cou > 0)
            {
                Nodes = new Dictionary <short, MorphTreeNode>();
                for (; cou > 0; cou--)
                {
                    int           i     = str.DeserializeShort(ref pos);
                    int           pp    = str.DeserializeInt(ref pos);
                    MorphTreeNode child = new MorphTreeNode();
                    child.LazyPos = pos;
                    Nodes.Add((short)i, child);
                    pos = pp;
                }
            }
            int p = pos;

            if (RuleIds != null)
            {
                foreach (int rid in RuleIds)
                {
                    MorphRule r = me.GetMutRule(rid);
                    if (r.LazyPos > 0)
                    {
                        pos = r.LazyPos;
                        r.Deserialize(str, ref pos);
                        r.LazyPos = 0;
                    }
                }
                pos = p;
            }
            if (ReverceVariants != null)
            {
                foreach (MorphRuleVariantRef rv in ReverceVariants)
                {
                    MorphRule r = me.GetMutRule(rv.RuleId);
                    if (r.LazyPos > 0)
                    {
                        pos = r.LazyPos;
                        r.Deserialize(str, ref pos);
                        r.LazyPos = 0;
                    }
                }
                pos = p;
            }
        }
Example #2
0
        internal int Deserialize(ByteArrayWrapper str, ref int pos)
        {
            int res = 0;

            this._deserializeBase(str, ref pos);
            int cou = str.DeserializeShort(ref pos);

            if (cou > 0)
            {
                Nodes = new Dictionary <short, MorphTreeNode>();
                for (; cou > 0; cou--)
                {
                    int           i     = str.DeserializeShort(ref pos);
                    int           pp    = str.DeserializeInt(ref pos);
                    MorphTreeNode child = new MorphTreeNode();
                    int           res1  = child.Deserialize(str, ref pos);
                    res += (1 + res1);
                    Nodes.Add((short)i, child);
                }
            }
            return(res);
        }