示例#1
0
        public IEnumerable <object> ReadAllObjects()
        {
            var types = TypeRegistry.GetDTOTypes().OrderBy(x => x.Name).ToList();

            if (!types.Any(x => x.Equals(typeof(Include))))
            {
                types.Add(typeof(Include));
            }

            types = types.Union(GetSubTypes(types)).ToList();

            using (ISerializer adapter = new SerializerFactory().GetSerializerByPath(Path))
            {
                try
                {
                    var result = new List <object>();

                    foreach (var o in adapter.Deserialize())
                    {
                        if (o is Include)
                        {
                            result.AddRange(ExpandInclude((Include)o));
                        }
                        else
                        {
                            result.Add(o);
                        }
                    }

                    return(result);
                }
                catch (Exception e)
                {
                    throw new IOException($"Exception occured when reading file {Path}\n{e.GetAllMessages()}", e);
                }
            }
        }