public IntPtr GetAddress() { if (address == IntPtr.Zero) { return(address); } using (TArrayUnsafe <FName> packageNamesUnsafe = new TArrayUnsafe <FName>()) { packageNamesUnsafe.AddRange(PackageNames.ToArray()); Native_FARFilter.Set_PackageNames(address, packageNamesUnsafe.Address); } using (TArrayUnsafe <FName> packagePathsUnsafe = new TArrayUnsafe <FName>()) { packagePathsUnsafe.AddRange(PackagePaths.ToArray()); Native_FARFilter.Set_PackagePaths(address, packagePathsUnsafe.Address); } using (TArrayUnsafe <FName> objectPathsUnsafe = new TArrayUnsafe <FName>()) { objectPathsUnsafe.AddRange(ObjectPaths.ToArray()); Native_FARFilter.Set_ObjectPaths(address, objectPathsUnsafe.Address); } using (TArrayUnsafe <FName> classNamesUnsafe = new TArrayUnsafe <FName>()) { classNamesUnsafe.AddRange(ClassNames.ToArray()); Native_FARFilter.Set_ClassNames(address, classNamesUnsafe.Address); } using (TArrayUnsafe <FName> tagsUnsafe = new TArrayUnsafe <FName>()) using (TArrayUnsafe <string> valuesUnsafe = new TArrayUnsafe <string>()) { tagsUnsafe.AddRange(TagsAndValues.Keys.ToArray()); valuesUnsafe.AddRange(TagsAndValues.Values.ToArray()); Native_FARFilter.Set_TagsAndValues(address, tagsUnsafe.Address, valuesUnsafe.Address); } using (TArrayUnsafe <FName> recursiveClassesExclusionSet = new TArrayUnsafe <FName>()) { recursiveClassesExclusionSet.AddRange(RecursiveClassesExclusionSet.ToArray()); Native_FARFilter.Set_RecursiveClassesExclusionSet(address, recursiveClassesExclusionSet.Address); } Native_FARFilter.Set_bRecursivePaths(address, RecursivePaths); Native_FARFilter.Set_bRecursiveClasses(address, RecursiveClasses); Native_FARFilter.Set_bIncludeOnlyOnDiskAssets(address, IncludeOnlyOnDiskAssets); return(address); }
protected override Expression VisitMemberAccess(MemberExpression m) { Visit(m.Expression); PropertyType = m.Type; // try to get the value try { var rootInstance = Expression.Lambda(typeof(Func <object>), m.Expression).Compile().DynamicInvoke(); if (rootInstance != null) { { var pi = m.Member as PropertyInfo; object resultingInstance = null; if (pi != null) { resultingInstance = pi.GetValue(rootInstance, null); } var fi = m.Member as FieldInfo; if (fi != null) { resultingInstance = fi.GetValue(rootInstance); } if (resultingInstance != null) { var propertyPath = ObjectPaths.Get(resultingInstance); if (propertyPath != null) { RootType = propertyPath.TypePrefix; AppendPropertyPath(propertyPath.TypeSuffix); return(m); } } } } } catch { } if (RootType == null) { RootType = ExtractType(m.Member).GetTypeString(); } else { var name = m.Member.Name; AppendPropertyPath(name); } return(m); }
public void an_instance_part_of_the_path_is_replaced_with_the_prefix_in_object_paths() { try { ObjectPaths.Add(Customer, new PropertyPath { TypePrefix = "Customer", TypeSuffix = "TheFirst" }); var pp = new PropertyPathForInstance <object>(() => Customer.FirstName); pp.Path.TypePrefix.ShouldBe("Customer"); pp.Path.TypeSuffix.ShouldBe("TheFirst.FirstName"); } finally { ObjectPaths.Remove(Customer); } }
public static IEnumerable <TResult> SelectHtml <TSource, TResult>(this IEnumerable <TSource> source, object rootInstance, PropertyPath path, Func <TSource, TResult> selector) { if (source == null) { yield break; } int index = 0; foreach (var item in source) { try { PropertyPath pathToAdd; if (rootInstance != null) { PropertyPath rootPath = ObjectPaths.Get(rootInstance); pathToAdd = new PropertyPath { TypePrefix = rootPath.TypePrefix, TypeSuffix = rootPath.TypeSuffix + "." + path.TypeSuffix + ":" + index }; } else { pathToAdd = new PropertyPath { TypePrefix = path.TypePrefix, TypeSuffix = path.TypeSuffix + ":" + index }; } ObjectPaths.Add(item, pathToAdd); yield return(selector(item)); } finally { ObjectPaths.Remove(item); index++; } } }
private MethodAction(ObjectPaths.Method method) { _method = method; }