Пример #1
0
        public object Get()
        {
            if (data == null)
            {
                if (!dataCursor.IsNull)
                {
                    // caller expects to get an IEditable, 'convert' cursor to editable
                    data       = factory.Create(dataCursor);
                    dataCursor = default(Cursor);
                }
                else
                {
                    // special auto-create logic of variable fields (even if variable was null)
                    data = factory.Create(dataSchema, nullable);
                }

                if (this.Frozen)
                {
                    data.Freeze();
                }
            }

            return(data);
        }
Пример #2
0
        public static Cursor ToCursor(this IEditable source, bool freeze = true)
        {
            if (!source.Frozen)
            {
                if (freeze)
                {
                    source.Freeze();
                }
                else
                {
                    source = source.CloneAsEditable(true);
                }
            }

            return(new Cursor(source.SchemaProvider, source.Schema, new ArraySegment <byte>(source.ToByteArray())));
        }
Пример #3
0
        public static byte[] ToByteArray(this IEditable source, bool freeze = true)
        {
            if (!source.Frozen)
            {
                if (freeze)
                {
                    source.Freeze();
                }
                else
                {
                    source = source.CloneAsEditable(true);
                }
            }

            var buffer = new byte[source.SerializedSize];

            source.WriteTo(new MemoryStream(buffer));
            return(buffer);
        }