Exemplo n.º 1
0
        private static object BuildOneInstance(AtomicNativeObjectInfo objectInfo)
        {
            var odbTypeId = objectInfo.GetOdbTypeId();
            

            return CheckIfNull(objectInfo, odbTypeId);
        }
Exemplo n.º 2
0
        private long WriteAtomicNativeObject(AtomicNativeObjectInfo anoi, bool writeInTransaction,
                                                    int totalSpaceIfString = -1)
        {
            var startPosition = FileSystemProcessor.FileSystemInterface.GetPosition();
            var odbTypeId = anoi.GetOdbTypeId();
            WriteNativeObjectHeader(odbTypeId, anoi.IsNull(), BlockTypes.BlockTypeNativeObject, writeInTransaction);
            if (anoi.IsNull())
            {
                // Even if object is null, reserve space for to simplify/enable in
                // place update
                FileSystemProcessor.FileSystemInterface.EnsureSpaceFor(anoi.GetOdbType());
                return startPosition;
            }
            var @object = anoi.GetObject();
            switch (odbTypeId)
            {
                case OdbType.ByteId:
                    {
                        FileSystemProcessor.FileSystemInterface.WriteByte(((byte) @object), writeInTransaction);
                        break;
                    }

                case OdbType.SByteId:
                    {
                        FileSystemProcessor.FileSystemInterface.WriteSByte(((sbyte)@object), writeInTransaction);
                        break;
                    }

                case OdbType.BooleanId:
                    {
                        FileSystemProcessor.FileSystemInterface.WriteBoolean(((bool) @object), writeInTransaction);
                        break;
                    }

                case OdbType.CharacterId:
                    {
                        FileSystemProcessor.FileSystemInterface.WriteChar(((char) @object), writeInTransaction);
                        break;
                    }

                case OdbType.FloatId:
                    {
                        FileSystemProcessor.FileSystemInterface.WriteFloat(((float) @object), writeInTransaction);
                        break;
                    }

                case OdbType.DoubleId:
                    {
                        FileSystemProcessor.FileSystemInterface.WriteDouble(((double) @object), writeInTransaction);
                        break;
                    }

                case OdbType.IntegerId:
                    {
                        FileSystemProcessor.FileSystemInterface.WriteInt(((int) @object), writeInTransaction);
                        break;
                    }

                case OdbType.UIntegerId:
                    {
                        FileSystemProcessor.FileSystemInterface.WriteUInt(((uint)@object), writeInTransaction); // native attr
                        break;
                    }

                case OdbType.LongId:
                    {
                        FileSystemProcessor.FileSystemInterface.WriteLong(((long)@object), writeInTransaction); // native attr
                        break;
                    }

                case OdbType.ULongId:
                    {
                        FileSystemProcessor.FileSystemInterface.WriteULong(((ulong)@object), writeInTransaction); // native attr
                        break;
                    }

                case OdbType.ShortId:
                    {
                        FileSystemProcessor.FileSystemInterface.WriteShort(((short) @object), writeInTransaction);
                        break;
                    }

                case OdbType.UShortId:
                    {
                        FileSystemProcessor.FileSystemInterface.WriteUShort(((ushort)@object), writeInTransaction);
                        break;
                    }

                case OdbType.DecimalId:
                    {
                        FileSystemProcessor.FileSystemInterface.WriteBigDecimal((Decimal) @object, writeInTransaction);
                        break;
                    }

                case OdbType.DateId:
                    {
                        FileSystemProcessor.FileSystemInterface.WriteDate((DateTime) @object, writeInTransaction);
                        break;
                    }

                case OdbType.StringId:
                    {
                        FileSystemProcessor.FileSystemInterface.WriteString((string) @object, writeInTransaction, totalSpaceIfString);
                        break;
                    }

                case OdbType.OidId:
                    {
                        var oid = ((ObjectOID) @object).ObjectId;
                        FileSystemProcessor.FileSystemInterface.WriteLong(oid, writeInTransaction);
                        break;
                    }

                case OdbType.ObjectOidId:
                    {
                        var ooid = ((ObjectOID) @object).ObjectId;
                        FileSystemProcessor.FileSystemInterface.WriteLong(ooid, writeInTransaction);
                        break;
                    }

                case OdbType.ClassOidId:
                    {
                        var coid = ((ClassOID) @object).ObjectId;
                        FileSystemProcessor.FileSystemInterface.WriteLong(coid, writeInTransaction);
                        break;
                    }

                default:
                {
                    var typeId = odbTypeId.ToString();
                    var message = 
                        "native type with odb type id " + typeId + " (" + OdbType.GetNameFromId(odbTypeId) + ") for attribute ? is not suported";

                    throw new OdbRuntimeException(NDatabaseError.InternalError.AddParameter(message));
                }
            }
            return startPosition;
        }