public void Can_Get_Used_Properties_From_Expression_With_Nested_Property_Access() { Expression <Func <Garage, bool> > exp = x => x.Car.Make == "Ford" && x.Color == "Green"; var properties = PropertiesVisitor.GetUsedProperties <Garage>(exp).ToList(); Assert.IsTrue(properties.Contains("Car.Make") && properties.Contains("Color")); }
private static void VisitProperties(Thing thing, IEnumerable <IInterceptorFactory> factories) { var intercepts = factories .Select(x => x.CreatePropertyIntercept()) .ToArray(); PropertiesVisitor.Visit(intercepts, thing); }
private static IDictionary <string, string> Parse(Stream stream) { var yaml = new YamlStream(); yaml.Load(new StreamReader(stream, encoding: Encoding.UTF8)); if (yaml.Documents.Any()) { var document = yaml.Documents.First(); var visitor = new PropertiesVisitor(); visitor.Visit(document); return(visitor.Properties); } return(new Dictionary <string, string>()); }
internal PropertiesNotMapped GetPropertiesNotMapped() { // 克隆属性信息 var sourceProperties = SourceType.GetProperties().ToList(); var targetProperties = TargetType.GetProperties().ToList(); var visitor = new PropertiesVisitor(TargetType); foreach (var members in memberForNew) { var members1 = members; sourceProperties.RemoveAll((p) => members1.Member.Name == p.Name); targetProperties.RemoveAll((p) => visitor.GetProperties(members.Expression).Contains(p)); } // 检查被忽略映射的成员 sourceProperties.RemoveAll((p) => _propertiesToIgnore.Contains(p)); return new PropertiesNotMapped { sourceProperties = sourceProperties, targetProperties = targetProperties }; }
internal PropertiesNotMapped GetPropertiesNotMapped() { PropertiesNotMapped result = new PropertiesNotMapped(); // Clone PropertyInfo. List <PropertyInfo> sourceProperties = SourceType.GetProperties().ToList(); List <PropertyInfo> targetProperties = TargetType.GetProperties().ToList(); PropertiesVisitor visitor = new PropertiesVisitor(TargetType); for (int i = 0; i < memberForNew.Count; i++) { var members = memberForNew[i]; // Simple remove. sourceProperties.RemoveAll((p) => members.Member.Name == p.Name); targetProperties.RemoveAll((p) => visitor.GetProperties(members.Expression).Contains(p)); } // Check the ignored properties. sourceProperties.RemoveAll((p) => propertiesToIgnore.Contains(p)); result.sourceProperties = sourceProperties; result.targetProperties = targetProperties; return(result); }
internal PropertiesNotMapped GetPropertiesNotMapped() { PropertiesNotMapped result = new PropertiesNotMapped(); // 克隆属性信息 List <PropertyInfo> sourceProperties = SourceType.GetProperties().ToList(); List <PropertyInfo> targetProperties = TargetType.GetProperties().ToList(); PropertiesVisitor visitor = new PropertiesVisitor(TargetType); foreach (var members in memberForNew) { var members1 = members; sourceProperties.RemoveAll((p) => members1.Member.Name == p.Name); targetProperties.RemoveAll((p) => visitor.GetProperties(members.Expression).Contains(p)); } // 检查被忽略映射的成员 sourceProperties.RemoveAll((p) => _propertiesToIgnore.Contains(p)); result.sourceProperties = sourceProperties; result.targetProperties = targetProperties; return(result); }