Beispiel #1
0
 public override int Deserialize(System.Byte[] serialized, int startIndex)
 {
     int curIndex = startIndex;
     data = BitConverter.ToInt64(serialized, curIndex);
     curIndex += BitConverter.GetBytes(data).Length;
     return (curIndex - startIndex);
 }
		private DrawItemState getState(NSInteger row)
		{
			DrawItemState state = DrawItemState.None;
			if(Host is ListBox)
			{
				var lbox = (ListBox)Host;
				if (lbox.SelectedIndices.Contains ((int)row))
					state |= DrawItemState.Selected;
					
				if (lbox.has_focus && lbox.FocusedItem == row)
					state |= DrawItemState.Focus;
			}
			return state;
		}
		public override void DrawRow (NSInteger row, NSRect clipRect)
		{
			bool shouldDraw = true;
			using (var graphics = Graphics.FromHwnd (this.Handle))
			{	
				
				var events = new DrawItemEventArgs(graphics,
				                                   this.Font.ToFont(),
				                                   Util.NSRectToRectangle(clipRect),
				                                   (int)row,
				                                   getState(row));
				if(Host is ListBox)
					((ListBox)Host).DrawItemInternal (events);				
				shouldDraw = !events.Handled;
			}
			if (shouldDraw)
				base.DrawRow (row, clipRect);
		}
			public override NSObject ObjectValueForItem (NSComboBox comboBox, NSInteger index)
			{
				if (cbox == null)
					return null;
				if (string.IsNullOrEmpty (cbox.DisplayMember))
					returnString = new NSString (cbox.Items[(int)index].ToString ());
				else
					returnString = new NSString (Util.GetPropertyStringValue (cbox.Items[(int)index], cbox.DisplayMember));
				return returnString;
				
			}
Beispiel #5
0
        static void x_CountStep(
            sqlite3_context context,
            int argc,
            sqlite3_value[] argv
            )
        {
            SumCtx p;

            int type;

            Debug.Assert(argc <= 1);
            Mem pMem = sqlite3_aggregate_context(context, 1);//sizeof(*p));

            if (pMem._SumCtx == null)
            {
                pMem._SumCtx = new SumCtx();
            }
            p = pMem._SumCtx;
            if (p.Context == null)
            {
                p.Context = pMem;
            }
            if (argc == 0 || SQLITE_NULL == sqlite3_value_type(argv[0]))
            {
                p.cnt++;
                p.iSum += 1;
            }
            else
            {
                type = sqlite3_value_numeric_type(argv[0]);
                if (p != null && type != SQLITE_NULL)
                {
                    p.cnt++;
                    if (type == SQLITE_INTEGER)
                    {
                        i64 v = sqlite3_value_int64(argv[0]);
                        if (v == 40 || v == 41)
                        {
                            sqlite3_result_error(context, "value of " + v + " handed to x_count", -1);
                            return;
                        }
                        else
                        {
                            p.iSum += v;
                            if (!(p.approx | p.overflow != 0))
                            {
                                i64 iNewSum = p.iSum + v;
                                int s1      = (int)(p.iSum >> (sizeof(i64) * 8 - 1));
                                int s2      = (int)(v >> (sizeof(i64) * 8 - 1));
                                int s3      = (int)(iNewSum >> (sizeof(i64) * 8 - 1));
                                p.overflow = ((s1 & s2 & ~s3) | (~s1 & ~s2 & s3)) != 0 ? 1 : 0;
                                p.iSum     = iNewSum;
                            }
                        }
                    }
                    else
                    {
                        p.rSum  += sqlite3_value_double(argv[0]);
                        p.approx = true;
                    }
                }
            }
        }
Beispiel #6
0
 static int sqlite3OsTruncate(sqlite3_file id, i64 size)
 {
     return(id.pMethods.xTruncate(id, size));
 }
 public List <Reference> Get(string lang, System.Int64 questionId)
 {
     return(_dataLayer.GetReferences(lang, questionId));
 }
Beispiel #8
0
 private static extern void _gameCenterIssueScoreChallenge(System.Int64 score, System.Int64 context, string leaderboardId, string playerIds, string message);
Beispiel #9
0
 static int sqlite3OsTruncate( sqlite3_file id, i64 size )
 {
   return id.pMethods.xTruncate( id, size );
 }
Beispiel #10
0
 static int sqlite3OsWrite( sqlite3_file id, byte[] pBuf, int amt, i64 offset )
 {
   DO_OS_MALLOC_TEST( id );
   return id.pMethods.xWrite( id, pBuf, amt, offset );
 }
Beispiel #11
0
        /// <summary>
        /// This routine runs an extensive test of the Bitvec code.
        ///
        /// The input is an array of integers that acts as a program
        /// to test the Bitvec.  The integers are opcodes followed
        /// by 0, 1, or 3 operands, depending on the opcode.  Another
        /// opcode follows immediately after the last operand.
        ///
        /// There are 6 opcodes numbered from 0 through 5.  0 is the
        /// "halt" opcode and causes the test to end.
        ///
        ///    0          Halt and return the number of errors
        ///    1 N S X    Set N bits beginning with S and incrementing by X
        ///    2 N S X    Clear N bits beginning with S and incrementing by X
        ///    3 N        Set N randomly chosen bits
        ///    4 N        Clear N randomly chosen bits
        ///    5 N S X    Set N bits from S increment X in array only, not in bitvec
        ///
        /// The opcodes 1 through 4 perform set and clear operations are performed
        /// on both a Bitvec object and on a linear array of bits obtained from malloc.
        /// Opcode 5 works on the linear array only, not on the Bitvec.
        /// Opcode 5 is used to deliberately induce a fault in order to
        /// confirm that error detection works.
        ///
        /// At the conclusion of the test the linear array is compared
        /// against the Bitvec object.  If there are any differences,
        /// an error is returned.  If they are the same, zero is returned.
        ///
        /// If a memory allocation error occurs, return -1.
        /// </summary>
        static int sqlite3BitvecBuiltinTest(u32 sz, int[] aOp)
        {
            Bitvec pBitvec = null;

            byte[] pV = null;
            int    rc = -1;
            int    i, nx, pc, op;

            u32[] pTmpSpace;

            /* Allocate the Bitvec to be tested and a linear array of
            ** bits to act as the reference */
            pBitvec   = sqlite3BitvecCreate(sz);
            pV        = sqlite3_malloc((int)(sz + 7) / 8 + 1);
            pTmpSpace = new u32[BITVEC_SZ];// sqlite3_malloc( BITVEC_SZ );
            if (pBitvec == null || pV == null || pTmpSpace == null)
            {
                goto bitvec_end;
            }
            Array.Clear(pV, 0, (int)(sz + 7) / 8 + 1);// memset( pV, 0, ( sz + 7 ) / 8 + 1 );

            /* NULL pBitvec tests */
            sqlite3BitvecSet(null, (u32)1);
            sqlite3BitvecClear(null, 1, pTmpSpace);

            /* Run the program */
            pc = 0;
            while ((op = aOp[pc]) != 0)
            {
                switch (op)
                {
                case 1:
                case 2:
                case 5:
                {
                    nx           = 4;
                    i            = aOp[pc + 2] - 1;
                    aOp[pc + 2] += aOp[pc + 3];
                    break;
                }

                case 3:
                case 4:
                default:
                {
                    nx = 2;
                    i64 i64Temp = 0;
                    sqlite3_randomness(sizeof(i64), ref i64Temp);
                    i = (int)i64Temp;
                    break;
                }
                }
                if ((--aOp[pc + 1]) > 0)
                {
                    nx = 0;
                }
                pc += nx;
                i   = (int)((i & 0x7fffffff) % sz);
                if ((op & 1) != 0)
                {
                    SETBIT(pV, (i + 1));
                    if (op != 5)
                    {
                        if (sqlite3BitvecSet(pBitvec, (u32)i + 1) != 0)
                        {
                            goto bitvec_end;
                        }
                    }
                }
                else
                {
                    CLEARBIT(pV, (i + 1));
                    sqlite3BitvecClear(pBitvec, (u32)i + 1, pTmpSpace);
                }
            }

            /* Test to make sure the linear array exactly matches the
            ** Bitvec object.  Start with the assumption that they do
            ** match (rc==0).  Change rc to non-zero if a discrepancy
            ** is found.
            */
            rc = sqlite3BitvecTest(null, 0) + sqlite3BitvecTest(pBitvec, sz + 1)
                 + sqlite3BitvecTest(pBitvec, 0)
                 + (int)(sqlite3BitvecSize(pBitvec) - sz);
            for (i = 1; i <= sz; i++)
            {
                if ((TESTBIT(pV, i)) != sqlite3BitvecTest(pBitvec, (u32)i))
                {
                    rc = i;
                    break;
                }
            }

            /* Free allocated structure */
bitvec_end:
            //sqlite3_free( ref pTmpSpace );
            //sqlite3_free( ref pV );
            sqlite3BitvecDestroy(ref pBitvec);
            return(rc);
        }
