Unlimited.Framework.Converters.Graph.String.Json.JsonPath.CreatePathSegment C# (CSharp) Method

CreatePathSegment() public method

public CreatePathSegment ( JProperty jProperty ) : IPathSegment
jProperty Newtonsoft.Json.Linq.JProperty
return IPathSegment
        public IPathSegment CreatePathSegment(JProperty jProperty)
        {
            return new JsonPathSegment(jProperty.Name, jProperty.IsEnumerable());
        }

Same methods

JsonPath::CreatePathSegment ( string pathSegmentString ) : IPathSegment

Usage Example

Esempio n. 1
0
        IPath BuildPath(Stack <Tuple <JProperty, bool> > propertyStack, JProperty jProperty, JToken root)
        {
            var path = new JsonPath();

            path.ActualPath = string.Join(JsonPath.SeperatorSymbol,
                                          propertyStack.Reverse().Select(p => path.CreatePathSegment(p.Item1).ToString(p.Item2)));

            var displayPathSegments =
                propertyStack.Reverse()
                .Select(p => new Tuple <IPathSegment, bool>(path.CreatePathSegment(p.Item1), p.Item2))
                .ToList();
            var recordsetEncountered = false;

            for (int i = displayPathSegments.Count - 1; i >= 0; i--)
            {
                var pathSegment = displayPathSegments[i];
                if (recordsetEncountered)
                {
                    pathSegment.Item1.IsEnumarable = false;
                }

                if (pathSegment.Item1.IsEnumarable && pathSegment.Item2)
                {
                    recordsetEncountered = true;
                }
            }

            path.DisplayPath = string.Join(JsonPath.SeperatorSymbol,
                                           displayPathSegments.Select(p => p.Item1.ToString(p.Item2)));

            if (path.ActualPath != string.Empty)
            {
                path.ActualPath += JsonPath.SeperatorSymbol;
            }

            if (path.DisplayPath != string.Empty)
            {
                path.DisplayPath += JsonPath.SeperatorSymbol;
            }

            path.ActualPath  += path.CreatePathSegment(jProperty);
            path.DisplayPath += path.CreatePathSegment(jProperty);
            path.SampleData  += GetSampleData(root, path);

            return(path);
        }
All Usage Examples Of Unlimited.Framework.Converters.Graph.String.Json.JsonPath::CreatePathSegment