public StringCommon[] GetImagePaths()
        {
            var res = new StringCommon[] { p1PictoPath, p2PictoPath };

            if (p1Gif != null)
            {
                res = res.Concat(p1Gif.GetFrames()).ToArray();
            }
            if (p2Gif != null)
            {
                res = res.Concat(p2Gif.GetFrames()).ToArray();
            }
            return(res);
        }
        public StringCommon[] GetImagePaths()
        {
            var res = new StringCommon[] { imagePath };

            if (gif != null)
            {
                res = res.Concat(gif.GetFrames()).ToArray();
            }
            return(res);
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Input"></param>
        /// <param name="outValue"></param>
        /// <exception cref="DomSyntaxError">On invalid value</exception>
        public void Parse(string Input, out object outValue)
        {
            if (Input is null)
            {
                throw new ArgumentNullException(nameof(Input));
            }
            Contract.EndContractBlock();

            switch (Type)
            {
            case EAttributeType.String:    // strings accept any value
            {
                outValue = Input;
            }
            break;

            case EAttributeType.Boolean:    // we need no verification for booleans. they dont care what the value use, only whether its null or not
            {
                outValue = Input is object;
            }
            break;

            case EAttributeType.Color:
            {
                if (!HTMLParserCommon.Parse_Simple_Color_String(Input.AsMemory(), out SimpleColor outVal))
                {
                    throw new DomSyntaxError($"Attribute {Name}: \"{Input}\" is not an valid color string");
                }

                outValue = outVal;
            }
            break;

            case EAttributeType.Date:
            {
                if (!HTMLParserCommon.Parse_Date_String(Input.AsMemory(), out DateTime outVal))
                {
                    throw new DomSyntaxError($"Attribute {Name}: \"{Input}\" is not an valid date string");
                }

                outValue = outVal;
            }
            break;

            case EAttributeType.Time:
            {
                if (!HTMLParserCommon.Parse_Time_String(Input.AsMemory(), out TimeSpan outVal))
                {
                    throw new DomSyntaxError($"Attribute {Name}: \"{Input}\" is not an valid time string");
                }

                outValue = outVal;
            }
            break;

            case EAttributeType.Duration:
            {
                if (!HTMLParserCommon.Parse_Duration_String(Input.AsMemory(), out double outVal))
                {
                    throw new DomSyntaxError($"Attribute {Name}: \"{Input}\" is not an valid duration string");
                }

                outValue = outVal;
            }
            break;

            case EAttributeType.Enumerated:
            {
                string strLower = Input.ToLowerInvariant();
                if (Keywords is object && Keywords.Count > 0)
                {
                    if (!Keywords.Contains(strLower))
                    {
                        throw new DomSyntaxError($"Attribute {Name}: \"{Input}\" is not an acceptable value, Acceptable values are: {StringCommon.Concat(", ".AsSpan(), Keywords.Select(o => o.AsMemory()))}");
                    }
                    else if (enumType is object && CssUI.Lookup.TryEnum(enumType, strLower, out var outEnum))
                    {
                        outValue = outEnum;
                        break;
                        //throw new DomSyntaxError($"Unable to find keyword value for \"{strLower}\" in enum: {enumType.Name}");
                    }

                    outValue = strLower;
                }
                else
                {
                    throw new DomSyntaxError($"Definition for enumerated attribute \"{Name}\" does not have any keywords specified!");
                }
            }
            break;

            case EAttributeType.Integer:
            {
                if (!HTMLParserCommon.Try_Parse_Integer(Input.AsMemory(), out long outVal))
                {
                    throw new DomSyntaxError($"Attribute {Name}: \"{Input}\" is not an valid integer");
                }

                outValue = outVal;
            }
            break;

            case EAttributeType.NonNegative_Integer:
            {
                if (!HTMLParserCommon.Try_Parse_Integer(Input.AsMemory(), out long outVal) || outVal < 0)
                {
                    throw new DomSyntaxError($"Attribute {Name}: \"{Input}\" is not an valid non-negative integer");
                }

                outValue = (ulong)outVal;
            }
            break;

            case EAttributeType.FloatingPoint:
            {
                if (!HTMLParserCommon.Try_Parse_FloatingPoint(Input.AsMemory(), out float outVal))
                {
                    throw new DomSyntaxError($"Attribute {Name}: \"{Input}\" is not an valid number");
                }

                outValue = outVal;
            }
            break;

            case EAttributeType.Length:
            {
                if (!HTMLParserCommon.Try_Parse_Length(Input.AsMemory(), out var outVal, out EAttributeType outTy) || outTy != EAttributeType.Length)
                {
                    throw new DomSyntaxError($"Attribute {Name}: \"{Input}\" is not an valid length");
                }

                outValue = outVal;
            }
            break;

            case EAttributeType.NonZero_Length:
            {
                if (!HTMLParserCommon.Try_Parse_Length(Input.AsMemory(), out var outVal, out EAttributeType outTy) || outVal <= 0d || outTy != EAttributeType.Length)
                {
                    throw new DomSyntaxError($"Attribute {Name}: \"{Input}\" is not an valid non-zero length");
                }

                outValue = outVal;
            }
            break;

            case EAttributeType.Percentage:
            {
                if (!HTMLParserCommon.Try_Parse_Length(Input.AsMemory(), out var outVal, out EAttributeType outTy) || outTy != EAttributeType.Percentage)
                {
                    throw new DomSyntaxError($"Attribute {Name}: \"{Input}\" is not an valid percentage");
                }

                outValue = outVal;
            }
            break;

            case EAttributeType.NonZero_Percentage:
            {
                if (!HTMLParserCommon.Try_Parse_Length(Input.AsMemory(), out var outVal, out EAttributeType outTy) || outVal <= 0d || outTy != EAttributeType.Percentage)
                {
                    throw new DomSyntaxError($"Attribute {Name}: \"{Input}\" is not an valid non-zero percentage");
                }

                outValue = outVal;
            }
            break;

            case EAttributeType.KeyCombo:
            {
                throw new NotImplementedException();
            }
            break;

            default:
            {
                throw new NotImplementedException($"Unrecognized attribute type: {Type}");
            }
            break;
            }
        }
Exemplo n.º 4
0
 public void ConcatNoDelimiterTest(string Expected, params string[] Inputs)
 {
     Assert.Equal(Expected, StringCommon.Concat(Inputs.Select(o => o.AsMemory())));
 }