Beispiel #12
0
 /*
 ** Insert a new value into a RowSet.
 **
 ** The mallocFailed flag of the database connection is set if a
 ** memory allocation fails.
 */
 static void sqlite3RowSetInsert( RowSet p, i64 rowid )
 {
   RowSetEntry pEntry;       /* The new entry */
   RowSetEntry pLast;        /* The last prior entry */
   Debug.Assert( p != null );
   if ( p.nFresh == 0 )
   {
     RowSetChunk pNew;
     pNew = new RowSetChunk();//sqlite3DbMallocRaw(p.db, sizeof(*pNew));
     if ( pNew == null )
     {
       return;
     }
     pNew.pNextChunk = p.pChunk;
     p.pChunk = pNew;
     p.pFresh = pNew.aEntry;
     p.nFresh = ROWSET_ENTRY_PER_CHUNK;
   }
   p.pFresh[p.pFresh.Length - p.nFresh] = new RowSetEntry();
   pEntry = p.pFresh[p.pFresh.Length - p.nFresh];
   p.nFresh--;
   pEntry.v = rowid;
   pEntry.pRight = null;
   pLast = p.pLast;
   if ( pLast != null )
   {
     if ( p.isSorted && rowid <= pLast.v )
     {
       p.isSorted = false;
     }
     pLast.pRight = pEntry;
   }
   else
   {
     Debug.Assert( p.pEntry == null );/* Fires if INSERT after SMALLEST */
     p.pEntry = pEntry;
   }
   p.pLast = pEntry;
 }
 public static System.Collections.Concurrent.OrderablePartitioner <System.Tuple <System.Int64, System.Int64> > Create(System.Int64 fromInclusive, System.Int64 toExclusive) => throw null;
Beispiel #14
0
 public NodeThing(Id id) : base(id)
 {
 }
Beispiel #15
0
 public static void FileGet(int FileNumber, System.Int64& Value, long RecordNumber)
 {
 }
