public void Write(ICommerceEntity entity)
        {
            if (_writer == null)
            {
                return;
            }

            if (entity == null)
            {
                _writer.WriteLine("<null>");
            }

            OutputInternal(entity, String.Empty);
        }
        private void OutputInternal(ICommerceEntity entity, string linePrefix)
        {
            if (entity == null)
            {
                return;
            }

            _writer.Write(linePrefix);
            _writer.WriteLine("Model = {0}", entity.ModelName);

            foreach (var property in entity.Properties)
            {
                _writer.Write(linePrefix);

                if (property.Value is CommerceRelationshipList)
                {
                    _writer.WriteLine(property.Key);

                    foreach (var relationShipEntity in (property.Value as CommerceRelationshipList).Select(x => x.Target))
                    {
                        OutputInternal(relationShipEntity, AppendLinePrefix(linePrefix));
                    }
                }
                else if (property.Value is CommerceRelationship)
                {
                    _writer.WriteLine(property.Key);

                    OutputInternal((property.Value as CommerceRelationship).Target, AppendLinePrefix(linePrefix));
                }
                else
                {
                    _writer.WriteLine(
                        "{0} = {1} ({2})",
                        property.Key,
                        WriteValue(property.Value),
                        property.Value != null ? property.Value.GetType().FullName : "<null>");
                }
            }

            _writer.WriteLine();
        }
 public static void Output(this ICommerceEntity entity, TextWriter writer)
 {
     new CommerceEntityWriter(writer).Write(entity);
 }
Esempio n. 4
0
 public WrongModelException(ICommerceEntity entity, string expectedModelName) :
     this(String.Format(Resources.Exceptions.Entity_WrongModel, entity.ModelName, expectedModelName))
 {
 }