示例#1
0
        private static void Deconstruct(ILogger <IValidatable> logger, ITypeInfo type, string name, List <string> deconstructionProperties, ref List <IMemberInfo> result)
        {
            var propertyPaths = deconstructionProperties;

            if (propertyPaths == null || propertyPaths.Count == 0)
            {
                if (!type.ImplementsInterface <IDeconstructible>())
                {
                    throw new Exception($"Type/Name pair with Deconstruct attribute expected type ({type.Name} {name}) to implement IDeconstructible when PropertyNames are empty.");
                }

                propertyPaths = type.Create <IDeconstructible>().Deconstruct().ToList();
            }

            foreach (var propertyPath in propertyPaths)
            {
                var deconstructedPath = new List <IMemberInfo>();
                DeconstructPath(logger, type, propertyPath, ref deconstructedPath);

                // TODO: Needs metadataprovider
                result.Add(new ProxyMemberInfo <ITypeInfo>(null, deconstructedPath.Last().Type, $"{name}{deconstructedPath.Aggregate(string.Empty, (previous, current) => previous + current.Name)}"));
            }
        }