Beispiel #16
0
 public static void Input(int FileNumber, System.Int64& Value)
 {
 }
        public override void OnInspectorGUI(NavGraph target)
        {
            var graph = target as RecastGraph;

            bool preEnabled = GUI.enabled;

            System.Int64 estWidth = Mathf.RoundToInt(Mathf.Ceil(graph.forcedBoundsSize.x / graph.cellSize));
            System.Int64 estDepth = Mathf.RoundToInt(Mathf.Ceil(graph.forcedBoundsSize.z / graph.cellSize));

            // Show a warning if the number of voxels is too large
            if (estWidth * estDepth >= 1024 * 1024 || estDepth >= 1024 * 1024 || estWidth >= 1024 * 1024)
            {
                GUIStyle helpBox = GUI.skin.FindStyle("HelpBox") ?? GUI.skin.FindStyle("Box");

                Color preColor = GUI.color;
                if (estWidth * estDepth >= 2048 * 2048 || estDepth >= 2048 * 2048 || estWidth >= 2048 * 2048)
                {
                    GUI.color = Color.red;
                }
                else
                {
                    GUI.color = Color.yellow;
                }

                GUILayout.Label("Warning : Might take some time to calculate", helpBox);
                GUI.color = preColor;
            }

            GUI.enabled = false;
            EditorGUILayout.LabelField(new GUIContent("Width (voxels)", "Based on the cell size and the bounding box"), new GUIContent(estWidth.ToString()));

            EditorGUILayout.LabelField(new GUIContent("Depth (voxels)", "Based on the cell size and the bounding box"), new GUIContent(estDepth.ToString()));
            GUI.enabled = preEnabled;

            graph.cellSize = EditorGUILayout.FloatField(new GUIContent("Cell Size", "Size of one voxel in world units"), graph.cellSize);
            if (graph.cellSize < 0.001F)
            {
                graph.cellSize = 0.001F;
            }

            graph.useTiles = (UseTiles)EditorGUILayout.EnumPopup("Use Tiles", graph.useTiles ? UseTiles.UseTiles : UseTiles.DontUseTiles) == UseTiles.UseTiles;

            if (graph.useTiles)
            {
                EditorGUI.indentLevel++;
                graph.editorTileSize = EditorGUILayout.IntField(new GUIContent("Tile Size", "Size in voxels of a single tile.\n" +
                                                                               "This is the width of the tile.\n" +
                                                                               "\n" +
                                                                               "A large tile size can be faster to initially scan (but beware of out of memory issues if you try with a too large tile size in a large world)\n" +
                                                                               "smaller tile sizes are (much) faster to update.\n" +
                                                                               "\n" +
                                                                               "Different tile sizes can affect the quality of paths. It is often good to split up huge open areas into several tiles for\n" +
                                                                               "better quality paths, but too small tiles can lead to effects looking like invisible obstacles."), graph.editorTileSize);
                EditorGUI.indentLevel--;
            }

            graph.minRegionSize = EditorGUILayout.FloatField(new GUIContent("Min Region Size", "Small regions will be removed. In square world units"), graph.minRegionSize);

            graph.walkableHeight = EditorGUILayout.FloatField(new GUIContent("Walkable Height", "Minimum distance to the roof for an area to be walkable"), graph.walkableHeight);
            graph.walkableHeight = Mathf.Max(graph.walkableHeight, 0);

            graph.walkableClimb = EditorGUILayout.FloatField(new GUIContent("Walkable Climb", "How high can the character climb"), graph.walkableClimb);

            // A walkableClimb higher than this can cause issues when generating the navmesh since then it can in some cases
            // Both be valid for a character to walk under an obstacle and climb up on top of it (and that cannot be handled with a navmesh without links)
            if (graph.walkableClimb >= graph.walkableHeight)
            {
                graph.walkableClimb = graph.walkableHeight;
                EditorGUILayout.HelpBox("Walkable climb should be less than walkable height. Clamping to " + graph.walkableHeight + ".", MessageType.Warning);
            }
            else if (graph.walkableClimb < 0)
            {
                graph.walkableClimb = 0;
            }

            graph.characterRadius = EditorGUILayout.FloatField(new GUIContent("Character Radius", "Radius of the character. It's good to add some margin.\nIn world units."), graph.characterRadius);
            graph.characterRadius = Mathf.Max(graph.characterRadius, 0);

            if (graph.characterRadius < graph.cellSize * 2)
            {
                EditorGUILayout.HelpBox("For best navmesh quality, it is recommended to keep the character radius at least 2 times as large as the cell size. Smaller cell sizes will give you higher quality navmeshes, but it will take more time to scan the graph.", MessageType.Warning);
            }

            graph.maxSlope      = EditorGUILayout.Slider(new GUIContent("Max Slope", "Approximate maximum slope"), graph.maxSlope, 0F, 90F);
            graph.maxEdgeLength = EditorGUILayout.FloatField(new GUIContent("Max Border Edge Length", "Maximum length of one border edge in the completed navmesh before it is split. A lower value can often yield better quality graphs, but don't use so low values so that you get a lot of thin triangles."), graph.maxEdgeLength);
            graph.maxEdgeLength = graph.maxEdgeLength < graph.cellSize ? graph.cellSize : graph.maxEdgeLength;

            graph.contourMaxError = EditorGUILayout.FloatField(new GUIContent("Max Edge Error", "Amount of simplification to apply to edges.\nIn world units."), graph.contourMaxError);

            graph.rasterizeTerrain = EditorGUILayout.Toggle(new GUIContent("Rasterize Terrain", "Should a rasterized terrain be included"), graph.rasterizeTerrain);
            if (graph.rasterizeTerrain)
            {
                EditorGUI.indentLevel++;
                graph.rasterizeTrees = EditorGUILayout.Toggle(new GUIContent("Rasterize Trees", "Rasterize tree colliders on terrains. " +
                                                                             "If the tree prefab has a collider, that collider will be rasterized. " +
                                                                             "Otherwise a simple box collider will be used and the script will " +
                                                                             "try to adjust it to the tree's scale, it might not do a very good job though so " +
                                                                             "an attached collider is preferable."), graph.rasterizeTrees);
                if (graph.rasterizeTrees)
                {
                    EditorGUI.indentLevel++;
                    graph.colliderRasterizeDetail = EditorGUILayout.FloatField(new GUIContent("Collider Detail", "Controls the detail of the generated collider meshes. " +
                                                                                              "Increasing does not necessarily yield better navmeshes, but lowering will speed up scan.\n" +
                                                                                              "Spheres and capsule colliders will be converted to meshes in order to be able to rasterize them, a higher value will increase the number of triangles in those meshes."), graph.colliderRasterizeDetail);
                    EditorGUI.indentLevel--;
                }

                graph.terrainSampleSize = EditorGUILayout.IntField(new GUIContent("Terrain Sample Size", "Size of terrain samples. A lower value is better, but slower"), graph.terrainSampleSize);
                graph.terrainSampleSize = graph.terrainSampleSize < 1 ? 1 : graph.terrainSampleSize;                //Clamp to at least 1
                EditorGUI.indentLevel--;
            }

            graph.rasterizeMeshes    = EditorGUILayout.Toggle(new GUIContent("Rasterize Meshes", "Should meshes be rasterized and used for building the navmesh"), graph.rasterizeMeshes);
            graph.rasterizeColliders = EditorGUILayout.Toggle(new GUIContent("Rasterize Colliders", "Should colliders be rasterized and used for building the navmesh"), graph.rasterizeColliders);
            if (graph.rasterizeColliders)
            {
                EditorGUI.indentLevel++;
                graph.colliderRasterizeDetail = EditorGUILayout.FloatField(new GUIContent("Collider Detail", "Controls the detail of the generated collider meshes. " +
                                                                                          "Increasing does not necessarily yield better navmeshes, but lowering will speed up scan.\n" +
                                                                                          "Spheres and capsule colliders will be converted to meshes in order to be able to rasterize them, a higher value will increase the number of triangles in those meshes."), graph.colliderRasterizeDetail);
                EditorGUI.indentLevel--;
            }

            if (graph.rasterizeMeshes && graph.rasterizeColliders)
            {
                EditorGUILayout.HelpBox("You are rasterizing both meshes and colliders, this might just be duplicating the work that is done if the colliders and meshes are similar in shape. You can use the RecastMeshObj component" +
                                        " to always include some specific objects regardless of what the above settings are set to.", MessageType.Info);
            }

            Separator();

            graph.forcedBoundsCenter = EditorGUILayout.Vector3Field("Center", graph.forcedBoundsCenter);
            graph.forcedBoundsSize   = EditorGUILayout.Vector3Field("Size", graph.forcedBoundsSize);
            // Make sure the bounding box is not infinitely thin along any axis
            graph.forcedBoundsSize = Vector3.Max(graph.forcedBoundsSize, Vector3.one * 0.001f);
            graph.rotation         = EditorGUILayout.Vector3Field("Rotation", graph.rotation);

            if (GUILayout.Button(new GUIContent("Snap bounds to scene", "Will snap the bounds of the graph to exactly contain all meshes that the bounds currently touches")))
            {
                graph.SnapForceBoundsToScene();
                GUI.changed = true;
            }

            Separator();

            EditorGUILayout.HelpBox("Objects contained in any of these masks will be rasterized", MessageType.None);
            graph.mask     = EditorGUILayoutx.LayerMaskField("Layer Mask", graph.mask);
            tagMaskFoldout = EditorGUILayoutx.UnityTagMaskList(new GUIContent("Tag Mask"), tagMaskFoldout, graph.tagMask);

            graph.enableNavmeshCutting = EditorGUILayout.Toggle(new GUIContent("Affected by navmesh cuts", "Makes this graph affected by NavmeshCut and NavmeshAdd components. See the documentation for more info."), graph.enableNavmeshCutting);

            Separator();

            GUILayout.BeginHorizontal();
            GUILayout.Space(18);
            graph.showMeshSurface     = GUILayout.Toggle(graph.showMeshSurface, new GUIContent("Show surface", "Toggles gizmos for drawing the surface of the mesh"), EditorStyles.miniButtonLeft);
            graph.showMeshOutline     = GUILayout.Toggle(graph.showMeshOutline, new GUIContent("Show outline", "Toggles gizmos for drawing an outline of the nodes"), EditorStyles.miniButtonMid);
            graph.showNodeConnections = GUILayout.Toggle(graph.showNodeConnections, new GUIContent("Show connections", "Toggles gizmos for drawing node connections"), EditorStyles.miniButtonRight);
            GUILayout.EndHorizontal();


            Separator();
            GUILayout.Label(new GUIContent("Advanced"), EditorStyles.boldLabel);

            if (GUILayout.Button("Export to .obj file"))
            {
                ExportToFile(graph);
            }

            graph.relevantGraphSurfaceMode = (RecastGraph.RelevantGraphSurfaceMode)EditorGUILayout.EnumPopup(new GUIContent("Relevant Graph Surface Mode",
                                                                                                                            "Require every region to have a RelevantGraphSurface component inside it.\n" +
                                                                                                                            "A RelevantGraphSurface component placed in the scene specifies that\n" +
                                                                                                                            "the navmesh region it is inside should be included in the navmesh.\n\n" +
                                                                                                                            "If this is set to OnlyForCompletelyInsideTile\n" +
                                                                                                                            "a navmesh region is included in the navmesh if it\n" +
                                                                                                                            "has a RelevantGraphSurface inside it, or if it\n" +
                                                                                                                            "is adjacent to a tile border. This can leave some small regions\n" +
                                                                                                                            "which you didn't want to have included because they are adjacent\n" +
                                                                                                                            "to tile borders, but it removes the need to place a component\n" +
                                                                                                                            "in every single tile, which can be tedious (see below).\n\n" +
                                                                                                                            "If this is set to RequireForAll\n" +
                                                                                                                            "a navmesh region is included only if it has a RelevantGraphSurface\n" +
                                                                                                                            "inside it. Note that even though the navmesh\n" +
                                                                                                                            "looks continous between tiles, the tiles are computed individually\n" +
                                                                                                                            "and therefore you need a RelevantGraphSurface component for each\n" +
                                                                                                                            "region and for each tile."),
                                                                                                             graph.relevantGraphSurfaceMode);

            graph.nearestSearchOnlyXZ = EditorGUILayout.Toggle(new GUIContent("Nearest node queries in XZ space",
                                                                              "Recomended for single-layered environments.\nFaster but can be inacurate esp. in multilayered contexts."), graph.nearestSearchOnlyXZ);

            if (graph.nearestSearchOnlyXZ && (Mathf.Abs(graph.rotation.x) > 1 || Mathf.Abs(graph.rotation.z) > 1))
            {
                EditorGUILayout.HelpBox("Nearest node queries in XZ space is not recommended for rotated graphs since XZ space no longer corresponds to the ground plane", MessageType.Warning);
            }
        }
Beispiel #18
0
 public static unsafe void PutInt64(Int64 x, byte[] b, int pos)
 {
     Debug.Assert(b.Length - pos  >= sizeof(Int64));
       fixed (byte* sb = b) {
     *((Int64*)(sb + pos)) = x;
       }
 }
Beispiel #19
0
 static int sqlite3OsFileControl(sqlite3_file id, u32 op, ref sqlite3_int64 pArg)
 {
     return(id.pMethods.xFileControl(id, (int)op, ref pArg));
 }
Beispiel #20
0
		private Package FindPackageById(IEnumerable<Package> packageList, Id id)
		{
			if (id == 0)
				return null;
			foreach (Package package in packageList)
			{
				if (package.Id == id)
					return package;
				Package childPackage = FindPackageById(package.Packages, id);
				if (childPackage != null)
					return childPackage;
			}

			return null;
		}
 /// <summary>
 /// sets the length of the stream.
 /// </summary>
 /// <param name="value"></param>
 public override void  SetLength(System.Int64 value)
 {
 }
Beispiel #22
0
 static int sqlite3OsCurrentTimeInt64( sqlite3_vfs pVfs, ref sqlite3_int64 pTimeOut )
 {
   int rc;
   /* IMPLEMENTATION-OF: R-49045-42493 SQLite will use the xCurrentTimeInt64()
   ** method to get the current date and time if that method is available
   ** (if iVersion is 2 or greater and the function pointer is not NULL) and
   ** will fall back to xCurrentTime() if xCurrentTimeInt64() is
   ** unavailable.
   */
   if ( pVfs.iVersion >= 2 && pVfs.xCurrentTimeInt64 != null )
   {
     rc = pVfs.xCurrentTimeInt64( pVfs, ref pTimeOut );
   }
   else
   {
     double r = 0;
     rc = pVfs.xCurrentTime( pVfs, ref r );
     pTimeOut = (sqlite3_int64)( r * 86400000.0 );
   }
   return rc;
 }
