Ejemplo n.º 1
0
        private static Border CreateBorder(string color)
        {
            Border border = new Border();

            border.LeftBorder = new LeftBorder()
            {
                Color = new Color()
                {
                    Rgb = HexBinaryValue.FromString(color)
                },
                Style = BorderStyleValues.Thin
            };
            border.RightBorder = new RightBorder()
            {
                Color = new Color()
                {
                    Rgb = HexBinaryValue.FromString(color)
                },
                Style = BorderStyleValues.Thin
            };
            border.BottomBorder = new BottomBorder()
            {
                Color = new Color()
                {
                    Rgb = HexBinaryValue.FromString(color)
                },
                Style = BorderStyleValues.Thin
            };

            return(border);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// <see cref="IMCItem"/> の色情報を使用して、<see cref="Fill"/> を生成します。
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        private Fill _createFillFromMCItem(IMCItem item)
        {
            // "#RRGGBB" => "FFRRGGBB"
            var backgroundColorCode = HexBinaryValue.FromString(this._mcItemToArgbCode(item));

            var pFill = new PatternFill()
            {
                PatternType = PatternValues.Solid
            };

            pFill.Append(new ForegroundColor()
            {
                Rgb = backgroundColorCode
            });
            pFill.Append(new BackgroundColor()
            {
                Rgb = backgroundColorCode
            });

            var fill = new Fill();

            fill.Append(pFill);

            return(fill);
        }
Ejemplo n.º 3
0
        public static uint ajoutFill(Stylesheet ss, string color)
        {
            Fills fills     = ss.Fills;
            uint  indexFill = fills.Count;

            Fill        fill;
            PatternFill patternFill;

            if (color == "")
            {
                fill                    = new Fill();
                patternFill             = new PatternFill();
                patternFill.PatternType = PatternValues.None;
                fill.PatternFill        = patternFill;
                fills.Append(fill);
            }
            else
            {
                fill                            = new Fill();
                patternFill                     = new PatternFill();
                patternFill.PatternType         = PatternValues.Solid;
                patternFill.ForegroundColor     = new ForegroundColor();
                patternFill.ForegroundColor.Rgb = HexBinaryValue.FromString(color);
                patternFill.BackgroundColor     = new BackgroundColor();
                patternFill.BackgroundColor.Rgb = patternFill.ForegroundColor.Rgb;
                fill.PatternFill                = patternFill;
                fills.Append(fill);
            }

            fills.Count = (uint)fills.ChildElements.Count;
            return(fills.Count - 1);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Create Fill styles
        /// </summary>
        private static void CreateFillStyles(Fills fills)
        {
            Fill        fill        = new Fill();
            PatternFill patternFill = new PatternFill();

            patternFill.PatternType = PatternValues.None;
            fill.PatternFill        = patternFill;
            fills.Append(fill);

            //Fill index 1
            fill                    = new Fill();
            patternFill             = new PatternFill();
            patternFill.PatternType = PatternValues.Gray125;
            fill.PatternFill        = patternFill;
            fills.Append(fill);

            //Fill index 2
            fill                            = new Fill();
            patternFill                     = new PatternFill();
            patternFill.PatternType         = PatternValues.Solid;
            patternFill.ForegroundColor     = new ForegroundColor();
            patternFill.ForegroundColor.Rgb = HexBinaryValue.FromString("00ff9728");
            patternFill.BackgroundColor     = new BackgroundColor();
            patternFill.BackgroundColor.Rgb = patternFill.ForegroundColor.Rgb;
            fill.PatternFill                = patternFill;
            fills.Append(fill);

            fills.Count = UInt32Value.FromUInt32((uint)fills.ChildElements.Count);
        }
Ejemplo n.º 5
0
        public void GetBytes()
        {
            var type = new HexBinaryValue();

            Assert.False(type.TryGetBytes(out _));

            type.InnerText = "00";
            Assert.True(type.TryGetBytes(out var result1));
            Assert.Collection(result1, b => Assert.Equal(0, b));

            type.InnerText = "01";
            Assert.True(type.TryGetBytes(out var result2));
            Assert.Collection(result2, b => Assert.Equal(1, b));

            type.InnerText = "FF";
            Assert.True(type.TryGetBytes(out var result3));
            Assert.Collection(result3, b => Assert.Equal(0xFF, b));

            type.InnerText = "FFF";
            Assert.False(type.TryGetBytes(out _));

            type.InnerText = "FF01";
            Assert.True(type.TryGetBytes(out var result4));
            Assert.Collection(
                result4,
                b => Assert.Equal(0xFF, b),
                b => Assert.Equal(0x01, b));
        }
Ejemplo n.º 6
0
        public static Cell SetCellBackgroundColor(this WorksheetPart part, WorkbookPart book,
                                                  string columnName, uint startRow, HexBinaryValue color)
        {
            var sheet = part.Worksheet;

            return(sheet.SetCellBackgroundColor(book, columnName, startRow, color));
        }
Ejemplo n.º 7
0
        private static Fills GetFills()
        {
            Fills fills = new Fills();

            var defaultFill1 = new Fill(new PatternFill {
                PatternType = PatternValues.None
            });                                                                                // Index 0 - default

            fills.Append(defaultFill1);

            var defaultFill2 = new Fill(new PatternFill {
                PatternType = PatternValues.Gray125
            });                                                                                   // Index 1 - default

            fills.Append(defaultFill2);

            Fill fillColumnHeader = new Fill
            {
                PatternFill = new PatternFill
                {
                    PatternType     = PatternValues.Solid,
                    ForegroundColor = new ForegroundColor {
                        Rgb = HexBinaryValue.FromString("FF005EB8")
                    }
                }
            };

            fills.Append(fillColumnHeader);

            fills.Count = UInt32Value.FromUInt32((uint)fills.ChildElements.Count);
            return(fills);
        }
Ejemplo n.º 8
0
         new ForegroundColor()
 {
     Rgb = new HexBinaryValue()
     {
         Value = FillColor.Value
     }
 }
Ejemplo n.º 9
0
 public static UInt32Value GetStyleIndex(this WorkbookPart book, HexBinaryValue bgColor)
 {
     try { return(_styleIndexes[bgColor.Value]); }
     catch (KeyNotFoundException ex)
     {
         var stylesheet = book.GetStyleSheet();
         var fill       = stylesheet.GetFill(bgColor);
         var formats    = stylesheet.CellFormats.Elements <CellFormat>();
         for (int x = 0; x < formats.Count(); x++)
         {
             if (formats.ElementAt(x).FillId.Value == fill.Value)
             {
                 return(new UInt32Value((uint)x));
             }
         }
         var cellFormat = new CellFormat
         {
             NumberFormatId = 0,
             FontId         = 0,
             FillId         = fill,
             BorderId       = 0,
             FormatId       = 0,
             ApplyFill      = BooleanValue.FromBoolean(true)
         };
         stylesheet.CellFormats.Append(cellFormat);
         stylesheet.CellFormats.Count = UInt32Value.FromUInt32((uint)stylesheet.CellFormats.ChildElements.Count);
         var value = new UInt32Value((uint)stylesheet.CellFormats.Count() - 1);
         _styleIndexes.Add(bgColor.Value, value);
         return(value);
     }
 }
Ejemplo n.º 10
0
        public static Cell SetCellBackgroundColor(this Worksheet sheet, WorkbookPart book, string columnName,
                                                  uint startRow, HexBinaryValue color)
        {
            var sheetData = sheet.GetFirstChild <SheetData>();
            var cell      = sheetData.SetCellBackgroundColor(book, columnName, startRow, color);

            return(cell);
        }
Ejemplo n.º 11
0
 public void CreateFromBytes()
 {
     Assert.Equal(string.Empty, HexBinaryValue.Create().Value);
     Assert.Equal("00", HexBinaryValue.Create(0).Value);
     Assert.Equal("01", HexBinaryValue.Create(1).Value);
     Assert.Equal("FF", HexBinaryValue.Create(0xFF).Value);
     Assert.Equal("FF01", HexBinaryValue.Create(0xFF, 0x01).Value);
 }
Ejemplo n.º 12
0
        private void BuildFills(WorkbookStylesPart stylesPart)
        {
            stylesPart.Stylesheet.Fills = new Fills();

            // create a solid red fill
            var solidRed = new PatternFill {
                PatternType     = PatternValues.Solid,
                ForegroundColor = new ForegroundColor {
                    Rgb = HexBinaryValue.FromString("FFFF0000")
                },
                BackgroundColor = new BackgroundColor {
                    Indexed = 64
                }
            };

            // create green
            var green = createColor("FF006836");
            // create yellow
            var yellow = createColor("FFffff00");
            // create orange
            var orange = createColor("FFff7d00");
            // create blue
            var blue = createColor("ff002fff");
            // create white
            var white = createColor("ffffffff");

            stylesPart.Stylesheet.Fills.AppendChild(new Fill {
                PatternFill = new PatternFill {
                    PatternType = PatternValues.None
                }
            });                                                                                                                       // required, reserved by Excel
            stylesPart.Stylesheet.Fills.AppendChild(new Fill {
                PatternFill = new PatternFill {
                    PatternType = PatternValues.Gray125
                }
            });                                                                                                                          // required, reserved by Excel

            stylesPart.Stylesheet.Fills.AppendChild(new Fill {
                PatternFill = solidRed
            });
            stylesPart.Stylesheet.Fills.AppendChild(new Fill {
                PatternFill = green
            });
            stylesPart.Stylesheet.Fills.AppendChild(new Fill {
                PatternFill = yellow
            });
            stylesPart.Stylesheet.Fills.AppendChild(new Fill {
                PatternFill = orange
            });
            stylesPart.Stylesheet.Fills.AppendChild(new Fill {
                PatternFill = blue
            });
            stylesPart.Stylesheet.Fills.AppendChild(new Fill {
                PatternFill = white
            });

            stylesPart.Stylesheet.Fills.Count = 7;
        }
Ejemplo n.º 13
0
        private static Fonts GetFonts()
        {
            Fonts fonts = new Fonts();

            // 0
            Font fontNormal = new Font()
            {
                FontName = new FontName {
                    Val = StringValue.FromString("Calibri")
                },
                FontSize = new FontSize {
                    Val = DoubleValue.FromDouble(11)
                }
            };

            fonts.Append(fontNormal);

            // 1
            Font fontTitle = new Font()
            {
                FontName = new FontName {
                    Val = StringValue.FromString("Calibri")
                },
                FontSize = new FontSize {
                    Val = DoubleValue.FromDouble(25)
                },
                Color = new Color {
                    Rgb = HexBinaryValue.FromString("ff584642")
                }
            };

            fonts.Append(fontTitle);

            // 2
            Font fontColumnHeaders = new Font()
            {
                FontName = new FontName {
                    Val = StringValue.FromString("Calibri")
                },
                FontSize = new FontSize {
                    Val = DoubleValue.FromDouble(13.5)
                },
                Color = new Color()
                {
                    Rgb = HexBinaryValue.FromString("ffffffff")
                },                                                                   //white
                Bold = new Bold()
                {
                    Val = true
                }
            };

            fonts.Append(fontColumnHeaders);

            fonts.Count = UInt32Value.FromUInt32((uint)fonts.ChildElements.Count);
            return(fonts);
        }
Ejemplo n.º 14
0
        public void ValidateValue(string innerText, bool expected)
        {
            var type = new HexBinaryValue
            {
                InnerText = innerText,
            };

            Assert.Equal(expected, type.IsValid);
        }
Ejemplo n.º 15
0
        public HexBinaryValueTests()
        {
            SmallValue1 = new HexBinaryValue(SmallHexBinary);
            SmallValue2 = new HexBinaryValue(SmallHexBinary);

            NullValue1 = new HexBinaryValue();
            NullValue2 = new HexBinaryValue();

            LargeValue = new HexBinaryValue(LargeHexBinary);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Adds the font color to the current
        /// style sheet and creates a cell reference style
        /// </summary>
        /// <param name="color"></param>
        private static void AddFontStyle(SystemColor color)
        {
            HexBinaryValue hex = HexBinaryValue.FromString(color.ToHexArgb());
            //Search for style
            bool exists = StylePart.Stylesheet.Fonts
                          .Select(f => f as Font)
                          .Where(f => f.Color != null)
                          .Where(f => f.Color.Rgb.Equals(hex))
                          .Any();

            if (exists)
            {
                return;
            }
            //Create font element
            Font font = new Font();

            font.Append(new FontSize()
            {
                Val = 11D
            });
            font.Append(new Color()
            {
                Rgb = hex
            });
            font.Append(new FontName()
            {
                Val = "Calibri"
            });
            font.Append(new FontFamilyNumbering()
            {
                Val = 2
            });
            font.Append(new FontScheme()
            {
                Val = FontSchemeValues.Minor
            });
            font.Append(new Bold());
            CellFormat cellFontFormat = new CellFormat()
            {
                FontId    = StylePart.Stylesheet.Fonts.Count,
                ApplyFont = true
            };

            StylePart.Stylesheet.Fonts.Append(font);
            StylePart.Stylesheet.Fonts.Count++;
            //Add the format style reference
            StylePart.Stylesheet.CellFormats.Append(cellFontFormat);
            StylePart.Stylesheet.CellFormats.Count++;
            //Save all changes
            StylePart.Stylesheet.Save();
        }
Ejemplo n.º 17
0
        public MakeStyleIntent WithFill(string rgbColor, PatternValues patternType = PatternValues.Solid)
        {
            var _rgb        = rgbColor.TrimStart('#');
            var patternFill = new PatternFill()
            {
                PatternType = PatternValues.Solid
            };

            patternFill.ForegroundColor = new ForegroundColor()
            {
                Rgb = HexBinaryValue.FromString(_rgb)
            };
            return(WithFill(patternFill));
        }
Ejemplo n.º 18
0
        public static Border CreateBorder(bool leftBorder, bool rightBorder, bool topBorder, bool bottomBorder, string borderColor, BorderStyleValues borderSize)
        {
            Border border = new Border();
            Color  color  = new Color
            {
                Rgb = HexBinaryValue.FromString(borderColor)
            };

            if (leftBorder)
            {
                LeftBorder leftBorder2 = new LeftBorder()
                {
                    Style = borderSize
                };
                leftBorder2.Color = color;
                border.LeftBorder = leftBorder2;
            }

            if (rightBorder)
            {
                RightBorder rightBorder2 = new RightBorder()
                {
                    Style = borderSize
                };
                rightBorder2.Color = (Color)color.CloneNode(true);
                border.RightBorder = rightBorder2;
            }

            if (topBorder)
            {
                TopBorder topBorder2 = new TopBorder()
                {
                    Style = borderSize
                };
                topBorder2.Color = (Color)color.CloneNode(true);
                border.TopBorder = topBorder2;
            }

            if (bottomBorder)
            {
                BottomBorder bottomBorder2 = new BottomBorder()
                {
                    Style = borderSize
                };
                bottomBorder2.Color = (Color)color.CloneNode(true);
                border.BottomBorder = bottomBorder2;
            }

            return(border);
        }
Ejemplo n.º 19
0
        private PatternFill createColor(string colorhex)
        {
            var color = new PatternFill {
                PatternType     = PatternValues.Solid,
                ForegroundColor = new ForegroundColor {
                    Rgb = HexBinaryValue.FromString(colorhex)
                },
                BackgroundColor = new BackgroundColor {
                    Indexed = 64
                }
            };

            return(color);
        }
Ejemplo n.º 20
0
        protected static bool GetAttrNumVal(OpenXmlSimpleType attributeValue, out double value)
        {
            HexBinaryValue hexBinaryValue = attributeValue as HexBinaryValue;

            if (hexBinaryValue != null)
            {
                long val;
                bool result = long.TryParse(hexBinaryValue.Value, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out val);
                value = val;
                return(result);
            }

            return(double.TryParse(attributeValue.InnerText, NumberStyles.AllowDecimalPoint,
                                   CultureInfo.InvariantCulture, out value));
        }
Ejemplo n.º 21
0
        public static Cell SetCellBackgroundColor(this SheetData data, WorkbookPart book, string columnName,
                                                  uint startRow, HexBinaryValue color)
        {
            var row           = data.GetRow(startRow);
            var cellReference = columnName + startRow;
            var cells         = row.Elements <Cell>();
            var refCell       = cells.GetRefCell(cellReference);
            var currentCell   = cells.GetCell(cellReference) ?? row.InsertBefore(new Cell(), refCell);

            var x = book.GetStyleIndex(color);

            currentCell.CellReference = cellReference;
            currentCell.StyleIndex    = x;
            return(currentCell);
        }
Ejemplo n.º 22
0
        public void SetFont(WorkbookStylesPart stylesPart, UInt32Value fontIndex)
        {
            DocumentFormat.OpenXml.Spreadsheet.Font font = new DocumentFormat.OpenXml.Spreadsheet.Font();
            if (IsBold)
            {
                font.Bold = new DocumentFormat.OpenXml.Spreadsheet.Bold();
            }
            font.Color = new DocumentFormat.OpenXml.Spreadsheet.Color()
            {
                Rgb = HexBinaryValue.FromString(((uint)Color).ToString("x8"))
            };

            stylesPart.Stylesheet.Fonts.AppendChild(font);
            FontIndex = fontIndex;
        }
Ejemplo n.º 23
0
        static public PatternFill GetFill(this CellFillAttribute cellFillAttribute)
        {
            PatternFill retFill = new PatternFill()
            {
                PatternType = PatternValues.Solid
            };

            if (!string.IsNullOrEmpty(cellFillAttribute.HexColor))
            {
                retFill.ForegroundColor = new ForegroundColor()
                {
                    Rgb = HexBinaryValue.FromString(cellFillAttribute.HexColor)
                };
            }

            return(retFill);
        }
Ejemplo n.º 24
0
        public static Fill CreateFill(string foreHexColor, string backHexColor)
        {
            PatternFill solidColor = new PatternFill {
                PatternType = PatternValues.Solid
            };

            solidColor.ForegroundColor = new ForegroundColor {
                Rgb = HexBinaryValue.FromString(foreHexColor)
            };
            solidColor.BackgroundColor = new BackgroundColor {
                Rgb = HexBinaryValue.FromString(backHexColor)
            };

            return(new Fill {
                PatternFill = solidColor
            });
        }
        /// <summary>
        /// Creates fills
        /// </summary>
        /// <param name="styleSheet">The style sheet.</param>
        static void CreateFills(Stylesheet styleSheet)
        {
            Fills fills = new Fills();

            fills.Append(new Fill {
                PatternFill = new PatternFill {
                    PatternType = PatternValues.None
                }
            });                                                                                            //0
            fills.Append(new Fill {
                PatternFill = new PatternFill {
                    PatternType = PatternValues.Gray125
                }
            });                   //1
            fills.Append(new Fill //2
            {
                PatternFill = new PatternFill
                {
                    PatternType     = PatternValues.Solid,
                    ForegroundColor = new ForegroundColor {
                        Rgb = HexBinaryValue.FromString("01DF3A")
                    },
                    BackgroundColor = new BackgroundColor {
                        Rgb = HexBinaryValue.FromString("01DF3A")
                    },
                }
            });
            fills.Append(new Fill //3
            {
                PatternFill = new PatternFill
                {
                    PatternType     = PatternValues.Solid,
                    ForegroundColor = new ForegroundColor {
                        Rgb = HexBinaryValue.FromString("FFFFFF")
                    },
                    BackgroundColor = new BackgroundColor {
                        Rgb = HexBinaryValue.FromString("FFFFFF")
                    },
                }
            });

            fills.Count = UInt32Value.FromUInt32((uint)fills.ChildElements.Count);

            styleSheet.Append(fills);
        }
Ejemplo n.º 26
0
        public static Font CreateFont(string hexForeColor, string fontName, double?fontSize, bool isBold, bool isItalic)
        {
            // Creamos una fuente nueva
            Font font = new Font();

            // Si tiene otra fuente diferente a la de por defecto, la cambiamos
            if (!string.IsNullOrEmpty(fontName))
            {
                font.Append(new FontName {
                    Val = fontName
                });
            }

            // Si tiene un tamaño diferente al de por defecto, lo cambiamos
            if (fontSize.HasValue)
            {
                font.Append(new FontSize {
                    Val = fontSize.Value
                });
            }

            // Si es negrita lo cambiamos
            if (isBold)
            {
                font.Append(new Bold());
            }

            // Si es cursiva, lo cambiamos
            if (isItalic)
            {
                font.Append(new Italic());
            }

            // Establecemos el color de la fuente
            Color color = new Color
            {
                Rgb = HexBinaryValue.FromString(hexForeColor)
            };

            font.Append(color);

            return(font);
        }
Ejemplo n.º 27
0
        public Fill ToXmlStyle()
        {
            var fill    = new Fill();
            var pattern = new PatternFill()
            {
                PatternType = PatternType
            };

            if (!string.IsNullOrEmpty(FillCollor))
            {
                pattern.ForegroundColor = new ForegroundColor()
                {
                    Rgb = HexBinaryValue.FromString(FillCollor)
                }
            }
            ;
            fill.Append(pattern);
            return(fill);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Adds the background color to the current
        /// style sheet and creates a cell reference style
        /// </summary>
        /// <param name="color"></param>
        private static void AddBackgroundStyle(SystemColor color)
        {
            HexBinaryValue hex = HexBinaryValue.FromString(color.ToHexArgb());
            //Search for style
            bool exists = StylePart.Stylesheet.Fills
                          .Select(f => f as Fill)
                          .Where(f => f.PatternFill.ForegroundColor != null)
                          .Where(f => f.PatternFill.PatternType.Equals(PatternValues.Solid))
                          .Where(f => f.PatternFill.ForegroundColor.Rgb.Equals(hex))
                          .Any();

            if (exists)
            {
                return;
            }
            //Create fill element
            Fill fill = new Fill()
            {
                PatternFill = new PatternFill()
                {
                    ForegroundColor = new ForegroundColor()
                    {
                        Rgb = hex,
                    },
                    PatternType = PatternValues.Solid
                }
            };
            //Add the fill (of a background)
            CellFormat cellFontFormat = new CellFormat()
            {
                FillId    = StylePart.Stylesheet.Fills.Count,
                ApplyFill = true
            };

            StylePart.Stylesheet.Fills.Append(fill);
            StylePart.Stylesheet.Fills.Count++;
            //Add the format style reference
            StylePart.Stylesheet.CellFormats.Append(cellFontFormat);
            StylePart.Stylesheet.CellFormats.Count++;
            //Save all changes
            StylePart.Stylesheet.Save();
        }
Ejemplo n.º 29
0
        public static UInt32Value GetFill(this Stylesheet stylesheet, HexBinaryValue bgColor)
        {
            try { return(_fills[bgColor.Value]); }
            catch (KeyNotFoundException ex)
            {
                var fills = stylesheet.Fills.Elements <Fill>();
                for (int x = 0; x < fills.Count(); x++)
                {
                    var currentFill = fills.ElementAt(x).Elements <PatternFill>().Where(p => p.PatternType == PatternValues.Solid);
                    if (currentFill != null && currentFill.Count() > 0)
                    {
                        var patternFill     = currentFill.First();
                        var backgroundColor = patternFill.Elements <ForegroundColor>();
                        for (int y = 0; y < backgroundColor.Count(); y++)
                        {
                            var color = backgroundColor.ElementAt(y);
                            if (color != null && color.Rgb != null && color.Rgb.Value == bgColor.Value)
                            {
                                return((uint)x);
                            }
                        }
                    }
                }

                var fill = new Fill(new PatternFill(new ForegroundColor()
                {
                    Rgb = bgColor
                }, new BackgroundColor()
                {
                    Auto = true
                })
                {
                    PatternType = PatternValues.Solid
                });
                stylesheet.Fills.Append(fill);
                stylesheet.Fills.Count = UInt32Value.FromUInt32((uint)stylesheet.Fills.ChildElements.Count);
                var value = new UInt32Value((uint)stylesheet.Fills.Count() - 1);
                _fills.Add(bgColor.Value, value);
                return(value);
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        /// 创建一个字体相关的Excel样式
        /// </summary>
        /// <param name="fontName"></param>
        /// <param name="fontSize"></param>
        /// <param name="fontColor"></param>
        /// <returns></returns>
        private static Font CreateFont(string fontName, string fontSize, string fontColor)
        {
            Font font = new Font();

            font.FontName = new FontName()
            {
                Val = new StringValue(fontName)
            };
            font.FontSize = new FontSize()
            {
                Val = new DoubleValue(double.Parse(fontSize))
            };
            font.Color = new Color()
            {
                Rgb = HexBinaryValue.FromString(fontColor)
            };
            font.FontFamilyNumbering = new FontFamilyNumbering {
                Val = 2
            };
            return(font);
        }
Ejemplo n.º 31
0
        internal static OpenXmlSimpleType CreateTargetValueObject(RedirectedRestriction redirectedRestriction)
        {
            OpenXmlSimpleType simpleValue = null;

            switch (redirectedRestriction.AttributeId)
            {
                // property name: Width
                case 2387:
                    simpleValue = new UInt32Value();
                    break;

                // property name: VerticalSpace
                case 2389:
                    simpleValue = new UInt32Value();
                    break;

                // property name: HorizontalSpace
                case 2390:
                    simpleValue = new UInt32Value();
                    break;

                // property name: X
                case 2394:
                    simpleValue = new Int32Value();
                    break;

                // property name: Y
                case 2396:
                    simpleValue = new Int32Value();
                    break;

                // property name: Before
                case 2409:
                    simpleValue = new UInt32Value();
                    break;

                // property name: After
                case 2412:
                    simpleValue = new UInt32Value();
                    break;

                // property name: Line
                case 2415:
                    simpleValue = new Int32Value();
                    break;

                // property name: Left
                case 2417:
                    simpleValue = new Int32Value();
                    break;

                // property name: Start
                case 2418:
                    simpleValue = new Int32Value();
                    break;

                // property name: Right
                case 2421:
                    simpleValue = new Int32Value();
                    break;

                // property name: End
                case 2422:
                    simpleValue = new Int32Value();
                    break;

                // property name: Hanging
                case 2425:
                    simpleValue = new UInt32Value();
                    break;

                // property name: FirstLine
                case 2427:
                    simpleValue = new UInt32Value();
                    break;

                // property name: Val
                case 2473:
                    simpleValue = new Int32Value();
                    break;

                // property name: Val
                case 2474:
                    simpleValue = new UInt32Value();
                    break;

                // property name: Width
                case 2589:
                    simpleValue = new Int32Value();
                    break;

                // property name: Distance
                case 2643:
                    simpleValue = new UInt32Value();
                    break;

                // property name: Space
                case 2650:
                    simpleValue = new UInt32Value();
                    break;

                // property name: Val
                case 2680:
                    simpleValue = new StringValue();
                    break;

                // property name: Width
                case 2686:
                    simpleValue = new UInt32Value();
                    break;

                // property name: Space
                case 2687:
                    simpleValue = new UInt32Value();
                    break;

                // property name: Width
                case 2704:
                    simpleValue = new UInt32Value();
                    break;

                // property name: Val
                case 2732:
                    simpleValue = new UInt32Value();
                    break;

                // property name: LegacySpace
                case 2738:
                    simpleValue = new UInt32Value();
                    break;

                // property name: LegacyIndent
                case 2739:
                    simpleValue = new Int32Value();
                    break;

                // property name: Val
                case 2769:
                    simpleValue = new Int32Value();
                    break;

                // property name: Percent
                case 2847:
                    simpleValue = new Int32Value();
                    break;

                // property name: Val
                case 2872:
                    simpleValue = new HexBinaryValue();
                    break;

                // property name: FontSize
                case 2924:
                    simpleValue = new Int32Value();
                    break;

                // property name: Val
                case 2986:
                    simpleValue = new StringValue();
                    break;

                // property name: Delay
                case 2991:
                    simpleValue = new StringValue();
                    break;

                // property name: ShapeId
                case 3071:
                    simpleValue = new StringValue();
                    break;

                // property name: AutoAdvance
                case 3079:
                    simpleValue = new StringValue();
                    break;

                // property name: ShapeId
                case 3080:
                    simpleValue = new StringValue();
                    break;

                // property name: ShapeId
                case 3084:
                    simpleValue = new StringValue();
                    break;

                // property name: ShapeId
                case 3089:
                    simpleValue = new StringValue();
                    break;

                // property name: AdvanceAfterTime
                case 3150:
                    simpleValue = new UInt32Value();
                    break;

                // property name: ShapeId
                case 3153:
                    simpleValue = new StringValue();
                    break;

                default:
                    Debug.Assert(false);
                    break;
            }

            return simpleValue;
        }
Ejemplo n.º 32
0
        internal static OpenXmlSimpleType[] CreatePossibleMembers(UnionValueRestriction unionValueRestriction)
        {
            OpenXmlSimpleType[] simpleValues = new OpenXmlSimpleType[unionValueRestriction.UnionTypes.Length];

            switch (unionValueRestriction.UnionId)
            {
                // ST_AnimationDgmBuildType
                case 25:
                    simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Drawing.AnimationBuildValues>();
                    simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.Drawing.AnimationDiagramOnlyBuildValues>();
                    break;

                // ST_AnimationChartBuildType
                case 27:
                    simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Drawing.AnimationBuildValues>();
                    simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.Drawing.AnimationChartOnlyBuildValues>();
                    break;

                // ST_AdjCoordinate
                case 45:
                    simpleValues[0] = new Int64Value();
                    simpleValues[1] = new StringValue();
                    break;

                // ST_AdjAngle
                case 46:
                    simpleValues[0] = new Int32Value();
                    simpleValues[1] = new StringValue();
                    break;

                // ST_LayoutShapeType
                case 145:
                    simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Drawing.ShapeTypeValues>();
                    simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.OutputShapeValues>();
                    break;

                // ST_ParameterVal
                case 183:
                    simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.HorizontalAlignmentValues>();
                    simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.VerticalAlignmentValues>();
                    simpleValues[2] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.ChildDirectionValues>();
                    simpleValues[3] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.ChildAlignmentValues>();
                    simpleValues[4] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.SecondaryChildAlignmentValues>();
                    simpleValues[5] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.LinearDirectionValues>();
                    simpleValues[6] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.SecondaryLinearDirectionValues>();
                    simpleValues[7] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.StartingElementValues>();
                    simpleValues[8] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.BendPointValues>();
                    simpleValues[9] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.ConnectorRoutingValues>();
                    simpleValues[10] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.ArrowheadStyleValues>();
                    simpleValues[11] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.ConnectorDimensionValues>();
                    simpleValues[12] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.RotationPathValues>();
                    simpleValues[13] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.CenterShapeMappingValues>();
                    simpleValues[14] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.NodeHorizontalAlignmentValues>();
                    simpleValues[15] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.NodeVerticalAlignmentValues>();
                    simpleValues[16] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.FallbackDimensionValues>();
                    simpleValues[17] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.TextDirectionValues>();
                    simpleValues[18] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.PyramidAccentPositionValues>();
                    simpleValues[19] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.PyramidAccentTextMarginValues>();
                    simpleValues[20] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.TextBlockDirectionValues>();
                    simpleValues[21] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.TextAnchorHorizontalValues>();
                    simpleValues[22] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.TextAnchorVerticalValues>();
                    simpleValues[23] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.TextAlignmentValues>();
                    simpleValues[24] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.AutoTextRotationValues>();
                    simpleValues[25] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.GrowDirectionValues>();
                    simpleValues[26] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.FlowDirectionValues>();
                    simpleValues[27] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.ContinueDirectionValues>();
                    simpleValues[28] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.BreakpointValues>();
                    simpleValues[29] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.OffsetValues>();
                    simpleValues[30] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.HierarchyAlignmentValues>();
                    simpleValues[31] = new Int32Value();
                    simpleValues[32] = new DoubleValue();
                    simpleValues[33] = new BooleanValue();
                    simpleValues[34] = new StringValue();
                    simpleValues[35] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.ConnectorPointValues>();
                    break;

                // ST_ModelId
                case 184:
                    simpleValues[0] = new Int32Value();
                    simpleValues[1] = new StringValue();
                    break;

                // ST_FunctionValue
                case 207:
                    simpleValues[0] = new Int32Value();
                    simpleValues[1] = new BooleanValue();
                    simpleValues[2] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.DirectionValues>();
                    simpleValues[3] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.HierarchyBranchStyleValues>();
                    simpleValues[4] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.AnimateOneByOneValues>();
                    simpleValues[5] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.AnimationLevelStringValues>();
                    simpleValues[6] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.ResizeHandlesStringValues>();
                    break;

                // ST_FunctionArgument
                case 209:
                    simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.VariableValues>();
                    break;

                // ST_NonZeroDecimalNumber
                case 368:
                    simpleValues[0] = new Int32Value();
                    simpleValues[1] = new Int32Value();
                    break;

                // ST_MarkupId
                case 375:
                    simpleValues[0] = new Int32Value();
                    simpleValues[1] = new Int32Value();
                    break;

                // ST_HexColor
                case 404:
                    simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Wordprocessing.AutomaticColorValues>();
                    simpleValues[1] = new HexBinaryValue();
                    break;

                // ST_DecimalNumberOrPercent
                case 507:
                    simpleValues[0] = new StringValue();
                    simpleValues[1] = new Int32Value();
                    break;

                // ST_SignedHpsMeasure_O14
                case 525:
                    simpleValues[0] = new IntegerValue();
                    simpleValues[1] = new StringValue();
                    break;

                // ST_HpsMeasure_O14
                case 528:
                    simpleValues[0] = new UInt32Value();
                    simpleValues[1] = new StringValue();
                    break;

                // ST_SignedTwipsMeasure_O14
                case 531:
                    simpleValues[0] = new IntegerValue();
                    simpleValues[1] = new StringValue();
                    break;

                // ST_TwipsMeasure_O14
                case 534:
                    simpleValues[0] = new UInt32Value();
                    simpleValues[1] = new StringValue();
                    break;

                // ST_TransitionEightDirectionType
                case 544:
                    simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Presentation.TransitionSlideDirectionValues>();
                    simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.Presentation.TransitionCornerDirectionValues>();
                    break;

                // ST_TLTimeAnimateValueTime
                case 561:
                    simpleValues[0] = new Int32Value();
                    simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.Presentation.IndefiniteTimeDeclarationValues>();
                    break;

                // ST_TLTime_O12
                case 603:
                    simpleValues[0] = new UInt32Value();
                    simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.Presentation.IndefiniteTimeDeclarationValues>();
                    break;

                // ST_TLTime_O14
                case 604:
                    simpleValues[0] = new StringValue();
                    simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.Presentation.IndefiniteTimeDeclarationValues>();
                    break;

                // ST_PublishDate
                case 689:
                    simpleValues[0] = new DateTimeValue();
                    simpleValues[1] = new DateTimeValue();
                    simpleValues[2] = new StringValue();
                    break;

                // ST_ChannelDataPoint
                case 697:
                    simpleValues[0] = new DecimalValue();
                    simpleValues[1] = new BooleanValue();
                    break;

                // ST_ChannelPropertyName
                case 701:
                    simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardChannelPropertyNameValues>();
                    simpleValues[1] = new StringValue();
                    break;

                // ST_BrushPropertyName
                case 704:
                    simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardBrushPropertyNameValues>();
                    simpleValues[1] = new StringValue();
                    break;

                // ST_ChannelName
                case 707:
                    simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardChannelNameValues>();
                    simpleValues[1] = new StringValue();
                    break;

                // ST_Units
                case 719:
                    simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardLengthUnitsValues>();
                    simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardPerLengthUnitsValues>();
                    simpleValues[2] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardTimeUnitsValues>();
                    simpleValues[3] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardPerTimeUnitsValues>();
                    simpleValues[4] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardMassForceUnitsValues>();
                    simpleValues[5] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardPerMassForceUnitsValues>();
                    simpleValues[6] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardAngleUnitsValues>();
                    simpleValues[7] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardPerAngleUnitsValues>();
                    simpleValues[8] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardOtherUnitsValues>();
                    simpleValues[9] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardPerOtherUnitsValues>();
                    simpleValues[10] = new StringValue();
                    break;

                // ST_BrushPropertyValue
                case 732:
                    simpleValues[0] = new DecimalValue();
                    simpleValues[1] = new BooleanValue();
                    simpleValues[2] = new EnumValue<DocumentFormat.OpenXml.InkML.PenTipShapeValues>();
                    simpleValues[3] = new EnumValue<DocumentFormat.OpenXml.InkML.RasterOperationValues>();
                    simpleValues[4] = new StringValue();
                    break;

                // ST_Ref
                case 746:
                    simpleValues[0] = new StringValue();
                    simpleValues[1] = new UInt32Value();
                    break;

                // ST_CtxNodeType
                case 747:
                    simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Office2010.Ink.KnownContextNodeTypeValues>();
                    simpleValues[1] = new StringValue();
                    break;

                // ST_SemanticType
                case 750:
                    simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Office2010.Ink.KnownSemanticTypeValues>();
                    simpleValues[1] = new UInt32Value();
                    break;

                // ST_PointsOrInt
                case 753:
                    simpleValues[0] = new ListValue<StringValue>();
                    simpleValues[1] = new Int32Value();
                    break;

                default:
                    Debug.Assert(false);
                    break;
            }

            Debug.Assert(simpleValues.Length > 0);

            return simpleValues;
        }
Ejemplo n.º 33
0
        public void OpenXmlSimpleTypeConverterTest()
        {
            // 1. Base64BinaryValue
            Base64BinaryValue base64 = new Base64BinaryValue();
            base64 = "AA3322";
            Assert.True("AA3322" == base64);
            Assert.Equal("AA3322", base64.Value);
            base64 = Base64BinaryValue.FromString("1234");
            Assert.Equal("1234", base64.ToString());
            Assert.Equal("1234", Base64BinaryValue.ToString(base64));

            // 2. BooleanValue
            BooleanValue booleanValue = new BooleanValue();
            booleanValue = true;
            Assert.True(booleanValue);
            Assert.True(booleanValue.Value);
            booleanValue = BooleanValue.FromBoolean(false);
            Assert.False(booleanValue);
            Assert.Equal(false, BooleanValue.ToBoolean(booleanValue));

            // 3. ByteValue
            ByteValue byteValue = new ByteValue();
            Byte bt = 1;
            byteValue = bt;
            Assert.True(bt == byteValue);
            Assert.Equal(bt, byteValue.Value);
            bt = 2;
            byteValue = ByteValue.FromByte(bt);
            Assert.Equal(bt, ByteValue.ToByte(byteValue));

            // 4. DateTimeValue
            DateTimeValue dtValue = new DateTimeValue();
            DateTime dt = DateTime.Now;
            dtValue = dt;
            Assert.True(dt == dtValue);
            dt = DateTime.Now.AddDays(1);
            dtValue = DateTimeValue.FromDateTime(dt);
            Assert.Equal(dt, dtValue.Value);
            Assert.Equal(dt, DateTimeValue.ToDateTime(dt));

            // 5. DecimalValue
            DecimalValue decimalValue = new DecimalValue();
            decimal dcm = 10;
            decimalValue = dcm;
            Assert.True(dcm == decimalValue);
            decimalValue = DecimalValue.FromDecimal(20);
            Assert.Equal(20, decimalValue.Value);
            Assert.Equal(20, DecimalValue.ToDecimal(decimalValue));

            // 6. DoubleValue
            DoubleValue doubleValue = new DoubleValue();
            double dbl = 1.1;
            doubleValue = dbl;
            Assert.True(dbl == doubleValue);
            doubleValue = DoubleValue.FromDouble(2.2);
            Assert.Equal(2.2, doubleValue.Value);
            Assert.Equal(2.2, DoubleValue.ToDouble(doubleValue));

            // 7. HexBinaryValue
            HexBinaryValue hexBinaryValue = new HexBinaryValue();
            string hex = "0X99CCFF";
            hexBinaryValue = hex;
            Assert.True(hex == hexBinaryValue);
            hex = "111111";
            hexBinaryValue = HexBinaryValue.FromString(hex);
            Assert.Equal(hex, hexBinaryValue.Value);
            Assert.Equal(hex, HexBinaryValue.ToString(hexBinaryValue));

            // 8. Int16
            Int16Value int16Value = new Int16Value();
            Int16 int16 = 16;
            int16Value = int16;
            Assert.True(int16 == int16Value);
            int16 = 17;
            int16Value = Int16Value.FromInt16(int16);
            Assert.Equal(int16, int16Value.Value);
            Assert.Equal(int16, Int16Value.ToInt16(int16Value));

            // 9. Int32
            Int32Value int32Value = new Int32Value();
            Int32 int32 = 32;
            int32Value = int32;
            Assert.True(int32 == int32Value);
            int32 = 33;
            int32Value = Int32Value.FromInt32(int32);
            Assert.Equal(int32, int32Value.Value);
            Assert.Equal(int32, Int32Value.ToInt32(int32Value));

            // 10. Int64
            Int64Value int64Value = new Int64Value();
            Int64 int64 = 64;
            int64Value = int64;
            Assert.True(int64 == int64Value);
            int64 = 17;
            int64Value = Int64Value.FromInt64(int64);
            Assert.Equal(int64, int64Value.Value);
            Assert.Equal(int64, Int64Value.ToInt64(int64Value));

            // 11. IntegerValue
            IntegerValue integerValue = new IntegerValue();
            int integer = 64;
            integerValue = integer;
            Assert.True(integer == integerValue);
            integer = 17;
            integerValue = IntegerValue.FromInt64(integer);
            Assert.Equal(integer, integerValue.Value);
            Assert.Equal(integer, IntegerValue.ToInt64(integerValue));

            // 12. OnOffValue
            OnOffValue onOffValue = new OnOffValue();
            onOffValue = true;
            Assert.True(onOffValue);
            onOffValue = OnOffValue.FromBoolean(false);
            Assert.Equal(false, onOffValue.Value);
            Assert.Equal(false, OnOffValue.ToBoolean(onOffValue));

            // 13. SByteValue
            SByteValue sbyteValue = new SByteValue();
            SByte sbt = SByte.MaxValue;
            sbyteValue = sbt;
            Assert.True(sbt == sbyteValue);
            sbt = SByte.MinValue;
            sbyteValue = SByteValue.FromSByte(sbt);
            Assert.Equal(sbt, sbyteValue.Value);
            Assert.Equal(sbt, SByteValue.ToSByte(sbt));

            // 14. SingleValue
            SingleValue singleValue = new SingleValue();
            Single single = Single.MaxValue;
            singleValue = single;
            Assert.True(single == singleValue);
            single = Single.NaN;
            singleValue = SingleValue.FromSingle(single);
            Assert.Equal(single, singleValue.Value);
            Assert.Equal(single, SingleValue.ToSingle(singleValue));

            // 15. StringValue
            StringValue stringValue = new StringValue();
            String str = "Ethan";
            stringValue = str;
            Assert.True(str == stringValue);
            str = "Yin";
            stringValue = StringValue.FromString(str);
            Assert.Equal(str, stringValue.Value);
            Assert.Equal(str, stringValue.ToString());
            Assert.Equal(str, StringValue.ToString(stringValue));

            // 16. TrueFalseBlankValue
            TrueFalseBlankValue tfbValue = new TrueFalseBlankValue();
            tfbValue = true;
            Assert.True(tfbValue);
            tfbValue = TrueFalseBlankValue.FromBoolean(false);
            Assert.Equal(false, tfbValue.Value);
            Assert.Equal(false, TrueFalseBlankValue.ToBoolean(tfbValue));

            // 17. TrueFalseValue
            TrueFalseValue tfValue = new TrueFalseValue();
            tfValue = true;
            Assert.True(tfValue);
            tfValue = TrueFalseValue.FromBoolean(false);
            Assert.Equal(false, tfValue.Value);
            Assert.Equal(false, TrueFalseValue.ToBoolean(tfValue));

            // 18. UInt16Value
            UInt16Value uint16Value = new UInt16Value();
            UInt16 uint16 = UInt16.MaxValue;
            uint16Value = uint16;
            Assert.True(uint16 == uint16Value);
            uint16 = UInt16.MinValue;
            uint16Value = UInt16Value.FromUInt16(uint16);
            Assert.Equal(uint16, uint16Value.Value);
            Assert.Equal(uint16, UInt16Value.ToUInt16(uint16Value));

            // 19. UInt32Value
            UInt32Value uint32Value = new UInt32Value();
            UInt32 uint32 = UInt32.MaxValue;
            uint32Value = uint32;
            Assert.True(uint32 == uint32Value);
            uint32 = UInt32.MinValue;
            uint32Value = UInt32Value.FromUInt32(uint32);
            Assert.Equal(uint32, uint32Value.Value);
            Assert.Equal(uint32, UInt32Value.ToUInt32(uint32Value));

            // 20. UInt64Value
            UInt64Value uint64Value = new UInt64Value();
            UInt64 uint64 = UInt64.MaxValue;
            uint64Value = uint64;
            Assert.True(uint64 == uint64Value);
            uint64 = UInt64.MinValue;
            uint64Value = UInt64Value.FromUInt64(uint64);
            Assert.Equal(uint64, uint64Value.Value);
            Assert.Equal(uint64, UInt64Value.ToUInt64(uint64Value));
        }