void IPropertyBagVisitor.Visit <TContainer>(IPropertyBag <TContainer> properties, ref TContainer container) { if (properties is IPropertyWrapper) { using (var enumerator = properties.GetProperties().GetEnumerator()) { if (enumerator.MoveNext() && null != enumerator.Current) { var property = enumerator.Current; using (CreatePropertyScope(property)) { property.Accept(this, ref container); } } else { throw new InvalidOperationException("IPropertyWrapper has no properties"); } } } else { if (m_View.Type != TokenType.Object) { throw new ArgumentException(); } var obj = m_View.AsObjectView(); if (!(Property is IPropertyWrapper && m_DisableRootMigration)) { if (m_Migrations.TryMigrate <TContainer>(obj, out var migrated, this, m_SerializedTypeProvider.Events)) { m_SerializedReferences?.AddDeserializedReference(m_Metadata.SerializedId, migrated); container = migrated; return; } } foreach (var property in properties.GetProperties(ref container)) { if (PropertyChecks.IsPropertyExcludedFromSerialization(property)) { continue; } AcceptProperty(ref container, obj, property); } } }
/// <summary> /// Invoked by Unity.Properties for each container type (i.e. struct or class). /// </summary> /// <param name="properties">The property bag being visited.</param> /// <param name="srcContainer">The source container being visited.</param> /// <typeparam name="TContainer">The container type.</typeparam> void IPropertyBagVisitor.Visit <TContainer>(IPropertyBag <TContainer> properties, ref TContainer srcContainer) { foreach (var property in properties.GetProperties(ref srcContainer)) { ((IPropertyAccept <TContainer>)property).Accept(this, ref srcContainer); } }
void IPropertyBagVisitor.Visit <TContainer>(IPropertyBag <TContainer> properties, ref TContainer container) { foreach (var property in properties.GetProperties(ref container)) { property.Accept(this, ref container); } }
void IPropertyBagVisitor.Visit <TContainer>(IPropertyBag <TContainer> properties, ref TContainer container) { if (properties is IPropertyList <TContainer> collection) { foreach (var property in collection.GetProperties(ref container)) { if (property.HasAttribute <NonSerializedAttribute>() || property.HasAttribute <DontSerializeAttribute>()) { continue; } ((IPropertyAccept <TContainer>)property).Accept(this, ref container); } } else { foreach (var property in properties.GetProperties(ref container)) { if (property.HasAttribute <NonSerializedAttribute>() || property.HasAttribute <DontSerializeAttribute>()) { continue; } ((IPropertyAccept <TContainer>)property).Accept(this, ref container); } } }
static IEnumerable <PropertyTypeDescriptor> VisitProperties <TContainer>( IPropertyBag <TContainer> properties) { foreach (var property in properties.GetProperties()) { yield return(new PropertyTypeDescriptor(property, property.DeclaredValueType())); } }
void IPropertyBagVisitor.Visit <TContainer>(IPropertyBag <TContainer> properties, ref TContainer container) { if (properties is IPropertyWrapper) { if (properties is IPropertyList <TContainer> propertyList) { foreach (var property in propertyList.GetProperties(ref container)) { using (CreatePropertyScope(property)) { ((IPropertyAccept <TContainer>)property).Accept(this, ref container); } } } else { throw new Exception("PropertyWrapper is missing the built in property bag."); } } else { if (m_View.Type != TokenType.Object) { throw new ArgumentException(); } var obj = m_View.AsObjectView(); if (properties is IPropertyList <TContainer> propertyList) { foreach (var property in propertyList.GetProperties(ref container)) { AcceptProperty(ref container, obj, property); } } else { foreach (var property in properties.GetProperties(ref container)) { AcceptProperty(ref container, obj, property); } } } try { if (container is ISerializationCallbackReceiver receiver) { receiver.OnAfterDeserialize(); } } catch (Exception e) { Debug.LogException(e); } }
void IPropertyBagVisitor.Visit <TContainer>(IPropertyBag <TContainer> properties, ref TContainer container) { if (properties is IPropertyWrapper) { if (properties is IPropertyList <TContainer> propertyList) { foreach (var property in propertyList.GetProperties(ref container)) { using (CreatePropertyScope(property)) { ((IPropertyAccept <TContainer>)property).Accept(this, ref container); } } } else { throw new Exception("PropertyWrapper is missing the built in property bag."); } } else { if (m_View.Type != TokenType.Object) { throw new ArgumentException(); } var obj = m_View.AsObjectView(); if (!(Property is IPropertyWrapper && m_DisableRootMigration)) { if (m_Migrations.TryMigrate <TContainer>(obj, out var migrated, this, m_SerializedTypeProvider.Events)) { m_SerializedReferences?.AddDeserializedReference(m_Metadata.SerializedId, migrated); container = migrated; return; } } if (properties is IPropertyList <TContainer> propertyList) { foreach (var property in propertyList.GetProperties(ref container)) { AcceptProperty(ref container, obj, property); } } else { foreach (var property in properties.GetProperties(ref container)) { AcceptProperty(ref container, obj, property); } } } }
void IPropertyBagVisitor.Visit <TContainer>(IPropertyBag <TContainer> properties, ref TContainer container) { foreach (var property in properties.GetProperties(ref container)) { if (PropertyChecks.IsPropertyExcludedFromSerialization(property)) { continue; } property.Accept(this, ref container); } }
void IPropertyBagVisitor.Visit <TContainer>(IPropertyBag <TContainer> properties, ref TContainer container) { if (properties is IPropertyList <TContainer> propertyList) { foreach (var property in propertyList.GetProperties(ref container)) { ((IPropertyAccept <TContainer>)property).Accept(this, ref container); } } else { foreach (var property in properties.GetProperties(ref container)) { ((IPropertyAccept <TContainer>)property).Accept(this, ref container); } } }
void IPropertyBagVisitor.Visit <TContainer>(IPropertyBag <TContainer> properties, ref TContainer container) { m_SerializedReferences?.AddDeserializedReference(container); if (properties is IPropertyList <TContainer> collection) { // no boxing foreach (var property in collection.GetProperties(ref container)) { #if !UNITY_DOTSPLAYER if (property.HasAttribute <NonSerializedAttribute>()) { continue; } #endif if (property.HasAttribute <DontSerializeAttribute>()) { continue; } ((IPropertyAccept <TContainer>)property).Accept(this, ref container); } } else { // boxing foreach (var property in properties.GetProperties(ref container)) { #if !UNITY_DOTSPLAYER if (property.HasAttribute <NonSerializedAttribute>()) { continue; } #endif if (property.HasAttribute <DontSerializeAttribute>()) { continue; } ((IPropertyAccept <TContainer>)property).Accept(this, ref container); } } }
/// <inheritdoc/> void IPropertyBagVisitor.Visit <TContainer>(IPropertyBag <TContainer> properties, ref TContainer container) { if (properties is IPropertyList <TContainer> propertyList) { // no boxing foreach (var property in propertyList.GetProperties(ref container)) { ((IPropertyAccept <TContainer>)property).Accept(this, ref container); } return; } // boxing foreach (var property in properties.GetProperties(ref container)) { ((IPropertyAccept <TContainer>)property).Accept(this, ref container); } }
void IPropertyBagVisitor.Visit <TContainer>(IPropertyBag <TContainer> properties, ref TContainer container) { m_SerializedReferences?.AddDeserializedReference(container); if (properties is IPropertyList <TContainer> collection) { // no boxing foreach (var property in collection.GetProperties(ref container)) { ((IPropertyAccept <TContainer>)property).Accept(this, ref container); } } else { // boxing foreach (var property in properties.GetProperties(ref container)) { ((IPropertyAccept <TContainer>)property).Accept(this, ref container); } } }