Beispiel #23
0
        /// <summary>
        /// add an item with parameters of .net value type for each property
        /// </summary>
        public void Add(
            System.Int64 id
            , System.Int64 parentId
            , System.String name
            , System.Boolean isSystemBuiltIn
            , System.Guid uniqueIdentifier
            , System.DateTime createdDateTime
            , System.String charColumn
            , System.String varcharColumn
            , System.String textColumn
            , System.String ncharColumn
            , System.String nvarcharColumn
            , System.String ntextColumn
            , System.Boolean bitColumn
            , System.Byte[] binaryColumn
            , System.Byte[] varbinaryColumn
            , System.Byte[] imageColumn
            , System.Byte tinyintColumn
            , System.Int16 smallintColumn
            , System.Int32 intColumn
            , System.Int64 bigintColumn
            , System.Decimal decimalColumn
            , System.Decimal numericColumn
            , System.Decimal smallmoneyColumn
            , System.Decimal moneyColumn
            , System.Single floatColumn
            , System.Single realColumn
            , System.DateTime datetimeColumn
            , System.DateTime datetime2Column
            , System.DateTime smalldatetimeColumn
            , System.DateTime dateColumn
            , System.TimeSpan timeColumn
            , System.Guid uniqueidentifierColumn)
        {
            Organization _Item = new Organization(
                id
                , parentId
                , name
                , isSystemBuiltIn
                , uniqueIdentifier
                , createdDateTime
                , charColumn
                , varcharColumn
                , textColumn
                , ncharColumn
                , nvarcharColumn
                , ntextColumn
                , bitColumn
                , binaryColumn
                , varbinaryColumn
                , imageColumn
                , tinyintColumn
                , smallintColumn
                , intColumn
                , bigintColumn
                , decimalColumn
                , numericColumn
                , smallmoneyColumn
                , moneyColumn
                , floatColumn
                , realColumn
                , datetimeColumn
                , datetime2Column
                , smalldatetimeColumn
                , dateColumn
                , timeColumn
                , uniqueidentifierColumn);

            this.Add(_Item);
        }
Beispiel #24
0
 /*
 ** Extract the smallest element from the RowSet.
 ** Write the element into *pRowid.  Return 1 on success.  Return
 ** 0 if the RowSet is already empty.
 **
 ** After this routine has been called, the sqlite3RowSetInsert()
 ** routine may not be called again.
 */
 static int sqlite3RowSetNext( RowSet p, ref i64 pRowid )
 {
   rowSetToList( p );
   if ( p.pEntry != null )
   {
     pRowid = p.pEntry.v;
     p.pEntry = p.pEntry.pRight;
     if ( p.pEntry == null )
     {
       sqlite3RowSetClear( p );
     }
     return 1;
   }
   else
   {
     return 0;
   }
 }
Beispiel #25
0
 public Int64()
 {
     data = 0;
 }
Beispiel #26
0
 /** 設定。
  */
 public void Reset(System.Int64 a_raw)
 {
     this.valuetype = ValueType.SignedNumber;
     this.raw       = (SIGNED_NUMBER_TYPE)a_raw;
 }
 public virtual void Emit(System.Reflection.Emit.OpCode opcode, System.Int64 arg) => throw null;
 /// <summary>
 /// seek to an specific place in the stream.
 /// </summary>
 public override System.Int64 Seek(System.Int64 offset, System.IO.SeekOrigin origin)
 {
     return(0);
 }
Beispiel #29
0
 /// <summary>
 /// Specifies a column alias of a specified value.
 /// </summary>
 /// <param name="value">A value.</param>
 /// <param name="alias">Is an alias. It is recommended that the alias follows the rules for regular SQL identifiers.</param>
 public static ColumnAsChainer As(this System.Int64 value, string alias)
 {
     return(new ColumnAsChainer(value, alias));
 }
Beispiel #30
0
 private static extern void _gameCenterReportScore(System.Int64 score, System.UInt64 context, string leaderboardId);
Beispiel #31
0
 /// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/ctor2/*' />
 public SqlFileStream(string path, byte[] transactionContext, System.IO.FileAccess access, System.IO.FileOptions options, System.Int64 allocationSize)
 {
 }
