private void AppendMember(StringBuilder text, ConceptMemberSyntax member)
        {
            object memberValue = member.GetMemberValue(this);

            if (memberValue == null)
            {
                text.Append("<null>");
            }
            else if (member.IsConceptInfo)
            {
                var value = (ConceptSyntaxNode)memberValue;
                if (member.IsConceptInfoInterface)
                {
                    text.Append(value.Concept.GetRootTypeName()).Append(':');
                }
                value.AppendKeyMembers(text);
            }
            else if (member.IsStringType)
            {
                ConceptMemberHelper.AppendWithQuotesIfNeeded(text, (string)memberValue);
            }
            else
            {
                throw new FrameworkException(
                          $"{nameof(ConceptSyntaxNode)} member {member.Name} of type {member.ConceptType?.TypeName} in {Concept.TypeName} is not supported.");
            }
        }
Пример #2
0
        private static void AppendMember(StringBuilder text, IConceptInfo ci, ConceptMember member, bool exceptionOnNullMember)
        {
            object memberValue = member.GetValue(ci);

            if (memberValue == null)
            {
                if (exceptionOnNullMember)
                {
                    throw new DslSyntaxException(ci, string.Format(
                                                     "{0}'s property {1} is null. Info: {2}.",
                                                     ci.GetType().Name, member.Name, ci.GetErrorDescription()));
                }
                else
                {
                    text.Append("<null>");
                }
            }
            else if (member.IsConceptInfo)
            {
                IConceptInfo value = (IConceptInfo)memberValue;
                if (member.IsConceptInfoInterface)
                {
                    text.Append(BaseConceptInfoType(value).Name).Append(':');
                }
                AppendMembers(text, value, SerializationOptions.KeyMembers, exceptionOnNullMember);
            }
            else if (member.IsStringType)
            {
                ConceptMemberHelper.AppendWithQuotesIfNeeded(text, (string)memberValue);
            }
            else
            {
                throw new FrameworkException(string.Format(
                                                 "IConceptInfo member {0} of type {1} in {2} is not supported.",
                                                 member.Name, member.ValueType.Name, ci.GetType().Name));
            }
        }