示例#1
0
        public IValueContainer Decompose(object value)
        {
#warning Add support for multi-projection. Need to know the variable/result type - a bigger serializer problem :( Also possibly need to know if it's a cross-domain derialization to keep the entity instance.
            var projectionInterface = value.GetType().GetInterfaces()
                                      .First(i => KnownEntityProjectionInterfaces != null
                    ? KnownEntityProjectionInterfaces.Contains(i)
                    : EntityProjection.IsProjectionInterface(i));

            var container = new EntityProjectionContainer
            {
                Type       = _typeNameShortener.TryShorten(projectionInterface, out string shortName) ? shortName : projectionInterface.ToString(),
                Properties = new Dictionary <string, object>()
            };

#warning Add properties of base interface(s)
            foreach (var property in projectionInterface.GetProperties())
            {
                container.Properties.Add(property.Name, property.GetValue(value));
            }

            return(container);
        }