Beispiel #32
0
        // Returns &inputBuffer[inputLength] if the input buffer is valid.
        /// <summary>
        /// Given an input buffer <paramref name="pInputBuffer"/> of char length <paramref name="inputLength"/>,
        /// returns a pointer to where the first invalid data appears in <paramref name="pInputBuffer"/>.
        /// </summary>
        /// <remarks>
        /// Returns a pointer to the end of <paramref name="pInputBuffer"/> if the buffer is well-formed.
        /// </remarks>
        public static char *GetPointerToFirstInvalidChar(char *pInputBuffer, int inputLength, out long utf8CodeUnitCountAdjustment, out int scalarCountAdjustment)
        {
            Debug.Assert(inputLength >= 0, "Input length must not be negative.");
            Debug.Assert(pInputBuffer != null || inputLength == 0, "Input length must be zero if input buffer pointer is null.");

            // First, we'll handle the common case of all-ASCII. If this is able to
            // consume the entire buffer, we'll skip the remainder of this method's logic.

            int numAsciiCharsConsumedJustNow = (int)ASCIIUtility.GetIndexOfFirstNonAsciiChar(pInputBuffer, (uint)inputLength);

            Debug.Assert(0 <= numAsciiCharsConsumedJustNow && numAsciiCharsConsumedJustNow <= inputLength);

            pInputBuffer += (uint)numAsciiCharsConsumedJustNow;
            inputLength  -= numAsciiCharsConsumedJustNow;

            if (inputLength == 0)
            {
                utf8CodeUnitCountAdjustment = 0;
                scalarCountAdjustment       = 0;
                return(pInputBuffer);
            }

            // If we got here, it means we saw some non-ASCII data, so within our
            // vectorized code paths below we'll handle all non-surrogate UTF-16
            // code points branchlessly. We'll only branch if we see surrogates.
            //
            // We still optimistically assume the data is mostly ASCII. This means that the
            // number of UTF-8 code units and the number of scalars almost matches the number
            // of UTF-16 code units. As we go through the input and find non-ASCII
            // characters, we'll keep track of these "adjustment" fixups. To get the
            // total number of UTF-8 code units required to encode the input data, add
            // the UTF-8 code unit count adjustment to the number of UTF-16 code units
            // seen.  To get the total number of scalars present in the input data,
            // add the scalar count adjustment to the number of UTF-16 code units seen.

            long tempUtf8CodeUnitCountAdjustment = 0;
            int  tempScalarCountAdjustment       = 0;

            if (Sse2.IsSupported)
            {
                if (inputLength >= Vector128 <ushort> .Count)
                {
                    Vector128 <ushort> vector0080 = Vector128.Create((ushort)0x80);
                    Vector128 <ushort> vectorA800 = Vector128.Create((ushort)0xA800);
                    Vector128 <short>  vector8800 = Vector128.Create(unchecked ((short)0x8800));
                    Vector128 <ushort> vectorZero = Vector128 <ushort> .Zero;

                    do
                    {
                        Vector128 <ushort> utf16Data = Sse2.LoadVector128((ushort *)pInputBuffer); // unaligned
                        uint mask;

                        // The 'charIsNonAscii' vector we're about to build will have the 0x8000 or the 0x0080
                        // bit set (but not both!) only if the corresponding input char is non-ASCII. Which of
                        // the two bits is set doesn't matter, as will be explained in the diagram a few lines
                        // below.

                        Vector128 <ushort> charIsNonAscii;
                        if (Sse41.IsSupported)
                        {
                            // sets 0x0080 bit if corresponding char element is >= 0x0080
                            charIsNonAscii = Sse41.Min(utf16Data, vector0080);
                        }
                        else
                        {
                            // sets 0x8000 bit if corresponding char element is >= 0x0080
                            charIsNonAscii = Sse2.AndNot(vector0080, Sse2.Subtract(vectorZero, Sse2.ShiftRightLogical(utf16Data, 7)));
                        }

#if DEBUG
                        // Quick check to ensure we didn't accidentally set both 0x8080 bits in any element.
                        uint debugMask = (uint)Sse2.MoveMask(charIsNonAscii.AsByte());
                        Debug.Assert((debugMask & (debugMask << 1)) == 0, "Two set bits shouldn't occur adjacent to each other in this mask.");
#endif // DEBUG

                        // sets 0x8080 bits if corresponding char element is >= 0x0800
                        Vector128 <ushort> charIsThreeByteUtf8Encoded = Sse2.Subtract(vectorZero, Sse2.ShiftRightLogical(utf16Data, 11));

                        mask = (uint)Sse2.MoveMask(Sse2.Or(charIsNonAscii, charIsThreeByteUtf8Encoded).AsByte());

                        // Each odd bit of mask will be 1 only if the char was >= 0x0080,
                        // and each even bit of mask will be 1 only if the char was >= 0x0800.
                        //
                        // Example for UTF-16 input "[ 0123 ] [ 1234 ] ...":
                        //
                        //            ,-- set if char[1] is non-ASCII
                        //            |   ,-- set if char[0] is non-ASCII
                        //            v   v
                        // mask = ... 1 1 1 0
                        //              ^   ^-- set if char[0] is >= 0x0800
                        //              `-- set if char[1] is >= 0x0800
                        //
                        // (If the SSE4.1 code path is taken above, the meaning of the odd and even
                        // bits are swapped, but the logic below otherwise holds.)
                        //
                        // This means we can popcnt the number of set bits, and the result is the
                        // number of *additional* UTF-8 bytes that each UTF-16 code unit requires as
                        // it expands. This results in the wrong count for UTF-16 surrogate code
                        // units (we just counted that each individual code unit expands to 3 bytes,
                        // but in reality a well-formed UTF-16 surrogate pair expands to 4 bytes).
                        // We'll handle this in just a moment.
                        //
                        // For now, compute the popcnt but squirrel it away. We'll fold it in to the
                        // cumulative UTF-8 adjustment factor once we determine that there are no
                        // unpaired surrogates in our data. (Unpaired surrogates would invalidate
                        // our computed result and we'd have to throw it away.)

                        uint popcnt = (uint)BitOperations.PopCount(mask);

                        // Surrogates need to be special-cased for two reasons: (a) we need
                        // to account for the fact that we over-counted in the addition above;
                        // and (b) they require separate validation.

                        utf16Data = Sse2.Add(utf16Data, vectorA800);
                        mask      = (uint)Sse2.MoveMask(Sse2.CompareLessThan(utf16Data.AsInt16(), vector8800).AsByte());

                        if (mask != 0)
                        {
                            // There's at least one UTF-16 surrogate code unit present.
                            // Since we performed a pmovmskb operation on the result of a 16-bit pcmpgtw,
                            // the resulting bits of 'mask' will occur in pairs:
                            // - 00 if the corresponding UTF-16 char was not a surrogate code unit;
                            // - 11 if the corresponding UTF-16 char was a surrogate code unit.
                            //
                            // A UTF-16 high/low surrogate code unit has the bit pattern [ 11011q## ######## ],
                            // where # is any bit; q = 0 represents a high surrogate, and q = 1 represents
                            // a low surrogate. Since we added 0xA800 in the vectorized operation above,
                            // our surrogate pairs will now have the bit pattern [ 10000q## ######## ].
                            // If we logical right-shift each word by 3, we'll end up with the bit pattern
                            // [ 00010000 q####### ], which means that we can immediately use pmovmskb to
                            // determine whether a given char was a high or a low surrogate.
                            //
                            // Therefore the resulting bits of 'mask2' will occur in pairs:
                            // - 00 if the corresponding UTF-16 char was a high surrogate code unit;
                            // - 01 if the corresponding UTF-16 char was a low surrogate code unit;
                            // - ## (garbage) if the corresponding UTF-16 char was not a surrogate code unit.
                            //   Since 'mask' already has 00 in these positions (since the corresponding char
                            //   wasn't a surrogate), "mask AND mask2 == 00" holds for these positions.

                            uint mask2 = (uint)Sse2.MoveMask(Sse2.ShiftRightLogical(utf16Data, 3).AsByte());

                            // 'lowSurrogatesMask' has its bits occur in pairs:
                            // - 01 if the corresponding char was a low surrogate char,
                            // - 00 if the corresponding char was a high surrogate char or not a surrogate at all.

                            uint lowSurrogatesMask = mask2 & mask;

                            // 'highSurrogatesMask' has its bits occur in pairs:
                            // - 01 if the corresponding char was a high surrogate char,
                            // - 00 if the corresponding char was a low surrogate char or not a surrogate at all.

                            uint highSurrogatesMask = (mask2 ^ 0b_0101_0101_0101_0101u /* flip all even-numbered bits 00 <-> 01 */) & mask;

                            Debug.Assert((highSurrogatesMask & lowSurrogatesMask) == 0,
                                         "A char cannot simultaneously be both a high and a low surrogate char.");

                            Debug.Assert(((highSurrogatesMask | lowSurrogatesMask) & 0b_1010_1010_1010_1010u) == 0,
                                         "Only even bits (no odd bits) of the masks should be set.");

                            // Now check that each high surrogate is followed by a low surrogate and that each
                            // low surrogate follows a high surrogate. We make an exception for the case where
                            // the final char of the vector is a high surrogate, since we can't perform validation
                            // on it until the next iteration of the loop when we hope to consume the matching
                            // low surrogate.

                            highSurrogatesMask <<= 2;
                            if ((ushort)highSurrogatesMask != lowSurrogatesMask)
                            {
                                goto NonVectorizedLoop; // error: mismatched surrogate pair; break out of vectorized logic
                            }

                            if (highSurrogatesMask > ushort.MaxValue)
                            {
                                // There was a standalone high surrogate at the end of the vector.
                                // We'll adjust our counters so that we don't consider this char consumed.

                                highSurrogatesMask = (ushort)highSurrogatesMask; // don't allow stray high surrogate to be consumed by popcnt
                                popcnt            -= 2;                          // the '0xC000_0000' bits in the original mask are shifted out and discarded, so account for that here
                                pInputBuffer--;
                                inputLength++;
                            }

                            // If we're 64-bit, we can perform the zero-extension of the surrogate pairs count for
                            // free right now, saving the extension step a few lines below. If we're 32-bit, the
                            // convertion to nuint immediately below is a no-op, and we'll pay the cost of the real
                            // 64 -bit extension a few lines below.
                            nuint surrogatePairsCountNuint = (uint)BitOperations.PopCount(highSurrogatesMask);

                            // 2 UTF-16 chars become 1 Unicode scalar

                            tempScalarCountAdjustment -= (int)surrogatePairsCountNuint;

                            // Since each surrogate code unit was >= 0x0800, we eagerly assumed
                            // it'd be encoded as 3 UTF-8 code units, so our earlier popcnt computation
                            // assumes that the pair is encoded as 6 UTF-8 code units. Since each
                            // pair is in reality only encoded as 4 UTF-8 code units, we need to
                            // perform this adjustment now.

                            if (IntPtr.Size == 8)
                            {
                                // Since we've already zero-extended surrogatePairsCountNuint, we can directly
                                // sub + sub. It's more efficient than shl + sub.
                                tempUtf8CodeUnitCountAdjustment -= (long)surrogatePairsCountNuint;
                                tempUtf8CodeUnitCountAdjustment -= (long)surrogatePairsCountNuint;
                            }
                            else
                            {
                                // Take the hit of the 64-bit extension now.
                                tempUtf8CodeUnitCountAdjustment -= 2 * (uint)surrogatePairsCountNuint;
                            }
                        }

                        tempUtf8CodeUnitCountAdjustment += popcnt;
                        pInputBuffer += Vector128 <ushort> .Count;
                        inputLength  -= Vector128 <ushort> .Count;
                    } while (inputLength >= Vector128 <ushort> .Count);
                }
            }
            else if (Vector.IsHardwareAccelerated)
            {
                if (inputLength >= Vector <ushort> .Count)
                {
                    Vector <ushort> vector0080 = new Vector <ushort>(0x0080);
                    Vector <ushort> vector0400 = new Vector <ushort>(0x0400);
                    Vector <ushort> vector0800 = new Vector <ushort>(0x0800);
                    Vector <ushort> vectorD800 = new Vector <ushort>(0xD800);

                    do
                    {
                        // The 'twoOrMoreUtf8Bytes' and 'threeOrMoreUtf8Bytes' vectors will contain
                        // elements whose values are 0xFFFF (-1 as signed word) iff the corresponding
                        // UTF-16 code unit was >= 0x0080 and >= 0x0800, respectively. By summing these
                        // vectors, each element of the sum will contain one of three values:
                        //
                        // 0x0000 ( 0) = original char was 0000..007F
                        // 0xFFFF (-1) = original char was 0080..07FF
                        // 0xFFFE (-2) = original char was 0800..FFFF
                        //
                        // We'll negate them to produce a value 0..2 for each element, then sum all the
                        // elements together to produce the number of *additional* UTF-8 code units
                        // required to represent this UTF-16 data. This is similar to the popcnt step
                        // performed by the SSE2 code path. This will overcount surrogates, but we'll
                        // handle that shortly.

                        Vector <ushort> utf16Data            = Unsafe.ReadUnaligned <Vector <ushort> >(pInputBuffer);
                        Vector <ushort> twoOrMoreUtf8Bytes   = Vector.GreaterThanOrEqual(utf16Data, vector0080);
                        Vector <ushort> threeOrMoreUtf8Bytes = Vector.GreaterThanOrEqual(utf16Data, vector0800);
                        Vector <nuint>  sumVector            = (Vector <nuint>)(Vector <ushort> .Zero - twoOrMoreUtf8Bytes - threeOrMoreUtf8Bytes);

                        // We'll try summing by a natural word (rather than a 16-bit word) at a time,
                        // which should halve the number of operations we must perform.

                        nuint popcnt = 0;
                        for (int i = 0; i < Vector <nuint> .Count; i++)
                        {
                            popcnt += sumVector[i];
                        }

                        uint popcnt32 = (uint)popcnt;
                        if (IntPtr.Size == 8)
                        {
                            popcnt32 += (uint)(popcnt >> 32);
                        }

                        // As in the SSE4.1 paths, compute popcnt but don't fold it in until we
                        // know there aren't any unpaired surrogates in the input data.

                        popcnt32 = (ushort)popcnt32 + (popcnt32 >> 16);

                        // Now check for surrogates.

                        utf16Data -= vectorD800;
                        Vector <ushort> surrogateChars = Vector.LessThan(utf16Data, vector0800);
                        if (surrogateChars != Vector <ushort> .Zero)
                        {
                            // There's at least one surrogate (high or low) UTF-16 code unit in
                            // the vector. We'll build up additional vectors: 'highSurrogateChars'
                            // and 'lowSurrogateChars', where the elements are 0xFFFF iff the original
                            // UTF-16 code unit was a high or low surrogate, respectively.

                            Vector <ushort> highSurrogateChars = Vector.LessThan(utf16Data, vector0400);
                            Vector <ushort> lowSurrogateChars  = Vector.AndNot(surrogateChars, highSurrogateChars);

                            // We want to make sure that each high surrogate code unit is followed by
                            // a low surrogate code unit and each low surrogate code unit follows a
                            // high surrogate code unit. Since we don't have an equivalent of pmovmskb
                            // or palignr available to us, we'll do this as a loop. We won't look at
                            // the very last high surrogate char element since we don't yet know if
                            // the next vector read will have a low surrogate char element.

                            if (lowSurrogateChars[0] != 0)
                            {
                                goto Error; // error: start of buffer contains standalone low surrogate char
                            }

                            ushort surrogatePairsCount = 0;
                            for (int i = 0; i < Vector <ushort> .Count - 1; i++)
                            {
                                surrogatePairsCount -= highSurrogateChars[i]; // turns into +1 or +0
                                if (highSurrogateChars[i] != lowSurrogateChars[i + 1])
                                {
                                    goto NonVectorizedLoop; // error: mismatched surrogate pair; break out of vectorized logic
                                }
                            }

                            if (highSurrogateChars[Vector <ushort> .Count - 1] != 0)
                            {
                                // There was a standalone high surrogate at the end of the vector.
                                // We'll adjust our counters so that we don't consider this char consumed.

                                pInputBuffer--;
                                inputLength++;
                                popcnt32 -= 2;
                            }

                            nint surrogatePairsCountNint = (nint)surrogatePairsCount; // zero-extend to native int size

                            // 2 UTF-16 chars become 1 Unicode scalar

                            tempScalarCountAdjustment -= (int)surrogatePairsCountNint;

                            // Since each surrogate code unit was >= 0x0800, we eagerly assumed
                            // it'd be encoded as 3 UTF-8 code units. Each surrogate half is only
                            // encoded as 2 UTF-8 code units (for 4 UTF-8 code units total),
                            // so we'll adjust this now.

                            tempUtf8CodeUnitCountAdjustment -= surrogatePairsCountNint;
                            tempUtf8CodeUnitCountAdjustment -= surrogatePairsCountNint;
                        }

                        tempUtf8CodeUnitCountAdjustment += popcnt32;
                        pInputBuffer += Vector <ushort> .Count;
                        inputLength  -= Vector <ushort> .Count;
                    } while (inputLength >= Vector <ushort> .Count);
                }
            }

NonVectorizedLoop:

            // Vectorization isn't supported on our current platform, or the input was too small to benefit
            // from vectorization, or we saw invalid UTF-16 data in the vectorized code paths and need to
            // drain remaining valid chars before we report failure.

            for (; inputLength > 0; pInputBuffer++, inputLength--)
            {
                uint thisChar = pInputBuffer[0];
                if (thisChar <= 0x7F)
                {
                    continue;
                }

                // Bump adjustment by +1 for U+0080..U+07FF; by +2 for U+0800..U+FFFF.
                // This optimistically assumes no surrogates, which we'll handle shortly.

                tempUtf8CodeUnitCountAdjustment += (thisChar + 0x0001_F800u) >> 16;

                if (!UnicodeUtility.IsSurrogateCodePoint(thisChar))
                {
                    continue;
                }

                // Found a surrogate char. Back out the adjustment we made above, then
                // try to consume the entire surrogate pair all at once. We won't bother
                // trying to interpret the surrogate pair as a scalar value; we'll only
                // validate that its bit pattern matches what's expected for a surrogate pair.

                tempUtf8CodeUnitCountAdjustment -= 2;

                if (inputLength == 1)
                {
                    goto Error; // input buffer too small to read a surrogate pair
                }

                thisChar = Unsafe.ReadUnaligned <uint>(pInputBuffer);
                if (((thisChar - (BitConverter.IsLittleEndian ? 0xDC00_D800u : 0xD800_DC00u)) & 0xFC00_FC00u) != 0)
                {
                    goto Error; // not a well-formed surrogate pair
                }

                tempScalarCountAdjustment--;          // 2 UTF-16 code units -> 1 scalar
                tempUtf8CodeUnitCountAdjustment += 2; // 2 UTF-16 code units -> 4 UTF-8 code units

                pInputBuffer++;                       // consumed one extra char
                inputLength--;
            }

Error:

            // Also used for normal return.

            utf8CodeUnitCountAdjustment = tempUtf8CodeUnitCountAdjustment;
            scalarCountAdjustment       = tempScalarCountAdjustment;
            return(pInputBuffer);
        }
