Esempio n. 1
0
        public override KeyValuePair <string, EntityProperty>[] CastValue(Type typeOfValue, object value, string propertyName)
        {
            if (!IsCorrectType(typeOfValue))
            {
                return(base.CastValue(typeOfValue, value, propertyName));
            }

            var valueRect = (string[])value;

            var stringBytes = valueRect.ToUTF8ByteArrayOfStrings();
            var ep          = new EntityProperty(stringBytes);

            return(ep.PairWithKey(propertyName).AsArray());
        }
        public override KeyValuePair <string, EntityProperty>[] CastValue(Type typeOfValue, object value, string propertyName)
        {
            if (typeOfValue == typeof(RectangleF))
            {
                var valueRect = (RectangleF)value;
                var xBytes    = BitConverter.GetBytes(valueRect.X);
                var yBytes    = BitConverter.GetBytes(valueRect.Y);
                var wBytes    = BitConverter.GetBytes(valueRect.Width);
                var hBytes    = BitConverter.GetBytes(valueRect.Height);

                var rectBytes = xBytes
                                .Concat(yBytes)
                                .Concat(wBytes)
                                .Concat(hBytes)
                                .ToArray();
                var ep = new EntityProperty(rectBytes);
                return(ep.PairWithKey(propertyName).AsArray());
            }

            return(base.CastValue(typeOfValue, value, propertyName));
        }