Ejemplo n.º 1
0
        public void Path_values_are_considered_equal_if_both_path_and_value_are_equal()
        {
            var x = new PathValue("path", "value");
            var y = new PathValue("path", "value");

            Assert.That(x, Is.EqualTo(y));
        }
Ejemplo n.º 2
0
    public override Value Clone()
    {
        PathValue pv = CreateInstance <PathValue>();

        pv.path = path;
        return(pv);
    }
Ejemplo n.º 3
0
        public void Path_values_are_considered_inequal_if_values_are_different()
        {
            var x = new PathValue("path", "value1");
            var y = new PathValue("path", "value2");

            Assert.That(x, Is.Not.EqualTo(y));
        }
Ejemplo n.º 4
0
        public void Execute(IEnumerable <string> paramList)
        {
            if (paramList.Count() != 3)
            {
                throw new ArgumentException();
            }

            var parameters = paramList.Skip(1).ToList();

            var pathValue = new PathValue
            {
                Name = parameters[0],
                Path = parameters[1]
            };

            try
            {
                _service.AddPathValue(pathValue);
                var pathLedgerService = new PathLedgerService();
                pathLedgerService.AddEntry(pathValue);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 5
0
        public void Hashcodes_are_the_same_where_paths_are_the_same()
        {
            var x = new PathValue("path", "value1").GetHashCode();
            var y = new PathValue("path", "value2").GetHashCode();

            Assert.That(x, Is.EqualTo(y));
        }
Ejemplo n.º 6
0
 protected override void InnerReplaceValues(Dictionary <Value, Value> originalReplace)
 {
     if (originalReplace.TryGetValue(path, out Value replacePath))
     {
         path = replacePath as PathValue;
     }
 }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            RegistryKey Key = Registry.CurrentUser.OpenSubKey("Environment", true);

            if (args.Length < 1)
            {
                Console.WriteLine("Error: Invalid # of arguments");
                Console.WriteLine("Usage: pathadd <path>");
                Environment.Exit(0);
            }

            string Path = Key.GetValue("Path") as string;

            string[] PathValues = Path.Split(';');
            string   NewPath    = string.Empty;

            foreach (string PathValue in PathValues)
            {
                if (PathValue.ToLower() != args[0].ToLower())
                {
                    NewPath += $"{PathValue};";
                }
            }

            Key.SetValue("Path", NewPath.TrimEnd(';'));
            BroadcastWininiChangeMessage();
        }
Ejemplo n.º 8
0
        public ApiResult UploadPhoto()
        {
            UserModel userModel = Auth.GetLoginUser(_httpContext);
            string    oldPath   = userModel.HeadPhoto;

            if (!string.IsNullOrEmpty(oldPath))
            {
                UploadHelper.DeleteFile(oldPath);
            }
            var       file      = Request.Form.Files[0];
            PathValue pathValue = UploadHelper.SaveFile(file.FileName);

            UploadHelper.CompressImage(pathValue.FilePath, file.OpenReadStream(), 168, 168, true);
            pathValue           = UploadHelper.Upload(pathValue.FilePath, file.FileName).GetAwaiter().GetResult();
            userModel.HeadPhoto = pathValue.FilePath;
            _userService.Update(userModel);
            IList <Claim> claims = new List <Claim>()
            {
                new Claim("account", userModel.Account),
                new Claim("username", userModel.Username),
                new Claim("sex", userModel.Sex),
                new Claim("birthDate", string.IsNullOrEmpty(userModel.BirthDate)?"":userModel.BirthDate),
                new Claim("email", string.IsNullOrEmpty(userModel.Email)?"":userModel.Email),
                new Claim("sign", string.IsNullOrEmpty(userModel.Sign)?"":userModel.Sign),
                new Claim("phone", userModel.Phone),
                new Claim("headPhoto", userModel.HeadPhoto)
            };
            string jwtToken = new JWT(_cacheClient).CreateToken(claims);

            return(ApiResult.Success(new { Path = pathValue.FilePath, token = jwtToken }));
        }
Ejemplo n.º 9
0
 public override Path MapPath(PathValue value)
 {
     if (value is PathWrappingPathValue)
     {
         return((( PathWrappingPathValue )value).Path());
     }
     return(new CoreAPIPath(this, value));
 }
        public static SearchFilter ToConditionBasedSearchFilterOriginal(this object request, string pathToConditions = null)
        {
            List <PathValue> pathValues = GetPropertyPathValuesOriginal(request, pathToConditions ?? string.Empty, ".");

            if (!string.IsNullOrEmpty(pathToConditions))
            {
                pathToConditions += ".";
            }

            SearchFilter search = null;

            List <SpanDefinition> spans = GetSpans(request);

            if (spans != null)
            {
                foreach (SpanDefinition span in spans)
                {
                    switch (span.Type)
                    {
                    case SpanType.Intersection:
                        string    fromPath = $"{pathToConditions}{span.From}";
                        PathValue from     = pathValues.FirstOrDefault(p => p.Path == fromPath);
                        string    toPath   = $"{pathToConditions}{span.To}";
                        PathValue to       = pathValues.FirstOrDefault(p => p.Path == toPath);

                        if (from == null || to == null)
                        {
                            continue;
                        }

                        pathValues.Remove(from);
                        pathValues.Remove(to);

                        search &= BuildIntersectionFilter(from, to);
                        break;

                    case SpanType.Between:
                        string path  = $"{pathToConditions}{span.Property}";
                        object value = pathValues.FirstOrDefault(p => p.Path == path)?.Value;

                        if (value == null)
                        {
                            continue;
                        }

                        search &= BuildBetweenFilter($"{path}/{span.From}", $"{path}/{span.To}", value);
                        break;

                    default:
                        throw ExceptionFactory.CreateException("Span type must be specified.", HttpStatusCode.BadRequest);
                    }
                }
            }

            search = pathValues.Aggregate(search, (current, pv) => current & BuildSimpleFilter(pv));

            return(search);
        }
 private void AddPath(PathValue value)
 {
     if (value.value != null && !value.value.GetType().IsPrimitive&& !(value.value is string))
     {
         Array.Resize(ref _path, _path.Length + 1);
         _path[_path.Length - 1] = Inspect(value.name, value.value, _privateMembers);
         _sortBy = SortBy.NAME_UP;
     }
 }
Ejemplo n.º 12
0
        public override void Execute(SafeSharedObjects shared)
        {
            AssertArgBottomAndConsume(shared);

            int    currentOpcode = shared.Cpu.GetCallTrace()[0];
            Opcode opcode        = shared.Cpu.GetOpcodeAt(currentOpcode);

            ReturnValue = new PathValue(opcode.SourcePath, shared);
        }
Ejemplo n.º 13
0
 protected override void InnerReplaceValues(Dictionary <Value, Value> originalReplace)
 {
     if (originalReplace.TryGetValue(target, out Value replaceTarget))
     {
         target = replaceTarget as HealthValue;
     }
     if (originalReplace.TryGetValue(outPath, out Value replacePath))
     {
         outPath = replacePath as PathValue;
     }
 }
        private static SearchFilter BuildSimpleFilter(PathValue pathValue)
        {
            string typeString         = GetTypeString(pathValue.Value);
            string operationPath      = $"{pathValue.Path}.operator";
            string typedPath          = $"{pathValue.Path}.value.{typeString}";
            string operationArrayPath = $"{pathValue.Path}.values.operator";
            string typedArrayPath     = $"{pathValue.Path}.values.value.{typeString}";

            var nullSearch = new SearchFilter(pathValue.Path, SearchFilterOperation.EqualTo, null);

            if (pathValue.Value == null)
            {
                return(nullSearch);
            }

            if (typeString == "bool" || typeString == "object")
            {
                SearchFilter BuildFilter(string opPath, string typePath)
                {
                    return(new SearchFilter(opPath, "Equal") &
                           new SearchFilter(typePath, SearchFilterOperation.EqualTo, pathValue.Value));
                }

                return(nullSearch |
                       BuildFilter(operationPath, typedPath) |
                       BuildFilter(operationArrayPath, typedArrayPath));
            }
            else
            {
                SearchFilter BuildFilter(string opPath, string typePath)
                {
                    return((new SearchFilter(opPath, "GreaterThanEqual") &
                            new SearchFilter(typePath, SearchFilterOperation.LessThanOrEqualTo, pathValue.Value)) |
                           (new SearchFilter(opPath, "GreaterThan") &
                            new SearchFilter(typePath, SearchFilterOperation.LessThan, pathValue.Value)) |
                           (new SearchFilter(opPath, "Equal") &
                            new SearchFilter(typePath, SearchFilterOperation.EqualTo, pathValue.Value)) |
                           (new SearchFilter(opPath, "LessThan") &
                            new SearchFilter(typePath, SearchFilterOperation.GreaterThan, pathValue.Value)) |
                           (new SearchFilter(opPath, "LessThanEqual") &
                            new SearchFilter(typePath, SearchFilterOperation.GreaterThanOrEqualTo, pathValue.Value)));
                }

                return(nullSearch |
                       BuildFilter(operationPath, typedPath) |
                       BuildFilter(operationArrayPath, typedArrayPath));
            }
        }
Ejemplo n.º 15
0
        public void AddPathEntryCommand(CommandLineApplication app)
        {
            app.Command("add", (cmd) =>
            {
                cmd.HelpOption("-?|-h|--help");

                var name = cmd.Argument(
                    "name",
                    "The name of the Path Entry",
                    false
                    );

                var path = cmd.Argument(
                    "path",
                    "the path to the directory",
                    false
                    );

                cmd.Description = "Add a new entry to the System Environment Variable Path";
                cmd.OnExecute(() =>
                {
                    if (name.Value == null || path.Value == null)
                    {
                        Console.WriteLine("a name and path must be supplied!");
                        cmd.ShowHelp();
                        return(1);
                    }

                    var patherService = new PatherService();
                    var pathValue     = new PathValue
                    {
                        Name = name.Value,
                        Path = path.Value
                    };

                    patherService.AddPathValue(pathValue);
                    Console.WriteLine($"Saving Name: {name.Value} path:{path.Value}");
                    return(0);
                });
            });
        }
Ejemplo n.º 16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHandlePaths()
        public virtual void ShouldHandlePaths()
        {
            // Given
            NodeValue n1 = nodeValue(42L, stringArray("L"), EMPTY_MAP);
            NodeValue n2 = nodeValue(43L, stringArray("L"), EMPTY_MAP);
            PathValue p  = path(new NodeValue[] { n1, n2 }, new RelationshipValue[] { relationshipValue(1L, n1, n2, stringValue("T"), EMPTY_MAP) });

            // When
            p.WriteTo(_converter);

            // Then
            object value = _converter.value();

            assertThat(value, instanceOf(typeof(Path)));
            Path path = ( Path )value;

            assertThat(path.Length(), equalTo(1));
            assertThat(path.StartNode().Id, equalTo(42L));
            assertThat(path.EndNode().Id, equalTo(43L));
            assertThat(path.Relationships().GetEnumerator().next().Id, equalTo(1L));
        }
Ejemplo n.º 17
0
        public override void Execute(SharedObjects shared)
        {
            int remaining = CountRemainingArgs(shared);

            GlobalPath path;

            if (remaining == 0)
            {
                path = GlobalPath.FromVolumePath(shared.VolumeMgr.CurrentDirectory.Path,
                                                 shared.VolumeMgr.GetVolumeRawIdentifier(shared.VolumeMgr.CurrentVolume));
            }
            else
            {
                object pathObject = PopValueAssert(shared, true);
                path = shared.VolumeMgr.GlobalPathFromObject(pathObject);
            }

            AssertArgBottomAndConsume(shared);

            ReturnValue = new PathValue(path, shared);
        }
Ejemplo n.º 18
0
        public void path_value_id_is_less_than()
        {
            GameObject gameObject = new GameObject();
            IHexagon   hex1       = Substitute.For <IHexagon>();
            Vector3Int coords1    = new Vector3Int(0, -1, -1);

            hex1.MyHexMap.CoOrds.Returns(coords1);
            hex1.HexTransform.Returns(gameObject.transform);

            IHexagon   hex2    = Substitute.For <IHexagon>();
            Vector3Int coords2 = new Vector3Int(1, 0, -1);

            hex2.MyHexMap.CoOrds.Returns(coords2);
            hex2.HexTransform.Returns(gameObject.transform);

            Vector3   centre = new Vector3(0, 0, 0);
            PathValue path1  = new PathValue(4, 4, centre, hex1, null);
            PathValue path2  = new PathValue(4, 4, centre, hex2, null);


            Assert.AreEqual(path1.CompareTo(path2), -1);
        }
Ejemplo n.º 19
0
        public void Path_values_to_string_gives_nice_output()
        {
            var x = new PathValue("path", "value");

            Assert.That(x.ToString(), Is.EqualTo("\"path\" : \"value\""));
        }
Ejemplo n.º 20
0
 /// <summary>
 /// Checks if a path has the same steps as this path.
 /// </summary>
 /// <param name="otherPath">The other path.</param>
 /// <returns>Wheter it is the same or not.</returns>
 public bool IsSame(PathValue otherPath) => IsSame(otherPath.Get());
Ejemplo n.º 21
0
 protected bool Equals(PathValue other)
 {
     return Equals(Path, other.Path) && Equals(Value, other.Value);
 }
Ejemplo n.º 22
0
 public override ListValue MapPath(PathValue value)
 {
     return(null);
 }
Ejemplo n.º 23
0
 public override object MapPath(PathValue value)
 {
     return(new MappedGraphType(value));
 }
        private static SearchFilter BuildIntersectionFilter(PathValue from, PathValue to)
        {
            string fromTypeString    = GetTypeString(from.Value);
            string fromOperationPath = $"{from.Path}.operator";
            string fromTypedPath     = $"{from.Path}.value.{fromTypeString}";
            string toTypeString      = GetTypeString(to.Value);
            string toOperationPath   = $"{to.Path}.operator";
            string toTypedPath       = $"{to.Path}.value.{toTypeString}";

            SearchFilter fromFilter, toFilter, spanFilter;

            if (to.Value == null)
            {
                if (from.Value == null)
                {
                    return(null); // if span from/to are both null, get all items.
                }

                fromFilter = (new SearchFilter(fromOperationPath, "GreaterThanEqual") &
                              new SearchFilter(fromTypedPath, SearchFilterOperation.LessThanOrEqualTo, from.Value) &
                              new SearchFilter(toTypedPath, SearchFilterOperation.EqualTo, from.Value)) |
                             (new SearchFilter(fromOperationPath, "GreaterThan") &
                              new SearchFilter(fromTypedPath, SearchFilterOperation.LessThan, from.Value) &
                              new SearchFilter(toTypedPath, SearchFilterOperation.EqualTo, from.Value)) |
                             (new SearchFilter(fromOperationPath, "Equal") &
                              new SearchFilter(fromTypedPath, SearchFilterOperation.EqualTo, from.Value)) |
                             (new SearchFilter(fromOperationPath, "LessThan") &
                              new SearchFilter(fromTypedPath, SearchFilterOperation.GreaterThan, from.Value)) |
                             (new SearchFilter(fromOperationPath, "LessThanEqual") &
                              new SearchFilter(fromTypedPath, SearchFilterOperation.GreaterThanOrEqualTo, from.Value));

                toFilter = new SearchFilter(to.Path, SearchFilterOperation.EqualTo, null) &
                           new SearchFilter(fromTypedPath, SearchFilterOperation.LessThanOrEqualTo, from.Value);

                spanFilter = new SearchFilter(fromTypedPath, SearchFilterOperation.GreaterThanOrEqualTo, from.Value) &
                             new SearchFilter(to.Path, SearchFilterOperation.EqualTo, null);
            }
            else if (from.Value == null)
            {
                fromFilter = new SearchFilter(from.Path, SearchFilterOperation.EqualTo, null) &
                             new SearchFilter(toTypedPath, SearchFilterOperation.GreaterThanOrEqualTo, to.Value);

                toFilter = (new SearchFilter(toOperationPath, "GreaterThanEqual") &
                            new SearchFilter(toTypedPath, SearchFilterOperation.LessThanOrEqualTo, to.Value)) |
                           (new SearchFilter(toOperationPath, "GreaterThan") &
                            new SearchFilter(toTypedPath, SearchFilterOperation.LessThan, to.Value)) |
                           (new SearchFilter(toOperationPath, "Equal") &
                            new SearchFilter(toTypedPath, SearchFilterOperation.EqualTo, to.Value)) |
                           (new SearchFilter(toOperationPath, "LessThan") &
                            new SearchFilter(toTypedPath, SearchFilterOperation.GreaterThan, to.Value) &
                            new SearchFilter(fromTypedPath, SearchFilterOperation.EqualTo, to.Value)) |
                           (new SearchFilter(toOperationPath, "LessThanEqual") &
                            new SearchFilter(toTypedPath, SearchFilterOperation.GreaterThanOrEqualTo, to.Value) &
                            new SearchFilter(fromTypedPath, SearchFilterOperation.EqualTo, to.Value));

                spanFilter = new SearchFilter(from.Path, SearchFilterOperation.EqualTo, null) &
                             new SearchFilter(toTypedPath, SearchFilterOperation.LessThanOrEqualTo, to.Value);
            }
            else
            {
                fromFilter = (new SearchFilter(fromOperationPath, "GreaterThanEqual") &
                              new SearchFilter(fromTypedPath, SearchFilterOperation.LessThanOrEqualTo, from.Value) &
                              new SearchFilter(toTypedPath, SearchFilterOperation.GreaterThanOrEqualTo, from.Value)) |
                             (new SearchFilter(fromOperationPath, "GreaterThan") &
                              new SearchFilter(fromTypedPath, SearchFilterOperation.LessThan, from.Value) &
                              new SearchFilter(toTypedPath, SearchFilterOperation.GreaterThanOrEqualTo, from.Value)) |
                             (new SearchFilter(fromOperationPath, "Equal") &
                              new SearchFilter(fromTypedPath, SearchFilterOperation.EqualTo, from.Value)) |
                             (new SearchFilter(fromOperationPath, "LessThan") &
                              new SearchFilter(fromTypedPath, SearchFilterOperation.GreaterThan, from.Value)) |
                             (new SearchFilter(fromOperationPath, "LessThanEqual") &
                              new SearchFilter(fromTypedPath, SearchFilterOperation.GreaterThanOrEqualTo, from.Value));

                toFilter = (new SearchFilter(toOperationPath, "GreaterThanEqual") &
                            new SearchFilter(toTypedPath, SearchFilterOperation.LessThanOrEqualTo, to.Value)) |
                           (new SearchFilter(toOperationPath, "GreaterThan") &
                            new SearchFilter(toTypedPath, SearchFilterOperation.LessThan, to.Value)) |
                           (new SearchFilter(toOperationPath, "Equal") &
                            new SearchFilter(toTypedPath, SearchFilterOperation.EqualTo, to.Value)) |
                           (new SearchFilter(toOperationPath, "LessThan") &
                            new SearchFilter(toTypedPath, SearchFilterOperation.GreaterThan, to.Value) &
                            new SearchFilter(fromTypedPath, SearchFilterOperation.LessThanOrEqualTo, to.Value)) |
                           (new SearchFilter(toOperationPath, "LessThanEqual") &
                            new SearchFilter(toTypedPath, SearchFilterOperation.GreaterThanOrEqualTo, to.Value) &
                            new SearchFilter(fromTypedPath, SearchFilterOperation.LessThanOrEqualTo, to.Value));

                spanFilter = new SearchFilter(fromTypedPath, SearchFilterOperation.GreaterThanOrEqualTo, from.Value) &
                             new SearchFilter(toTypedPath, SearchFilterOperation.LessThanOrEqualTo, to.Value);
            }

            return(fromFilter | toFilter | spanFilter);
        }
Ejemplo n.º 25
0
 public static RouteHandlerResult Complete(PathValue value) => Complete(new List <PathValue> {
     value
 });
Ejemplo n.º 26
0
 public static RouteHandlerResult Complete(PathValue value) => Complete(new List<PathValue> {value});
Ejemplo n.º 27
0
 // Helper to extract list of nodes from a path
 public static IList <NodeValue> Nodes(PathValue path)
 {
     return(Arrays.asList(path.Nodes()));
 }
Ejemplo n.º 28
0
 public void Path_values_store_path()
 {
     var x = new PathValue("this path", "");
     Assert.That(x.Path, Is.EqualTo("this path"));
 }
Ejemplo n.º 29
0
 public void Path_values_store_value()
 {
     var x = new PathValue("", "a value");
     Assert.That(x.Value, Is.EqualTo("a value"));
 }
            // Paths do not require any conversion at this point

            public override AnyValue MapPath(PathValue value)
            {
                return(value);
            }
        private static PathValue Inspect(string targetName, object target, bool privateMembers)
        {
            targetName = ObjectToString(targetName);

            if (target != null)
            {
                var type = target as Type ?? target.GetType();

                if (type.IsPrimitive || target is String)
                {
                    return(new PathValue {
                        name = targetName, value = target, message = ObjectToString(target)
                    });
                }
                if (target is Array)
                {
                    var array = target as Array;
                    var path  = new PathValue[array.Length];

                    if (array.Rank == 1)
                    {
                        for (int i = 0; i < array.Length; i++)
                        {
                            var message = ObjectToString(array, i);
                            path[i] = new PathValue
                            {
                                index   = i,
                                name    = i.ToString(),
                                message = message,
                                value   = array.GetValue(i)
                            };
                        }
                    }
                    else if (array.Rank == 2)
                    {
                        for (int i = 0; i < array.GetLength(0); i++)
                        {
                            for (int j = 0; j < array.GetLength(1); j++)
                            {
                                var message = ObjectToString(array, i, j);
                                var index   = i * array.GetLength(0) + j;
                                path[index] = new PathValue
                                {
                                    index   = index,
                                    name    = string.Concat(i, ",", j),
                                    message = message,
                                    value   = array.GetValue(i, j)
                                };
                            }
                        }
                    }

                    return(new PathValue {
                        name = targetName, value = path, message = Convert.ToString(target)
                    });
                }
                if (target is IDictionary)
                {
                    var dict    = target as IDictionary;
                    var path    = new PathValue[dict.Count];
                    var index   = 0;
                    var keys    = dict.Keys;
                    var keyList = new List <object>(keys.Count);
                    foreach (var key in keys)
                    {
                        keyList.Add(key);
                    }
                    keyList.Sort(new KeyComparer <object>());
                    foreach (var key in keyList)
                    {
                        var value = dict[key];
                        path[index] = new PathValue
                        {
                            index   = index,
                            name    = ObjectToString(key),
                            message = ObjectToString(value),
                            value   = value
                        };
                        index++;
                    }
                    return(new PathValue {
                        name = targetName, value = path, message = Convert.ToString(target)
                    });
                }
                if (target is ICollection)
                {
                    var array = target as ICollection;
                    var path  = new PathValue[array.Count];
                    var index = 0;
                    foreach (var e in array)
                    {
                        path[index] = new PathValue
                        {
                            index   = index,
                            name    = index.ToString(),
                            message = ObjectToString(e),
                            value   = e
                        };
                        index++;
                    }
                    return(new PathValue {
                        name = targetName, value = path, message = Convert.ToString(target)
                    });
                }
                if (target is IEnumerator)
                {
                    var enumerator = target as IEnumerator;
                    var path       = new List <PathValue>();
                    var index      = 0;
                    while (enumerator.MoveNext())
                    {
                        var e = enumerator.Current;
                        path.Add(new PathValue
                        {
                            index   = index,
                            name    = index.ToString(),
                            message = ObjectToString(e),
                            value   = e
                        });
                        index++;
                    }
                    return(new PathValue {
                        name = targetName, value = path, message = Convert.ToString(target)
                    });
                }
                else
                {
                    FieldInfo[] fields = GetFields(type, privateMembers);
                    Array.Sort(fields, new MemberComparer <FieldInfo>());

                    BindingFlags propertyFlagsflags = BindingFlags.Instance | BindingFlags.Public |
                                                      BindingFlags.GetProperty | BindingFlags.SetProperty | BindingFlags.InvokeMethod;
                    if (privateMembers)
                    {
                        propertyFlagsflags |= BindingFlags.NonPublic;
                    }

                    PropertyInfo[] property = type.GetProperties(propertyFlagsflags);
                    Array.Sort(property, new MemberComparer <PropertyInfo>());

                    MethodInfo[] methods = type.GetMethods(propertyFlagsflags).Where(m => m.GetGenericArguments().Length == 0 && m.GetParameters().Length == 0 && m.ReturnType != typeof(void)).ToArray();
                    Array.Sort(methods, new MemberComparer <MethodInfo>());

                    var enumerable = target as IEnumerable;
                    var component  = target as Component;
                    var gameObject = target as GameObject;
                    var additional = 0;
                    if (enumerable != null)
                    {
                        additional++;
                    }
                    if (component != null)
                    {
                        additional += 2;
                    }
                    if (gameObject != null)
                    {
                        additional += 2;
                    }
                    var path  = new PathValue[fields.Length + property.Length + additional + methods.Length];
                    var index = 0;
                    foreach (var fieldInfo in fields)
                    {
                        object value;
                        try
                        {
                            value = fieldInfo.GetValue(target);
                        }
                        catch (Exception e)
                        {
                            value = string.Format("{0}: {1}", e.GetType().Name, e.Message);
                        }
                        path[index] = new PathValue
                        {
                            index   = index,
                            name    = ObjectToString(fieldInfo.Name),
                            message = ObjectToString(value),
                            value   = value
                        };
                        index++;
                    }
                    foreach (var propertyInfo in property)
                    {
                        object value;
                        try
                        {
                            value = propertyInfo.GetValue(target, null);
                        }
                        catch (Exception e)
                        {
                            value = string.Format("{0}: {1}", e.GetType().Name, e.Message);
                        }
                        path[index] = new PathValue
                        {
                            index   = index,
                            name    = ObjectToString(propertyInfo.Name),
                            message = ObjectToString(value),
                            value   = value
                        };
                        index++;
                    }
                    foreach (var methodInfo in methods)
                    {
                        object value;
                        try
                        {
                            value = methodInfo.Invoke(target, null);
                        }
                        catch (Exception e)
                        {
                            value = string.Format("{0}: {1}", e.GetType().Name, e.Message);
                        }
                        path[index] = new PathValue
                        {
                            index   = index,
                            name    = ObjectToString(methodInfo.Name) + "():" + methodInfo.ReturnType,
                            message = ObjectToString(value),
                            value   = value
                        };
                        index++;
                    }
                    if (enumerable != null)
                    {
                        object value;
                        try
                        {
                            value = enumerable.GetEnumerator();
                        }
                        catch (Exception e)
                        {
                            value = string.Format("{0}: {1}", e.GetType().Name, e.Message);
                        }
                        path[index] = new PathValue
                        {
                            index   = index,
                            name    = ObjectToString("GetEnumerator()"),
                            message = ObjectToString(value),
                            value   = value
                        };
                        index++;
                    }

                    if (component != null)
                    {
                        object value;
                        try
                        {
                            value = component.GetComponents(typeof(Component));
                        }
                        catch (Exception e)
                        {
                            value = string.Format("{0}: {1}", e.GetType().Name, e.Message);
                        }
                        path[index] = new PathValue
                        {
                            index   = index,
                            name    = ObjectToString("GetComponents()"),
                            message = ObjectToString(value),
                            value   = value
                        };
                        index++;

                        try
                        {
                            value = component.GetComponentsInChildren(typeof(Component));
                        }
                        catch (Exception e)
                        {
                            value = string.Format("{0}: {1}", e.GetType().Name, e.Message);
                        }
                        path[index] = new PathValue
                        {
                            index   = index,
                            name    = ObjectToString("GetComponentsInChildren()"),
                            message = ObjectToString(value),
                            value   = value
                        };
                        index++;
                    }

                    if (gameObject != null)
                    {
                        object value;
                        try
                        {
                            value = gameObject.GetComponents(typeof(Component));
                        }
                        catch (Exception e)
                        {
                            value = string.Format("{0}: {1}", e.GetType().Name, e.Message);
                        }
                        path[index] = new PathValue
                        {
                            index   = index,
                            name    = ObjectToString("GetComponents()"),
                            message = ObjectToString(value),
                            value   = value
                        };
                        index++;

                        try
                        {
                            value = gameObject.GetComponentsInChildren(typeof(Component));
                        }
                        catch (Exception e)
                        {
                            value = string.Format("{0}: {1}", e.GetType().Name, e.Message);
                        }
                        path[index] = new PathValue
                        {
                            index   = index,
                            name    = ObjectToString("GetComponentsInChildren()"),
                            message = ObjectToString(value),
                            value   = value
                        };
                        index++;
                    }

                    return(new PathValue {
                        name = targetName, value = path, message = ObjectToString(target)
                    });
                }
            }
            return(new PathValue());
        }
Ejemplo n.º 32
0
 public override object mapPath(PathValue value)
 {
     throw new EvaluationRuntimeException("Unable to evaluate paths");
 }
Ejemplo n.º 33
0
 internal CoreAPIPath(DefaultValueMapper outerInstance, PathValue value)
 {
     this._outerInstance = outerInstance;
     this.Value          = value;
 }
Ejemplo n.º 34
0
 protected bool Equals(PathValue other)
 {
     return(Equals(Path, other.Path) && Equals(Value, other.Value));
 }