Beispiel #33
0
 public void SetAttackUser(user_id_t uid)
 {
     m_GameRoomInfo.m_attack_user = uid;
 }
Beispiel #34
0
 static int sqlite3OsWrite(sqlite3_file id, byte[] pBuf, int amt, i64 offset)
 {
     DO_OS_MALLOC_TEST(id);
     return(id.pMethods.xWrite(id, pBuf, amt, offset));
 }
 /// <summary>Puts the specified instruction and numerical argument onto the Microsoft intermediate language (MSIL) stream of instructions.</summary>
 /// <param name="opcode">The MSIL instruction to be put onto the stream. </param>
 /// <param name="arg">The numerical argument pushed onto the stream immediately after the instruction. </param>
 /// <param name="generator">The <see cref="T:System.Reflection.Emit.XsILGenerator" /> to emit instructions from</param>
 public static XsILGenerator FluentEmit(this XsILGenerator generator, System.Reflection.Emit.OpCode opcode, System.Int64 arg)
 {
     generator.Emit(opcode, arg);
     return(generator);
 }
 /*
 ** The rowid.
 */
 static int wholenumberRowid( sqlite3_vtab_cursor cur, out sqlite_int64 pRowid )
 {
   wholenumber_cursor pCur = (wholenumber_cursor)cur;
   pRowid = pCur.iValue;
   return SQLITE_OK;
 }
