MongoDB.Driver.OidGenerator.Generate C# (CSharp) Метод

Generate() публичный Метод

public Generate ( ) : Oid
Результат Oid
        public Oid Generate()
        {
            //FIXME Endian issues with this code.
            //.Net runs in native endian mode which is usually little endian.
            //Big endian machines don't need the reversing (Linux+PPC, XNA on XBox)
            byte[] oid = new byte[12];
            int copyidx = 0;

            byte[] time = BitConverter.GetBytes(GenerateTime());
            Array.Reverse(time);
            Array.Copy(time,0,oid,copyidx,4);
            copyidx += 4;

            Array.Copy(machineHash,0,oid,copyidx,3);
            copyidx += 3;

            Array.Copy(this.procID,2,oid,copyidx,2);
            copyidx += 2;

            byte[] inc = BitConverter.GetBytes(GenerateInc());
            Array.Reverse(inc);
            Array.Copy(inc,1,oid,copyidx,3);

            return new Oid(oid);
        }

Usage Example

Пример #1
0
 public void TestCastsToDocument()
 {
     OidGenerator ogen = new OidGenerator();
     DBRef dref = new DBRef("tests.dbrefs", ogen.Generate());
     Document doc = (Document)dref;
     Assert.AreEqual(dref.CollectionName, doc[DBRef.RefName]);
 }
All Usage Examples Of MongoDB.Driver.OidGenerator::Generate