Медленная навигация для просмотра модели с циклическими ссылками - PullRequest
0 голосов
/ 25 сентября 2018

У меня есть приложение и модель WPF с циклическими ссылками, такими как:

class A : ModelBase
{
    public FastObservableCollection<B> Collection {get; set;}
}

class B : ModelBase
{
    public A Parent {get; set;}
}

, когда я загружаю более 100 экземпляров, а переход к другому отладочному выводу ViewModel забивается сообщениями:

...
20:40:36:751 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Creating new scope for type 'Catel.Runtime.Serialization.SerializationScope' with name 'Thread_1'
20:40:36:752 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Custom function to create the scope is provided, creating custom scope for type 'Catel.Runtime.Serialization.SerializationScope' with name 'Thread_1'
20:40:36:754 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Referencing type 'Catel.Runtime.Serialization.SerializationScope' with scope name 'Thread_1', new ref count is 1
20:40:36:755 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Returning existing scope for type 'Catel.Runtime.Serialization.SerializationScope' with name 'Thread_1'
20:40:36:757 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Referencing type 'Catel.Runtime.Serialization.SerializationScope' with scope name 'Thread_1', new ref count is 2
20:40:36:758 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Dereferencing type 'Catel.Runtime.Serialization.SerializationScope' with scope name 'Thread_1', new ref count is 1
20:40:36:759 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Creating new scope for type 'Catel.Runtime.Serialization.SerializationContextScope`1[[Catel.Runtime.Serialization.Xml.XmlSerializationContextInfo, Catel.Core, Version=5.7.0.0, Culture=neutral, PublicKeyToken=null]]' with name 'Thread_1'
20:40:36:761 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Custom function to create the scope is provided, creating custom scope for type 'Catel.Runtime.Serialization.SerializationContextScope`1[[Catel.Runtime.Serialization.Xml.XmlSerializationContextInfo, Catel.Core, Version=5.7.0.0, Culture=neutral, PublicKeyToken=null]]' with name 'Thread_1'
20:40:36:762 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Referencing type 'Catel.Runtime.Serialization.SerializationContextScope`1[[Catel.Runtime.Serialization.Xml.XmlSerializationContextInfo, Catel.Core, Version=5.7.0.0, Culture=neutral, PublicKeyToken=null]]' with scope name 'Thread_1', new ref count is 1
20:40:36:763 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Returning existing scope for type 'Catel.Runtime.Serialization.SerializationScope' with name 'Thread_1'
20:40:36:765 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Referencing type 'Catel.Runtime.Serialization.SerializationScope' with scope name 'Thread_1', new ref count is 2
20:40:36:766 => [DEBUG] [Catel.Runtime.Serialization.Xml.XmlSerializer] [1] Serializing property VSMC.Models.ApplicationModel.CurrentChannel as xml element 'CurrentChannel'
20:40:36:768 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Returning existing scope for type 'Catel.Runtime.Serialization.SerializationContextScope`1[[Catel.Runtime.Serialization.Xml.XmlSerializationContextInfo, Catel.Core, Version=5.7.0.0, Culture=neutral, PublicKeyToken=null]]' with name 'Thread_1'
20:40:36:769 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Referencing type 'Catel.Runtime.Serialization.SerializationContextScope`1[[Catel.Runtime.Serialization.Xml.XmlSerializationContextInfo, Catel.Core, Version=5.7.0.0, Culture=neutral, PublicKeyToken=null]]' with scope name 'Thread_1', new ref count is 2
20:40:36:771 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Dereferencing type 'Catel.Runtime.Serialization.SerializationContextScope`1[[Catel.Runtime.Serialization.Xml.XmlSerializationContextInfo, Catel.Core, Version=5.7.0.0, Culture=neutral, PublicKeyToken=null]]' with scope name 'Thread_1', new ref count is 1
20:40:36:772 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Returning existing scope for type 'Catel.Runtime.Serialization.SerializationScope' with name 'Thread_1'
20:40:36:774 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Referencing type 'Catel.Runtime.Serialization.SerializationScope' with scope name 'Thread_1', new ref count is 3
20:40:36:775 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Returning existing scope for type 'Catel.Runtime.Serialization.SerializationScope' with name 'Thread_1'
20:40:36:776 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Referencing type 'Catel.Runtime.Serialization.SerializationScope' with scope name 'Thread_1', new ref count is 4
20:40:36:778 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Returning existing scope for type 'Catel.Runtime.Serialization.SerializationScope' with name 'Thread_1'
20:40:36:779 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Referencing type 'Catel.Runtime.Serialization.SerializationScope' with scope name 'Thread_1', new ref count is 5
20:40:36:780 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Dereferencing type 'Catel.Runtime.Serialization.SerializationScope' with scope name 'Thread_1', new ref count is 4
20:40:36:781 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Returning existing scope for type 'Catel.Runtime.Serialization.SerializationContextScope`1[[Catel.Runtime.Serialization.Xml.XmlSerializationContextInfo, Catel.Core, Version=5.7.0.0, Culture=neutral, PublicKeyToken=null]]' with name 'Thread_1'
20:40:36:782 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Referencing type 'Catel.Runtime.Serialization.SerializationContextScope`1[[Catel.Runtime.Serialization.Xml.XmlSerializationContextInfo, Catel.Core, Version=5.7.0.0, Culture=neutral, PublicKeyToken=null]]' with scope name 'Thread_1', new ref count is 2
20:40:36:783 => [DEBUG] [Catel.Runtime.Serialization.SerializerBase`1] [1] Using '0' serializer modifiers to deserialize type 'VSMC.Models.ChannelModel'
20:40:36:784 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Returning existing scope for type 'Catel.Runtime.Serialization.SerializationScope' with name 'Thread_1'
20:40:36:785 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Referencing type 'Catel.Runtime.Serialization.SerializationScope' with scope name 'Thread_1', new ref count is 5
20:40:36:786 => [DEBUG] [Catel.Runtime.Serialization.Xml.XmlSerializer] [1] Serializing property VSMC.Models.ChannelModel.Id as xml element 'Id'
...

и приложение зависает на 10+ секунд.Что я делаю не так?Можно ли отключить сериализацию модели при навигации?

...