Пример #1
0
        protected internal override ObjectParseStatus Parse(ref AccessState accessState, ref ReadOnlySpan <char> completeName, ref ReadOnlySpan <char> remainingName, out Object?foundObject)
        {
            if (remainingName.IsEmpty)
            {
                foundObject = this;
                return(ObjectParseStatus.Success);
            }

            var separatorIndex = remainingName.IndexOf(ObjectManager.DirectorySeparatorChar);
            ReadOnlySpan <char> componentName;

            if (separatorIndex != -1)
            {
                componentName = remainingName.Slice(0, separatorIndex);
                remainingName = remainingName.Slice(separatorIndex + 1);
            }
            else
            {
                componentName = remainingName;
                remainingName = ReadOnlySpan <char> .Empty;
            }

            if (TryGet(componentName, out var componentObject))
            {
                if (remainingName.IsEmpty)
                {
                    foundObject = componentObject;
                    return(ObjectParseStatus.Success);
                }
                else
                {
                    if (componentObject.CanParse)
                    {
                        return(componentObject.Parse(ref accessState, ref completeName, ref remainingName, out foundObject));
                    }
                    else
                    {
                        foundObject = null;
                        return(ObjectParseStatus.InvalidPath);
                    }
                }
            }
            else
            {
                foundObject = null;
                return(ObjectParseStatus.NotFound);
            }
        }
Пример #2
0
 protected internal virtual ObjectParseStatus Parse(ref AccessState accessState, ref ReadOnlySpan <char> completeName, ref ReadOnlySpan <char> remainingName, out Object?foundObject)
 {
     throw new NotSupportedException();
 }