Ejemplo n.º 1
0
 protected abstract int?GetChildrenPriority(IUnparser unparser, object astValue, Unparser.Children childrenAtRule, Unparser.Direction direction);
Ejemplo n.º 2
0
        protected override int?GetChildrenPriority(IUnparser unparser, object astValue, Unparser.Children children, Unparser.Direction direction)
        {
            System.Collections.IEnumerable collection = (System.Collections.IEnumerable)astValue;

            if (collection != null || this.EmptyCollectionHandling == EmptyCollectionHandling.ReturnNull)
            {
                return(1);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 3
0
 int?IUnparsableNonTerminal.GetChildrenPriority(IUnparser unparser, object astValue, Unparser.Children childrenAtRule, Unparser.Direction direction)
 {
     return(GetChildrenPriority(unparser, astValue, childrenAtRule, direction));
 }
Ejemplo n.º 4
0
 protected override int?GetChildrenPriority(IUnparser unparser, object astValue, Unparser.Children children, Unparser.Direction direction)
 {
     return(children.SumIncludingNullValues(child => unparser.GetPriority(child)));
 }
Ejemplo n.º 5
0
        protected override int?GetChildrenPriority(IUnparser unparser, object astValue, Unparser.Children children, Unparser.Direction direction)
        {
            UnparsableAst mainChild = children.Single(childValue => IsMainChild(childValue.BnfTerm));

            if (astValue.GetType() == this.domainType)
            {
                return(unparser.GetPriority(mainChild));
            }
            else
            {
                IBnfiTerm mainChildWithDomainType = mainChild.BnfTerm as IBnfiTerm;

                if (mainChildWithDomainType == null || mainChildWithDomainType.DomainType == null)
                {
                    throw new UnparseException(string.Format("Cannot unparse '{0}' (type: '{1}'). BnfTerm '{2}' is not an IBnfiTerm or it has no domain type.",
                                                             astValue, astValue.GetType().Name, mainChild.BnfTerm));
                }

                int?priority = mainChildWithDomainType.DomainType == typeof(object)
                    ? int.MinValue
                    : 0 - mainChildWithDomainType.DomainType.GetInheritanceDistance(astValue);

                Unparser.tsPriorities.Indent();
                priority.DebugWriteLinePriority(Unparser.tsPriorities, mainChild);
                Unparser.tsPriorities.Unindent();

                return(priority);
            }
        }
Ejemplo n.º 6
0
 protected override int?GetChildrenPriority(IUnparser unparser, object astValue, Unparser.Children children, Unparser.Direction direction)
 {
     if (this.isOptionalValue && object.Equals(astValue, this.defaultValue))
     {
         return(0);
     }
     else if (this.value != null)
     {
         return(this.value.Equals(astValue) ? (int?)1 : null);
     }
     else if (this.UtokenizerForUnparse != null)
     {
         return(1);
     }
     else
     {
         return(unparser.GetPriority(GetMainChild(astValue, children)));
     }
 }
Ejemplo n.º 7
0
 protected override int?GetChildrenPriority(IUnparser unparser, object astValue, Unparser.Children childrenAtRule, Unparser.Direction direction)
 {
     return(childrenAtRule
            .SumIncludingNullValues(
                (childAtRule, childIndexAtRule) => IsMemberAtRule(new ReferredBnfTermEI(childrenAtRule.ContentIndex, childAtRule.BnfTerm, childIndexAtRule))
                 ? GetBnfTermPriorityForMember(unparser, childAtRule)
                 : unparser.GetPriority(childAtRule)
                ));
 }
Ejemplo n.º 8
0
 protected override int?GetChildrenPriority(IUnparser unparser, object astValue, Unparser.Children children, Unparser.Direction direction)
 {
     return(0);
 }