public void OnValueStart(ValueInfo info) { _scope = new ScopeState { ParentScope = _scope, Container = _scope == null ? _targetRootContainer : null }; _scope.ValueInfo = info; if (info.Type != null) { _scope.Type = ResolveType(info.Type); if (_scope.Container == null) { _scope.Composer = _composerSelector.SelectComposer(_scope.Type); if (_scope.Composer == null) { throw new UnserializableTypeException(_scope.Type); } _scope.Container = _scope.Composer.CreatePropertySet(_scope.Type); } } if (info.IsCollection) { _scope.ItemType = info.ItemType != null ? ResolveType(info.ItemType) : typeof(object); _scope.Array = (IList)Activator.CreateInstance(typeof(List <>).MakeGenericType(_scope.ItemType)); _scope.Value = _scope.Array; _scope.ValueReceived = true; } }
public static IObjectComposer SelectComposerOrPoco(this IObjectComposerSelector selector, Type type) { var decomposer = selector.SelectComposer(type); if (decomposer == null && type.IsPoco()) { decomposer = PocoSerializer.Instance; } return(decomposer); }