Beispiel #37
0
        }     // End Sub ctr_tree_AfterSelect

        public static void AddLdapObjectAsString(string propertyName, object Iter, System.Windows.Forms.ListViewItem item)
        {
            // lastLogon	        System.__ComObject
            // lastLogoff	        System.__ComObject
            // lastLogonTimestamp	System.__ComObject

            // accountExpires	System.__ComObject
            // badPasswordTime	System.__ComObject
            // pwdLastSet	    System.__ComObject
            // lockoutTime	    System.__ComObject
            // uSNCreated	    System.__ComObject
            // uSNChanged	    System.__ComObject


            // msExchMailboxGuid	            System.Byte[]
            // msExchVersion	                System.__ComObject
            // msExchMailboxSecurityDescriptor	System.__ComObject
            // nTSecurityDescriptor	            System.__ComObject

            if (System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "lastLogon") ||
                System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "lastLogoff") ||
                System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "lastLogonTimestamp")

                || System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "pwdLastSet") ||
                System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "badPasswordTime") ||
                System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "lockoutTime")

                || System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "uSNCreated") ||
                System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "uSNChanged")

                || System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "accountExpires")

                )
            {
                // http://social.technet.microsoft.com/wiki/contents/articles/22461.understanding-the-ad-account-attributes-lastlogon-lastlogontimestamp-and-lastlogondate.aspx
                // http://stackoverflow.com/questions/1602036/how-to-list-all-computers-and-the-last-time-they-were-logged-onto-in-ad
                // http://stackoverflow.com/questions/33274162/the-namespace-of-iadslargeinteger
                // Active DS Type Library

                // System.Console.WriteLine(Iter);
                // System.Console.WriteLine(str);
                try
                {
                    // SecurityDescriptor sd = (SecurityDescriptor)ent.Properties["ntSecurityDescriptor"].Value;
                    // ActiveDs.SecurityDescriptor sd = (ActiveDs.SecurityDescriptor)Iter;

                    // sd.DiscretionaryAcl
                    // ActiveDs.AccessControlList acl = (ActiveDs.AccessControlList)sd.DiscretionaryAcl;


                    //foreach (ActiveDs.AccessControlEntry ace in (System.Collections.IEnumerable)acl)
                    //{
                    //    System.Console.WriteLine("Trustee: {0}", ace.Trustee);
                    //    System.Console.WriteLine("AccessMask: {0}", ace.AccessMask);
                    //    System.Console.WriteLine("Access Type: {0}", ace.AceType);
                    //}



                    // ActiveDs.IADsLargeInteger ISomeAdTime = (ActiveDs.IADsLargeInteger)Iter;
                    // long lngSomeAdTime = (long)ISomeAdTime.HighPart << 32 | (uint)ISomeAdTime.LowPart;

                    // IADsLargeInteger noActiveDsSomeTime = (IADsLargeInteger)Iter;
                    // System.Console.WriteLine(noActiveDsSomeTime);

                    long lngSomeAdTime = ConvertLargeIntegerToLong(Iter);

                    System.DateTime someAdTime = System.DateTime.MaxValue;

                    if (lngSomeAdTime == long.MaxValue || lngSomeAdTime <= 0 || System.DateTime.MaxValue.ToFileTime() <= lngSomeAdTime)
                    {
                        someAdTime = System.DateTime.MaxValue;
                    }
                    else
                    {
                        // someAdTime = System.DateTime.FromFileTime(lngSomeAdTime);
                        someAdTime = System.DateTime.FromFileTimeUtc(lngSomeAdTime).ToLocalTime();
                    }

                    item.SubItems.Add(someAdTime.ToString("dd.MM.yyyy HH:mm:ss"));
                }
                catch (System.Exception ex)
                {
                    item.SubItems.Add(ex.Message + System.Environment.NewLine + Iter.ToString());
                }
            }
            else if (System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "msExchRecipientTypeDetails"))
            {
                try
                {
                    long   lngSomeVersion = ConvertLargeIntegerToLong(Iter);
                    string strVersion     = lngSomeVersion.ToString();
                    // http://memphistech.net/?p=457
                    // https://blogs.technet.microsoft.com/johnbai/2013/09/11/o365-exchange-and-ad-how-msexchrecipientdisplaytype-and-msexchangerecipienttypedetails-relate-to-your-on-premises/

                    switch (lngSomeVersion)
                    {
                    case 1:
                        strVersion = "User Mailbox";
                        break;

                    case 2:
                        strVersion = "Linked Mailbox";
                        break;

                    case 4:
                        strVersion = "Shared Mailbox";
                        break;

                    case 8:
                        strVersion = "Legacy Mailbox";
                        break;

                    case 16:
                        strVersion = "Room Mailbox";
                        break;

                    case 32:
                        strVersion = "Equipment Mailbox";
                        break;

                    case 64:
                        strVersion = "Mail Contact";
                        break;

                    case 128:
                        strVersion = "Mail User";
                        break;

                    case 256:
                        strVersion = "Mail-Enabled Universal Distribution Group";
                        break;

                    case 512:
                        strVersion = "Mail-Enabled Non-Universal Distribution Group";
                        break;

                    case 1024:
                        strVersion = "Mail-Enabled Universal Security Group";
                        break;

                    case 2048:
                        strVersion = "Dynamic Distribution Group";
                        break;

                    case 4096:
                        strVersion = "Public Folder";
                        break;

                    case 8192:
                        strVersion = "System Attendant Mailbox";
                        break;

                    case 16384:
                        strVersion = "System Mailbox";
                        break;

                    case 32768:
                        strVersion = "Cross-Forest Mail Contact";
                        break;

                    case 65536:
                        strVersion = "User";
                        break;

                    case 131072:
                        strVersion = "Contact";
                        break;

                    case 262144:
                        strVersion = "Universal Distribution Group";
                        break;

                    case 524288:
                        strVersion = "Universal Security Group";
                        break;

                    case 1048576:
                        strVersion = "Non-Universal Group";
                        break;

                    case 2097152:
                        strVersion = "Disabled User";
                        break;

                    case 4194304:
                        strVersion = "Microsoft Exchange";
                        break;

                    case 8388608:
                        strVersion = "Arbitration Mailbox";
                        break;

                    case 16777216:
                        strVersion = "Mailbox Plan";
                        break;

                    case 33554432:
                        strVersion = "Linked User";
                        break;

                    case 268435456:
                        strVersion = "Room List";
                        break;

                    case 536870912:
                        strVersion = "Discovery Mailbox";
                        break;

                    case 1073741824:
                        strVersion = "Role Group";
                        break;

                    case 2147483648L:
                        strVersion = "Remote Mailbox";
                        break;

                    case 137438953472L:
                        strVersion = "Team Mailbox";
                        break;

                    default:
                        strVersion = lngSomeVersion.ToString();
                        break;
                    }

                    item.SubItems.Add(strVersion);
                }
                catch (System.Exception ex)
                {
                    item.SubItems.Add(ex.Message + System.Environment.NewLine + Iter.ToString());
                }
            }
            else if (System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "msExchRemoteRecipientType"))
            {
                try
                {
                    System.Int64 lngSomeVersion = System.Convert.ToInt64(Iter);
                    string       strVersion     = lngSomeVersion.ToString();
                    // http://memphistech.net/?p=457
                    // https://blogs.technet.microsoft.com/johnbai/2013/09/11/o365-exchange-and-ad-how-msexchrecipientdisplaytype-and-msexchangerecipienttypedetails-relate-to-your-on-premises/

                    switch (lngSomeVersion)
                    {
                    case 1:
                        strVersion = "ProvisionedMailbox (Cloud MBX)";
                        break;

                    case 2:
                        strVersion = "ProvisionedArchive (Cloud Archive)";
                        break;

                    case 3:
                        strVersion = "ProvisionedMailbox, ProvisionedArchive";
                        // (mailbox provisioned in Cloud & Archive provisioned in Cloud)* either via EMC or new-remotemailbox cmd
                        break;

                    case 4:
                        strVersion = "Migrated mailbox from on-prem";
                        break;

                    case 6:
                        strVersion = "Migrated mailbox from on-prem, ProvisionedArchive in EXO";
                        // (mailbox migrated from on-prem & archive provisioned in Cloud)
                        break;

                    case 16:
                        strVersion = "DeprovisionArchive";
                        break;

                    case 20:
                        strVersion = "DeprovisionArchive, Migrated";
                        break;

                    case 32:
                        strVersion = "RoomMailbox";
                        break;

                    case 36:
                        strVersion = "Migrated, RoomMailbox";
                        break;

                    case 64:
                        strVersion = "EquipmentMailbox";
                        break;

                    case 68:
                        strVersion = "Migrated, EquipmentMailbox";
                        break;

                    case 96:
                        strVersion = "SharedMailbox";
                        break;

                    case 100:
                        strVersion = "Migrated, Shared Mailbox in EXO";
                        break;

                    default:
                        strVersion = lngSomeVersion.ToString();
                        break;
                    }

                    item.SubItems.Add(strVersion);
                }
                catch (System.Exception ex)
                {
                    item.SubItems.Add(ex.Message + System.Environment.NewLine + Iter.ToString());
                }
            }
            else if (System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "msExchRecipientDisplayType"))
            {
                try
                {
                    System.Int64 lngSomeVersion = System.Convert.ToInt64(Iter);
                    string       strVersion     = lngSomeVersion.ToString();
                    // http://memphistech.net/?p=457

                    switch (lngSomeVersion)
                    {
                    case 0:
                        strVersion = "MailboxUser";
                        break;

                    case 1:
                        strVersion = "DistrbutionGroup";
                        break;

                    case 2:
                        strVersion = "PublicFolder";
                        break;

                    case 3:
                        strVersion = "DynamicDistributionGroup";
                        break;

                    case 4:
                        strVersion = "Organization";
                        break;

                    case 5:
                        strVersion = "PrivateDistributionList";
                        break;

                    case 6:
                        strVersion = "RemoteMailUser";
                        break;

                    case 7:
                        strVersion = "ConferenceRoomMailbox";
                        break;

                    case 8:
                        strVersion = "EquipmentMailbox";
                        break;

                    case 1073741824:
                        strVersion = "ACLableMailboxUser";
                        break;

                    case 1043741833:
                        strVersion = "SecurityDistributionGroup";
                        break;

                    case -2147483642:
                        strVersion = "SyncedMailboxUser";
                        break;

                    case -2147483391:
                        strVersion = "SyncedUDGasUDG";
                        break;

                    case -2147483386:
                        strVersion = "SyncedUDGasContact";
                        break;

                    case -2147483130:
                        strVersion = "SyncedPublicFolder";
                        break;

                    case -2147482874:
                        strVersion = "SyncedDynamicDistributionGroup";
                        break;

                    case -2147482106:
                        strVersion = "SyncedRemoteMailUser";
                        break;

                    case -2147481850:
                        strVersion = "SyncedConferenceRoomMailbox";
                        break;

                    case -2147481594:
                        strVersion = "SyncedEquipmentMailbox";
                        break;

                    case -2147481343:
                        strVersion = "SyncedUSGasUDG";
                        break;

                    case -2147481338:
                        strVersion = "SyncedUSGasContact";
                        break;

                    case -1073741818:
                        strVersion = "ACLableSyncedMailboxUser";
                        break;

                    case -1073740282:
                        strVersion = "ACLableSyncedRemoteMailUser";
                        break;

                    case -1073739514:
                        strVersion = "ACLableSyncedUSGasContact";
                        break;

                    case -1073739511:
                        strVersion = "SyncedUSGasUSG";
                        break;

                    default:
                        strVersion = lngSomeVersion.ToString();
                        break;
                    }

                    item.SubItems.Add(strVersion);
                }
                catch (System.Exception ex)
                {
                    item.SubItems.Add(ex.Message + System.Environment.NewLine + Iter.ToString());
                }
            }
            else if (System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "msExchVersion"))
            {
                try
                {
                    long   lngSomeVersion = ConvertLargeIntegerToLong(Iter);
                    string strVersion     = "";

                    // http://blogs.metcorpconsulting.com/tech/?p=1313
                    if (lngSomeVersion < 4535486012416L)
                    {
                        strVersion = "Exchange 2003 and earlier (" + lngSomeVersion.ToString() + ")";
                    }
                    else if (lngSomeVersion == 4535486012416L)
                    {
                        strVersion = "Exchange 2007 (4535486012416)";
                    }
                    else if (lngSomeVersion == 44220983382016L)
                    {
                        strVersion = "Exchange 2010 (44220983382016)";
                    }
                    else
                    {
                        strVersion = lngSomeVersion.ToString();
                    }

                    item.SubItems.Add(strVersion);
                }
                catch (System.Exception ex)
                {
                    item.SubItems.Add(ex.Message + System.Environment.NewLine + Iter.ToString());
                }
            }
            else if (System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "userCertificate")
                     // || System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "mSMQSignCertificates")
                     // || System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "mSMQDigest")
                     )
            {
                System.Security.Cryptography.X509Certificates.X509Certificate cert = new System.Security.Cryptography.X509Certificates.X509Certificate((byte[])Iter);
                item.SubItems.Add(cert.ToString());
            }
            else if (System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "objectSid"))
            {
                System.Security.Principal.SecurityIdentifier sid = new System.Security.Principal.SecurityIdentifier((byte[])Iter, 0);
                item.SubItems.Add(sid.ToString());
            }
            else if (
                System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "objectGUID") ||
                System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "msExchMailboxGuid")
                )
            {
                System.Guid guid = new System.Guid((byte[])Iter);
                item.SubItems.Add(guid.ToString());
            }
            else if (Iter != null && object.ReferenceEquals(Iter.GetType(), typeof(byte[])))
            {
                byte[] ba = (byte[])Iter;
                item.SubItems.Add("0x" + System.BitConverter.ToString(ba).Replace("-", ""));
            }
            else
            {
                item.SubItems.Add(Iter.ToString());
            }
        } // End Sub AddLdapObjectAsString
