private IComponentHtml ParseComponentHtml(IDeclarationSource nameSource, IParsingSourceStream sourceStream, List <ComponentInfo> infoList) { IComponentProperty HtmlProperty = null; foreach (ComponentInfo Info in infoList) { if (Info.NameSource.Name == "html" && HtmlProperty == null) { HtmlProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name != "html") { throw new ParsingException(27, sourceStream, $"Unknown token '{Info.NameSource.Name}'."); } else { throw new ParsingException(28, sourceStream, $"'{Info.NameSource.Name}' is repeated."); } } if (HtmlProperty == null) { throw new ParsingException(0, sourceStream, "Html not specified."); } return(new ComponentHtml(nameSource, ParserDomain.ToXamlName(nameSource.Source, nameSource.Name, "Html"), HtmlProperty)); }
private IComponentPasswordEdit ParseComponentPasswordEdit(IDeclarationSource nameSource, IParsingSourceStream sourceStream, List <ComponentInfo> infoList) { IComponentProperty TextProperty = null; foreach (ComponentInfo Info in infoList) { if (Info.NameSource.Name == "text" && TextProperty == null) { TextProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name != "text") { throw new ParsingException(27, sourceStream, $"Unknown token '{Info.NameSource.Name}'."); } else { throw new ParsingException(28, sourceStream, $"'{Info.NameSource.Name}' is repeated."); } } if (TextProperty == null) { throw new ParsingException(50, sourceStream, "Text not specified."); } if (TextProperty.FixedValueSource != null || TextProperty.ObjectPropertyKey != null) { throw new ParsingException(51, sourceStream, "Text must be a string property."); } return(new ComponentPasswordEdit(nameSource, ParserDomain.ToXamlName(nameSource.Source, nameSource.Name, "PasswordEdit"), TextProperty)); }
private IComponentArea ParseComponentArea(IDeclarationSource nameSource, IParsingSourceStream sourceStream, List <ComponentInfo> infoList) { IComponentProperty AreaProperty = null; foreach (ComponentInfo Info in infoList) { if (Info.NameSource.Name == "name" && AreaProperty == null) { AreaProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name != "name") { throw new ParsingException(27, sourceStream, $"Unknown token '{Info.NameSource.Name}'."); } else { throw new ParsingException(28, sourceStream, $"'{Info.NameSource.Name}' is repeated."); } } if (AreaProperty == null) { throw new ParsingException(29, sourceStream, "Area name not specified."); } if (AreaProperty.FixedValueSource == null) { throw new ParsingException(30, sourceStream, "Area can only be a static name."); } return(new ComponentArea(nameSource, ParserDomain.ToXamlName(nameSource.Source, nameSource.Name, "Area"), AreaProperty.FixedValueSource)); }
private IComponentText ParseComponentText(IDeclarationSource nameSource, IParsingSourceStream sourceStream, List <ComponentInfo> infoList) { IComponentProperty TextProperty = null; IComponentProperty TextDecorationProperty = null; foreach (ComponentInfo Info in infoList) { if (Info.NameSource.Name == "text" && TextProperty == null) { TextProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name == "decoration" && TextDecorationProperty == null) { TextDecorationProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name != "text" && Info.NameSource.Name != "decoration") { throw new ParsingException(27, sourceStream, $"Unknown token '{Info.NameSource.Name}'."); } else { throw new ParsingException(28, sourceStream, $"'{Info.NameSource.Name}' is repeated."); } } if (TextProperty == null) { throw new ParsingException(38, sourceStream, "Text not specified."); } if (TextDecorationProperty != null && TextDecorationProperty.FixedValueSource == null) { throw new ParsingException(39, sourceStream, "Decoration can only be a constant."); } string TextDecoration = TextDecorationProperty != null ? TextDecorationProperty.FixedValueSource.Name : null; if (TextDecoration != null && TextDecoration != Windows.UI.Text.TextDecorations.OverLine.ToString() && TextDecoration != Windows.UI.Text.TextDecorations.Strikethrough.ToString() && TextDecoration != Windows.UI.Text.TextDecorations.Underline.ToString()) { throw new ParsingException(40, sourceStream, $"Invalid decoration for '{nameSource.Name}'."); } return(new ComponentText(nameSource, ParserDomain.ToXamlName(nameSource.Source, nameSource.Name, "Text"), TextProperty, TextDecoration)); }
private IComponentSelector ParseComponentSelector(IDeclarationSource nameSource, IParsingSourceStream sourceStream, List <ComponentInfo> infoList) { IComponentProperty IndexProperty = null; IComponentProperty ItemsProperty = null; foreach (ComponentInfo Info in infoList) { if (Info.NameSource.Name == "index" && IndexProperty == null) { IndexProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name == "items" && ItemsProperty == null) { ItemsProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name != "index" && Info.NameSource.Name != "items") { throw new ParsingException(27, sourceStream, $"Unknown token '{Info.NameSource.Name}'."); } else { throw new ParsingException(28, sourceStream, $"'{Info.NameSource.Name}' is repeated."); } } if (IndexProperty == null) { throw new ParsingException(60, sourceStream, "Index not specified."); } if (IndexProperty.FixedValueSource != null || IndexProperty.ObjectPropertyKey != null) { throw new ParsingException(61, sourceStream, "Index must be an integer property."); } if (ItemsProperty == null) { throw new ParsingException(62, sourceStream, "Items not specified."); } if (ItemsProperty.FixedValueSource != null || ItemsProperty.ObjectPropertyKey != null) { throw new ParsingException(63, sourceStream, "Items must be a list property."); } return(new ComponentSelector(nameSource, ParserDomain.ToXamlName(nameSource.Source, nameSource.Name, "Selector"), IndexProperty, ItemsProperty)); }
private IComponentCheckBox ParseComponentCheckBox(IDeclarationSource nameSource, IParsingSourceStream sourceStream, List <ComponentInfo> infoList) { IComponentProperty ContentProperty = null; IComponentProperty CheckedProperty = null; foreach (ComponentInfo Info in infoList) { if (Info.NameSource.Name == "content" && ContentProperty == null) { ContentProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name == "checked" && CheckedProperty == null) { CheckedProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name != "content" && Info.NameSource.Name != "checked") { throw new ParsingException(27, sourceStream, $"Unknown token '{Info.NameSource.Name}'."); } else { throw new ParsingException(28, sourceStream, $"'{Info.NameSource.Name}' is repeated."); } } if (ContentProperty == null) { throw new ParsingException(34, sourceStream, "CheckBox content not specified."); } if (CheckedProperty == null) { throw new ParsingException(35, sourceStream, "CheckBox checked property not specified."); } if (CheckedProperty.FixedValueSource != null) { throw new ParsingException(36, sourceStream, "Checked property cannot be a static name."); } if (CheckedProperty.ObjectPropertyKey != null) { throw new ParsingException(37, sourceStream, "Checked property cannot use a key."); } return(new ComponentCheckBox(nameSource, ParserDomain.ToXamlName(nameSource.Source, nameSource.Name, "CheckBox"), ContentProperty, CheckedProperty)); }
private IComponentContainerList ParseComponentContainerList(IDeclarationSource nameSource, IParsingSourceStream sourceStream, List <ComponentInfo> infoList) { IComponentProperty ItemListProperty = null; IComponentProperty AreaProperty = null; foreach (ComponentInfo Info in infoList) { if (Info.NameSource.Name == "items" && ItemListProperty == null) { ItemListProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name == "area" && AreaProperty == null) { AreaProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name != "items" && Info.NameSource.Name != "area") { throw new ParsingException(27, sourceStream, $"Unknown token '{Info.NameSource.Name}'."); } else { throw new ParsingException(28, sourceStream, $"'{Info.NameSource.Name}' is repeated."); } } if (ItemListProperty == null) { throw new ParsingException(69, sourceStream, "Items not specified."); } if (AreaProperty == null) { throw new ParsingException(70, sourceStream, "Area not specified."); } if (AreaProperty.FixedValueSource == null) { throw new ParsingException(71, sourceStream, "Area name can only be a static name."); } return(new ComponentContainerList(nameSource, ParserDomain.ToXamlName(nameSource.Source, nameSource.Name, "ContainerList"), ItemListProperty, AreaProperty.FixedValueSource)); }
private IDynamicProperty Parse(IParsingSourceStream sourceStream, ref string line, ref int indentation, ref bool useTab) { while (string.IsNullOrEmpty(line) && !sourceStream.EndOfStream) { sourceStream.ReadLine(); line = sourceStream.Line; } IDeclarationSource PropertySource; string ResultValue; ParserDomain.ParseStringPair(sourceStream, ':', out PropertySource, out ResultValue); if (string.IsNullOrEmpty(PropertySource.Name)) { throw new ParsingException(209, sourceStream, "Missing dynamic property name."); } string CSharpName = ParserDomain.ToCSharpName(PropertySource.Source, PropertySource.Name); DynamicOperationResults Result; if (ResultValue == "boolean") { Result = DynamicOperationResults.Boolean; } else { throw new ParsingException(210, sourceStream, $"Invalid dynamic property type '{ResultValue}'."); } Stack <IDynamicOperation> OperationStack = new Stack <IDynamicOperation>(); IDynamicOperation RootOperation = null; for (;;) { sourceStream.ReadLine(); line = sourceStream.Line; if (string.IsNullOrEmpty(line)) { break; } if (indentation < 0) { MeasureIndentation(sourceStream, ref indentation, ref useTab); } int Depth = GetIndentation(sourceStream, indentation, useTab); string Text = line.Trim(); if (Text == "NOT") { OperationStack.Push(new UnaryOperation(DynamicOperationTypes.NOT)); } else if (Text == "OR") { OperationStack.Push(new BinaryOperation(DynamicOperationTypes.OR)); } else if (Text == "AND") { OperationStack.Push(new BinaryOperation(DynamicOperationTypes.AND)); } else if (Text == "EQUALS") { OperationStack.Push(new BinaryOperation(DynamicOperationTypes.EQUALS)); } else if (Text == "GREATER THAN") { OperationStack.Push(new BinaryOperation(DynamicOperationTypes.GREATER_THAN)); } else if (Text == "IS EMPTY") { OperationStack.Push(new UnaryOperation(DynamicOperationTypes.IS_EMPTY)); } else { IDynamicOperation Operand; int IntegerConstantValue; if (int.TryParse(Text, out IntegerConstantValue)) { Operand = new IntegerConstantOperation(IntegerConstantValue); } else { IDeclarationSource ObjectSource; IDeclarationSource MemberSource; IDeclarationSource KeySource; if (!ParserDomain.TryParseObjectProperty(sourceStream, Text, out ObjectSource, out MemberSource, out KeySource)) { throw new ParsingException(211, sourceStream, $"Expected operator, integer constant or object property."); } ComponentInfo Info = new ComponentInfo(); Info.ObjectSource = ObjectSource; Info.MemberSource = MemberSource; Info.KeySource = KeySource; ComponentProperty ValueProperty = new ComponentProperty(Info); Operand = new PropertyValueOperation(ValueProperty); } while (OperationStack.Count > 0) { IDynamicOperation CurrentOperation = OperationStack.Peek(); if ((CurrentOperation is IUnaryOperation AsUnary) && (AsUnary.Operand == null)) { AsUnary.SetOperand(Operand); RootOperation = OperationStack.Pop(); Operand = RootOperation; }
private IComponentRadioButton ParseComponentRadioButton(IDeclarationSource nameSource, IParsingSourceStream sourceStream, List <ComponentInfo> infoList) { IComponentProperty ContentProperty = null; IComponentProperty IndexProperty = null; IComponentProperty GroupNameProperty = null; IComponentProperty GroupIndexProperty = null; foreach (ComponentInfo Info in infoList) { if (Info.NameSource.Name == "content" && ContentProperty == null) { ContentProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name == "index" && IndexProperty == null) { IndexProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name == "group name" && GroupNameProperty == null) { GroupNameProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name == "group index" && GroupIndexProperty == null) { GroupIndexProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name != "content" && Info.NameSource.Name != "index" && Info.NameSource.Name != "group name" && Info.NameSource.Name != "group index") { throw new ParsingException(27, sourceStream, $"Unknown token '{Info.NameSource.Name}'."); } else { throw new ParsingException(28, sourceStream, $"'{Info.NameSource.Name}' is repeated."); } } if (ContentProperty == null) { throw new ParsingException(72, sourceStream, "Radio button content not specified."); } if (IndexProperty == null) { throw new ParsingException(73, sourceStream, "Index not specified."); } if (IndexProperty.FixedValueSource != null || IndexProperty.ObjectPropertyKey != null) { throw new ParsingException(74, sourceStream, "Index must be an integer, state or boolean property."); } if (GroupNameProperty == null) { throw new ParsingException(75, sourceStream, "Group name not specified."); } if (GroupNameProperty.FixedValueSource == null) { throw new ParsingException(76, sourceStream, "Group name can only be a static name."); } if (GroupIndexProperty == null) { throw new ParsingException(77, sourceStream, "Group index not specified."); } int GroupIndex; if (GroupIndexProperty.FixedValueSource == null || !int.TryParse(GroupIndexProperty.FixedValueSource.Name, out GroupIndex)) { throw new ParsingException(78, sourceStream, "Group index must be an integer constant."); } return(new ComponentRadioButton(nameSource, ParserDomain.ToXamlName(nameSource.Source, nameSource.Name, "RadioButton"), ContentProperty, IndexProperty, GroupNameProperty.FixedValueSource.Name, GroupIndex)); }
private IComponentPopup ParseComponentPopup(IDeclarationSource nameSource, IParsingSourceStream sourceStream, List <ComponentInfo> infoList) { IComponentProperty SourceProperty = null; IComponentProperty SourcePressedProperty = null; IComponentProperty AreaProperty = null; IComponentProperty WidthProperty = null; IComponentProperty HeightProperty = null; foreach (ComponentInfo Info in infoList) { if (Info.NameSource.Name == "source" && SourceProperty == null) { SourceProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name == "source pressed" && SourcePressedProperty == null) { SourcePressedProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name == "area" && AreaProperty == null) { AreaProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name == "width" && WidthProperty == null) { WidthProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name == "height" && HeightProperty == null) { HeightProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name != "source" && Info.NameSource.Name != "source pressed" && Info.NameSource.Name != "area" && Info.NameSource.Name != "width" && Info.NameSource.Name != "height") { throw new ParsingException(27, sourceStream, $"Unknown token '{Info.NameSource.Name}'."); } else { throw new ParsingException(28, sourceStream, $"'{Info.NameSource.Name}' is repeated."); } } if (SourceProperty == null) { throw new ParsingException(57, sourceStream, "Source not specified."); } if (SourceProperty.FixedValueSource == null) { throw new ParsingException(186, sourceStream, "Source can only be a static name."); } if (SourcePressedProperty != null && SourcePressedProperty.FixedValueSource == null) { throw new ParsingException(186, sourceStream, "Source pressed can only be a static name."); } if (AreaProperty == null) { throw new ParsingException(58, sourceStream, "Area not specified."); } if (AreaProperty.FixedValueSource == null) { throw new ParsingException(59, sourceStream, "Area name can only be a static name."); } double WidthValue; if (WidthProperty != null) { if (WidthProperty.FixedValueSource == null) { throw new ParsingException(54, sourceStream, "Width can only be a static value."); } string ImageWidth = WidthProperty.FixedValueSource.Name; if (!ParserDomain.TryParseDouble(ImageWidth, out WidthValue)) { throw new ParsingException(128, WidthProperty.FixedValueSource.Source, $"'{ImageWidth}' not parsed as a width."); } } else { WidthValue = double.NaN; } double HeightValue; if (HeightProperty != null) { if (HeightProperty.FixedValueSource == null) { throw new ParsingException(56, sourceStream, "Height can only be a static value."); } string ImageHeight = HeightProperty.FixedValueSource.Name; if (!ParserDomain.TryParseDouble(ImageHeight, out HeightValue)) { throw new ParsingException(129, HeightProperty.FixedValueSource.Source, $"'{ImageHeight}' not parsed as a height."); } } else { HeightValue = double.NaN; } return(new ComponentPopup(nameSource, ParserDomain.ToXamlName(nameSource.Source, nameSource.Name, "Popup"), SourceProperty, SourcePressedProperty, AreaProperty.FixedValueSource, WidthValue, HeightValue)); }
private IComponentImage ParseComponentImage(IDeclarationSource nameSource, IParsingSourceStream sourceStream, List <ComponentInfo> infoList) { IComponentProperty SourceProperty = null; IComponentProperty WidthProperty = null; IComponentProperty HeightProperty = null; foreach (ComponentInfo Info in infoList) { if (Info.NameSource.Name == "source" && SourceProperty == null) { SourceProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name == "width" && WidthProperty == null) { WidthProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name == "height" && HeightProperty == null) { HeightProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name != "source" && Info.NameSource.Name != "width" && Info.NameSource.Name != "height") { throw new ParsingException(27, sourceStream, $"Unknown token '{Info.NameSource.Name}'."); } else { throw new ParsingException(28, sourceStream, $"'{Info.NameSource.Name}' is repeated."); } } if (SourceProperty == null) { throw new ParsingException(52, sourceStream, "Source not specified."); } if (SourceProperty.FixedValueSource == null) { throw new ParsingException(0, sourceStream, "Source can only be a static resource name."); } bool IsResourceWidth; double WidthValue; if (WidthProperty != null) { if (WidthProperty.FixedValueSource == null) { throw new ParsingException(54, sourceStream, "Width can only be a static value."); } string ImageWidth = WidthProperty.FixedValueSource.Name; if (ImageWidth == "resource") { IsResourceWidth = true; WidthValue = double.NaN; } else if (ParserDomain.TryParseDouble(ImageWidth, out WidthValue)) { IsResourceWidth = false; } else { throw new ParsingException(128, WidthProperty.FixedValueSource.Source, $"'{ImageWidth}' not parsed as a width."); } } else { IsResourceWidth = false; WidthValue = double.NaN; } bool IsResourceHeight; double HeightValue; if (HeightProperty != null) { if (HeightProperty.FixedValueSource == null) { throw new ParsingException(56, sourceStream, "Height can only be a static value."); } string ImageHeight = HeightProperty.FixedValueSource.Name; if (ImageHeight == "resource") { IsResourceHeight = true; HeightValue = double.NaN; } else if (ParserDomain.TryParseDouble(ImageHeight, out HeightValue)) { IsResourceHeight = false; } else { throw new ParsingException(129, HeightProperty.FixedValueSource.Source, $"'{ImageHeight}' not parsed as a height."); } } else { IsResourceHeight = false; HeightValue = double.NaN; } return(new ComponentImage(nameSource, ParserDomain.ToXamlName(nameSource.Source, nameSource.Name, "Image"), SourceProperty, IsResourceWidth, WidthValue, IsResourceHeight, HeightValue)); }
private IComponentEdit ParseComponentEdit(IDeclarationSource nameSource, IParsingSourceStream sourceStream, List <ComponentInfo> infoList) { IComponentProperty TextProperty = null; IComponentProperty AcceptsReturnProperty = null; IComponentProperty TextDecorationProperty = null; IComponentProperty HorizontalScrollBarVisibilityProperty = null; IComponentProperty VerticalScrollBarVisibilityProperty = null; foreach (ComponentInfo Info in infoList) { if (Info.NameSource.Name == "text" && TextProperty == null) { TextProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name == "accepts return" && AcceptsReturnProperty == null) { AcceptsReturnProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name == "decoration" && TextDecorationProperty == null) { TextDecorationProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name == "decoration" && TextDecorationProperty == null) { TextDecorationProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name == "horizontal scrollbar" && HorizontalScrollBarVisibilityProperty == null) { HorizontalScrollBarVisibilityProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name == "vertical scrollbar" && VerticalScrollBarVisibilityProperty == null) { VerticalScrollBarVisibilityProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name != "text" && Info.NameSource.Name != "accepts return" && Info.NameSource.Name != "alignment" && Info.NameSource.Name != "wrapping" && Info.NameSource.Name != "decoration" && Info.NameSource.Name != "horizontal scrollbar" && Info.NameSource.Name != "vertical scrollbar") { throw new ParsingException(27, sourceStream, $"Unknown token '{Info.NameSource.Name}'."); } else { throw new ParsingException(28, sourceStream, $"'{Info.NameSource.Name}' is repeated."); } } if (TextProperty == null) { throw new ParsingException(41, sourceStream, "Text not specified."); } if (TextProperty.FixedValueSource != null || TextProperty.ObjectPropertyKey != null) { throw new ParsingException(42, sourceStream, "Text must be a string property."); } if (AcceptsReturnProperty != null && AcceptsReturnProperty.FixedValueSource.Name != "Yes") { throw new ParsingException(43, sourceStream, "The only valid value for the 'accepts return' property is 'Yes'."); } if (TextDecorationProperty != null && TextDecorationProperty.FixedValueSource == null) { throw new ParsingException(44, sourceStream, "Decoration can only be a constant."); } if (HorizontalScrollBarVisibilityProperty != null && HorizontalScrollBarVisibilityProperty.FixedValueSource == null) { throw new ParsingException(45, sourceStream, "Horizontal scrollbar can only be a constant."); } if (VerticalScrollBarVisibilityProperty != null && VerticalScrollBarVisibilityProperty.FixedValueSource == null) { throw new ParsingException(46, sourceStream, "Vertical scrollbar can only be a constant."); } bool AcceptsReturn = (AcceptsReturnProperty != null); string TextDecoration = TextDecorationProperty != null ? TextDecorationProperty.FixedValueSource.Name : null; if (TextDecoration != null && TextDecoration != Windows.UI.Text.TextDecorations.OverLine.ToString() && TextDecoration != Windows.UI.Text.TextDecorations.Strikethrough.ToString() && TextDecoration != Windows.UI.Text.TextDecorations.Underline.ToString()) { throw new ParsingException(47, sourceStream, $"Invalid decoration for '{nameSource.Name}'."); } string HorizontalScrollBarVisibility = HorizontalScrollBarVisibilityProperty != null ? HorizontalScrollBarVisibilityProperty.FixedValueSource.Name : null; if (HorizontalScrollBarVisibility != null && HorizontalScrollBarVisibility != Windows.UI.Xaml.Controls.ScrollBarVisibility.Disabled.ToString() && HorizontalScrollBarVisibility != Windows.UI.Xaml.Controls.ScrollBarVisibility.Auto.ToString() && HorizontalScrollBarVisibility != Windows.UI.Xaml.Controls.ScrollBarVisibility.Hidden.ToString() && HorizontalScrollBarVisibility != Windows.UI.Xaml.Controls.ScrollBarVisibility.Visible.ToString()) { throw new ParsingException(48, sourceStream, $"Invalid horizontal scrollbar for '{nameSource.Name}'."); } string VerticalScrollBarVisibility = VerticalScrollBarVisibilityProperty != null ? VerticalScrollBarVisibilityProperty.FixedValueSource.Name : null; if (VerticalScrollBarVisibility != null && VerticalScrollBarVisibility != Windows.UI.Xaml.Controls.ScrollBarVisibility.Disabled.ToString() && VerticalScrollBarVisibility != Windows.UI.Xaml.Controls.ScrollBarVisibility.Auto.ToString() && VerticalScrollBarVisibility != Windows.UI.Xaml.Controls.ScrollBarVisibility.Hidden.ToString() && VerticalScrollBarVisibility != Windows.UI.Xaml.Controls.ScrollBarVisibility.Visible.ToString()) { throw new ParsingException(49, sourceStream, $"Invalid vertical scrollbar for '{nameSource.Name}'."); } return(new ComponentEdit(nameSource, ParserDomain.ToXamlName(nameSource.Source, nameSource.Name, "Edit"), TextProperty, AcceptsReturn, TextDecoration, HorizontalScrollBarVisibility, VerticalScrollBarVisibility)); }
private IComponentButton ParseComponentButton(IDeclarationSource nameSource, IParsingSourceStream sourceStream, List <ComponentInfo> infoList) { IComponentProperty ContentProperty = null; IComponentEvent BeforeEvent = null; IComponentProperty NavigateProperty = null; IComponentProperty ExternalProperty = null; IComponentEvent AfterEvent = null; IComponentProperty ClosePopupProperty = null; foreach (ComponentInfo Info in infoList) { if (Info.NameSource.Name == "content" && ContentProperty == null) { ContentProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name == "before" && BeforeEvent == null) { BeforeEvent = new ComponentEvent(Info); } else if (Info.NameSource.Name == "goto" && NavigateProperty == null) { NavigateProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name == "external" && ExternalProperty == null) { ExternalProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name == "after" && AfterEvent == null) { AfterEvent = new ComponentEvent(Info); } else if (Info.NameSource.Name == "close popup" && ClosePopupProperty == null) { ClosePopupProperty = new ComponentProperty(Info); } else if (Info.NameSource.Name != "content" && Info.NameSource.Name != "before" && Info.NameSource.Name != "goto" && Info.NameSource.Name != "external" && Info.NameSource.Name != "after" && Info.NameSource.Name != "close popup") { throw new ParsingException(27, sourceStream, $"Unknown token '{Info.NameSource.Name}'."); } else { throw new ParsingException(28, sourceStream, $"'{Info.NameSource.Name}' is repeated."); } } if (ContentProperty == null) { throw new ParsingException(31, sourceStream, "Button content not specified."); } if (NavigateProperty == null) { throw new ParsingException(32, sourceStream, "Button goto page name not specified."); } if (NavigateProperty.FixedValueSource == null && (NavigateProperty.ObjectSource == null || NavigateProperty.ObjectPropertySource == null || NavigateProperty.ObjectPropertyKey != null)) { throw new ParsingException(33, sourceStream, "Go to page name can only be a static name or a readonly string property."); } bool IsExternal; if (ExternalProperty != null) { if (ExternalProperty.FixedValueSource == null || ExternalProperty.FixedValueSource.Name.ToLower() != "true") { throw new ParsingException(237, sourceStream, "Button external specifier can only have value 'true'."); } else if (ClosePopupProperty != null || AfterEvent != null) { throw new ParsingException(238, sourceStream, "Button with the external specifier cannot have an 'close popup' property or an 'after' event."); } else { IsExternal = true; } } else { IsExternal = false; } if (NavigateProperty.FixedValueSource == null) { if (!IsExternal) { throw new ParsingException(0, sourceStream, "Go to page name, if not a static name, can only be external."); } if (BeforeEvent != null || AfterEvent != null || ClosePopupProperty != null) { throw new ParsingException(0, sourceStream, "Button going to a non-static page cannot have a before or after event, or a 'close popup' property."); } } if (ClosePopupProperty != null && ClosePopupProperty.FixedValueSource != null) { throw new ParsingException(219, sourceStream, "Close popup can only be a property."); } return(new ComponentButton(nameSource, ParserDomain.ToXamlName(nameSource.Source, nameSource.Name, "Button"), ContentProperty, BeforeEvent, NavigateProperty, IsExternal, AfterEvent, ClosePopupProperty)); }