コード例 #1
0
ファイル: ParsingException.cs プロジェクト: dlebansais/Wrist
 public ParsingException(int code, IParsingSourceStream sourceStream, Exception innerException,
                         [CallerLineNumber] int lineNumber = 0,
                         [CallerFilePath] string filePath  = null,
                         [CallerMemberName] string caller  = null)
     : base(innerException.Message, innerException)
 {
     Code          = code;
     Directory     = null;
     ParsingSource = sourceStream.FreezedPosition();
     LineNumber    = lineNumber;
     FilePath      = ShortFilePath(filePath);
     Caller        = caller;
 }
コード例 #2
0
        private void ParseComponent(IParsingSourceStream sourceStream, ref IComponentEvent queryEvent, ref IDeclarationSource areaSource, ref IParsingSource allAreaLayoutsSource, ref Dictionary <IDeclarationSource, string> areaLayoutsPairs, ref IDeclarationSource designSource, ref IDeclarationSource widthSource, ref IDeclarationSource heightSource, ref bool isScrollable, ref IDeclarationSource backgroundSource, ref IDeclarationSource backgroundColorSource, ref string tag)
        {
            string Line = sourceStream.Line;

            if (Line.Trim() == "scrollable")
            {
                isScrollable = true;
                return;
            }

            IDeclarationSource ComponentSource;
            string             ComponentValue;

            ParserDomain.ParseStringPair(sourceStream, ':', out ComponentSource, out ComponentValue);
            //ComponentValue = ComponentValue.ToLower();

            if (ComponentSource.Name == "open on query")
            {
                if (queryEvent == null)
                {
                    queryEvent = ParseQueryEvent(sourceStream, ComponentValue);
                }
                else
                {
                    throw new ParsingException(125, sourceStream, $"Specifier '{ComponentSource.Name}' found more than once.");
                }
            }
            else if (ComponentSource.Name == "area")
            {
                if (areaSource == null)
                {
                    areaSource = new DeclarationSource(ComponentValue, sourceStream);
                }
                else
                {
                    throw new ParsingException(125, sourceStream, $"Specifier '{ComponentSource.Name}' found more than once.");
                }
            }
            else if (ComponentSource.Name == "default area layout")
            {
                if (areaLayoutsPairs == null)
                {
                    allAreaLayoutsSource = sourceStream.FreezedPosition();
                    areaLayoutsPairs     = ParseAreaLayoutsPairs(sourceStream, ComponentValue);
                }
                else
                {
                    throw new ParsingException(125, sourceStream, $"Specifier '{ComponentSource.Name}' found more than once.");
                }
            }
            else if (ComponentSource.Name == "design")
            {
                if (designSource == null)
                {
                    designSource = new DeclarationSource(ComponentValue, sourceStream);
                }
                else
                {
                    throw new ParsingException(125, sourceStream, $"Specifier '{ComponentSource.Name}' found more than once.");
                }
            }
            else if (ComponentSource.Name == "width")
            {
                if (widthSource == null)
                {
                    widthSource = new DeclarationSource(ComponentValue, sourceStream);
                }
                else
                {
                    throw new ParsingException(125, sourceStream, $"Specifier '{ComponentSource.Name}' found more than once.");
                }
            }
            else if (ComponentSource.Name == "height")
            {
                if (heightSource == null)
                {
                    heightSource = new DeclarationSource(ComponentValue, sourceStream);
                }
                else
                {
                    throw new ParsingException(125, sourceStream, $"Specifier '{ComponentSource.Name}' found more than once.");
                }
            }
            else if (ComponentSource.Name == "background")
            {
                if (backgroundSource == null)
                {
                    backgroundSource = new DeclarationSource(ComponentValue, sourceStream);
                }
                else
                {
                    throw new ParsingException(125, sourceStream, $"Specifier '{ComponentSource.Name}' found more than once.");
                }
            }
            else if (ComponentSource.Name == "background color")
            {
                if (backgroundColorSource == null)
                {
                    backgroundColorSource = new DeclarationSource(ComponentValue, sourceStream);
                }
                else
                {
                    throw new ParsingException(125, sourceStream, $"Specifier '{ComponentSource.Name}' found more than once.");
                }
            }
            else if (ComponentSource.Name == "tag")
            {
                if (tag == null)
                {
                    tag = ComponentValue;
                }
                else
                {
                    throw new ParsingException(125, sourceStream, $"Specifier '{ComponentSource.Name}' found more than once.");
                }
            }
            else
            {
                throw new ParsingException(115, sourceStream, $"Specifier '{ComponentSource.Name}' was unexpected.");
            }
        }
コード例 #3
0
 public DeclarationSource(string name, IParsingSourceStream sourceStream)
 {
     Name   = name;
     Source = sourceStream?.FreezedPosition();
 }
コード例 #4
0
 public static string ToCSharpName(IParsingSourceStream sourceStream, string name)
 {
     return(ToCSharpName(sourceStream.FreezedPosition(), name));
 }
コード例 #5
0
 public static string ToXamlName(IParsingSourceStream sourceStream, string name, string suffix)
 {
     return(ToXamlName(sourceStream.FreezedPosition(), name, suffix));
 }