Exemplo n.º 1
0
 public virtual void WriteLengthAndString(IWriteBuffer buffer, string str)
 {
     if (str == null)
     {
         buffer.WriteInt(0);
         return;
     }
     buffer.WriteInt(str.Length);
     Write(buffer, str);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Note the different implementation when compared to LatinStringIO and UnicodeStringIO:
 /// Instead of writing the length of the string, UTF8StringIO writes the length of the
 /// byte array.
 /// </summary>
 /// <remarks>
 /// Note the different implementation when compared to LatinStringIO and UnicodeStringIO:
 /// Instead of writing the length of the string, UTF8StringIO writes the length of the
 /// byte array.
 /// </remarks>
 public override void WriteLengthAndString(IWriteBuffer buffer, string str)
 {
     if (str == null)
     {
         buffer.WriteInt(0);
         return;
     }
     byte[] bytes = Encode(str);
     buffer.WriteInt(bytes.Length);
     buffer.WriteBytes(bytes);
 }
        internal override void Marshall(Transaction trans, ObjectReference @ref, IWriteBuffer
                                        buffer, bool isMigrating, bool isNew)
        {
            VirtualAttributes   attr      = @ref.VirtualAttributes();
            ObjectContainerBase container = trans.Container();
            bool doAddIndexEntry          = isNew && container.MaintainsIndices();
            int  dbID           = 0;
            bool linkToDatabase = (attr != null && attr.i_database == null) ? true : !isMigrating;

            if (linkToDatabase)
            {
                Db4oDatabase db = ((IInternalObjectContainer)container).Identity();
                if (db == null)
                {
                    // can happen on early classes like Metaxxx, no problem
                    attr = null;
                }
                else
                {
                    if (attr.i_database == null)
                    {
                        attr.i_database = db;
                        // TODO: Should be check for ! client instead of instanceof
                        if (container is LocalObjectContainer)
                        {
                            attr.i_uuid     = container.GenerateTimeStampId();
                            doAddIndexEntry = true;
                        }
                    }
                    db = attr.i_database;
                    if (db != null)
                    {
                        dbID = db.GetID(trans);
                    }
                }
            }
            else
            {
                if (attr != null)
                {
                    dbID = attr.i_database.GetID(trans);
                }
            }
            buffer.WriteInt(dbID);
            if (attr == null)
            {
                buffer.WriteLong(0);
                return;
            }
            buffer.WriteLong(attr.i_uuid);
            if (doAddIndexEntry)
            {
                AddIndexEntry(trans, @ref.GetID(), attr.i_uuid);
            }
        }
Exemplo n.º 4
0
		/// <summary>
		/// Note the different implementation when compared to LatinStringIO and UnicodeStringIO:
		/// Instead of writing the length of the string, UTF8StringIO writes the length of the
		/// byte array.
		/// </summary>
		/// <remarks>
		/// Note the different implementation when compared to LatinStringIO and UnicodeStringIO:
		/// Instead of writing the length of the string, UTF8StringIO writes the length of the
		/// byte array.
		/// </remarks>
		public override void WriteLengthAndString(IWriteBuffer buffer, string str)
		{
			if (str == null)
			{
				buffer.WriteInt(0);
				return;
			}
			byte[] bytes = Encode(str);
			buffer.WriteInt(bytes.Length);
			buffer.WriteBytes(bytes);
		}
Exemplo n.º 5
0
 private static void WriteElementCount(IWriteBuffer context, ICollectionInitializer initializer)
 {
     context.WriteInt(initializer.Count());
 }
        private static void WriteElementCount(IWriteBuffer context, ICollectionInitializer initializer)
		{
            context.WriteInt(initializer.Count());
		}
Exemplo n.º 7
0
		public virtual void WriteLengthAndString(IWriteBuffer buffer, string str)
		{
			if (str == null)
			{
				buffer.WriteInt(0);
				return;
			}
			buffer.WriteInt(str.Length);
			Write(buffer, str);
		}
 internal override void MarshallIgnore(IWriteBuffer buffer)
 {
     buffer.WriteInt(0);
     buffer.WriteLong(0);
 }
Exemplo n.º 9
0
 internal override void MarshallIgnore(IWriteBuffer buffer)
 {
     buffer.WriteInt(0);
     buffer.WriteLong(0);
 }
Exemplo n.º 10
0
 internal override void Marshall(Transaction trans, ObjectReference @ref, IWriteBuffer
     buffer, bool isMigrating, bool isNew)
 {
     var attr = @ref.VirtualAttributes();
     var container = trans.Container();
     var doAddIndexEntry = isNew && container.MaintainsIndices();
     var dbID = 0;
     var linkToDatabase = (attr != null && attr.i_database == null) ? true : !isMigrating;
     if (linkToDatabase)
     {
         var db = ((IInternalObjectContainer) container).Identity();
         if (db == null)
         {
             // can happen on early classes like Metaxxx, no problem
             attr = null;
         }
         else
         {
             if (attr.i_database == null)
             {
                 attr.i_database = db;
                 // TODO: Should be check for ! client instead of instanceof
                 if (container is LocalObjectContainer)
                 {
                     attr.i_uuid = container.GenerateTimeStampId();
                     doAddIndexEntry = true;
                 }
             }
             db = attr.i_database;
             if (db != null)
             {
                 dbID = db.GetID(trans);
             }
         }
     }
     else
     {
         if (attr != null)
         {
             dbID = attr.i_database.GetID(trans);
         }
     }
     buffer.WriteInt(dbID);
     if (attr == null)
     {
         buffer.WriteLong(0);
         return;
     }
     buffer.WriteLong(attr.i_uuid);
     if (doAddIndexEntry)
     {
         AddIndexEntry(trans, @ref.GetID(), attr.i_uuid);
     }
 }