Beispiel #38
0
 internal NodeInt(Location location, lint value)
     : base(location)
 {
     this.value = value;
 }
Beispiel #39
0
 protected void FillBody(System.Byte[] bufdata, System.Int64 length)
 {
     this._buffer.BeWrite((System.UInt16)length);
     this._buffer.Write(bufdata);
 }
Beispiel #40
0
		internal Package FindPackageById(Id id)
		{
			return FindPackageById(m_RootPackage.Packages, id);
		}
Beispiel #41
0
 /// <summary>
 /// Declares the parameter using the specified value.
 /// </summary>
 /// <param name="value">Is the value whose type is used to infer the parameter type.</param>
 public static Value Param(System.Int64 value)
 {
     return(new Value(value, Parameterization.Param));
 }
Beispiel #42
0
		internal string FindImageUriById(Id id)
		{
			Package package = FindPackageById(id);
			string iconName = (package == null ? "unknown" : package.Icon);
			string imageName = iconName + ".png";
			string imageUri = UriHelper.UriImages(imageName).ToString();
			return imageUri;
		}
 /// <summary>
 /// Get the value of <see cref="System.Math.DivRem(System.Int64, System.Int64, out System.Int64)"/> for this <see cref="System.Int64"/> value.
 /// </summary>
 public static System.Int64 DivRem(this System.Int64 a, System.Int64 b, out System.Int64 result)
 {
     return(System.Math.DivRem(a, b, out result));
 }
Beispiel #44
0
 static int sqlite3OsFileControl( sqlite3_file id, u32 op, ref sqlite3_int64 pArg )
 {
   return id.pMethods.xFileControl( id, (int)op, ref pArg );
 }
 /// <summary>
 /// Get the value of <see cref="System.Math.Min(System.Int64, System.Int64)"/> for this <see cref="System.Int64"/> value.
 /// </summary>
 public static System.Int64 Min(this System.Int64 val1, System.Int64 val2)
 {
     return(System.Math.Min(val1, val2));
 }
Beispiel #46
0
 static int sqlite3OsRead( sqlite3_file id, byte[] pBuf, int amt, i64 offset )
 {
   DO_OS_MALLOC_TEST( id );
   if ( pBuf == null )
     pBuf = sqlite3Malloc( amt );
   return id.pMethods.xRead( id, pBuf, amt, offset );
 }
 /// <summary>
 /// Get the value of <see cref="System.Math.Abs(System.Int64)"/> for this <see cref="System.Int64"/> value.
 /// </summary>
 public static System.Int64 Abs(this System.Int64 value)
 {
     return(System.Math.Abs(value));
 }
 public void bufferData (GLenum target, GLsizei size, GLenum usage)
 {
 }
 /// <summary>
 /// Get the value of <see cref="System.Math.Sign(System.Int64)"/> for this <see cref="System.Int32"/> value.
 /// </summary>
 public static System.Int32 Sign(this System.Int64 value)
 {
     return(System.Math.Sign(value));
 }