Beispiel #1
0
        /// <summary>
        /// A test method. returns a number
        /// </summary>
        /// <param name="AnotherNumber">A 64 bit integer</param>
        /// <param name="SomeString"> some random string</param>
        public System.Int64 testMethod(System.Int64 ANumber, string SomeString)
        {
            System.Console.WriteLine(SomeString + "\n");

            System.Console.WriteLine(ANumber.ToString("X"));

            return(0);
        }
Beispiel #2
0
        /// <summary>
        /// <para>Converts a given <see cref='System.DateTime'/> object to DMTF format.</para>
        ///
        /// </summary>
        /// <param name='date'>A <see cref='System.DateTime'/> object representing the datetime to be converted to DMTF datetime.</param>
        /// <returns>
        /// <para>A string that represents the DMTF datetime for the given DateTime object.</para>
        /// </returns>
        /// <remarks>
        ///			<para> Date and time in WMI is represented in DMTF datetime format. This format is explained in WMI SDK documentation.
        ///				The DMTF datetime string represented will be with respect to the UTC offset of the
        ///				current timezone. The lowest precision in DMTF is microseconds and
        ///				in <see cref='System.DateTime'/> is Ticks , which is equivalent to 100 of nanoseconds.
        ///				 During conversion these Ticks are converted to microseconds and rounded
        ///				 off to the the nearest microsecond.
        ///			</para>
        /// </remarks>
        /// <example>
        ///    <code lang='C#'>
        ///	// Convert the current time in System.DateTime to DMTF format
        ///	string dmtfDateTime = ManagementDateTimeConverter.ToDmtfDateTime(DateTime.Now);
        ///    </code>
        ///    <code lang='VB'>
        ///	' Convert the current time in System.DateTime to DMTF format
        ///	Dim dmtfDateTime as String = ManagementDateTimeConverter.ToDmtfDateTime(DateTime.Now)
        ///    </code>
        /// </example>
        public static string ToDmtfDateTime(DateTime date)
        {
            string UtcString = String.Empty;

            // Fill up the UTC field in the DMTF date with the current
            // zones UTC value
            System.TimeZone curZone    = System.TimeZone.CurrentTimeZone;
            System.TimeSpan tickOffset = curZone.GetUtcOffset(date);
            long            OffsetMins = (tickOffset.Ticks / System.TimeSpan.TicksPerMinute);
            IFormatProvider frmInt32   = (IFormatProvider)CultureInfo.InvariantCulture.GetFormat(typeof(System.Int32));

            // If the offset is more than that what can be specified in DMTF format, then
            // convert the date to UniversalTime
            if (Math.Abs(OffsetMins) > MAXSIZE_UTC_DMTF)
            {
                date      = date.ToUniversalTime();
                UtcString = "+000";
            }
            else
            if ((tickOffset.Ticks >= 0))
            {
                UtcString = "+" + ((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)).ToString(frmInt32).PadLeft(3, '0');
            }
            else
            {
                string strTemp = OffsetMins.ToString(frmInt32);
                UtcString = "-" + strTemp.Substring(1, strTemp.Length - 1).PadLeft(3, '0');
            }

            string dmtfDateTime = date.Year.ToString(frmInt32).PadLeft(4, '0');

            dmtfDateTime = (dmtfDateTime + date.Month.ToString(frmInt32).PadLeft(2, '0'));
            dmtfDateTime = (dmtfDateTime + date.Day.ToString(frmInt32).PadLeft(2, '0'));
            dmtfDateTime = (dmtfDateTime + date.Hour.ToString(frmInt32).PadLeft(2, '0'));
            dmtfDateTime = (dmtfDateTime + date.Minute.ToString(frmInt32).PadLeft(2, '0'));
            dmtfDateTime = (dmtfDateTime + date.Second.ToString(frmInt32).PadLeft(2, '0'));
            dmtfDateTime = (dmtfDateTime + ".");

            // Construct a DateTime with with the precision to Second as same as the passed DateTime and so get
            // the ticks difference so that the microseconds can be calculated
            DateTime dtTemp = new DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0);

            System.Int64 microsec = ((date.Ticks - dtTemp.Ticks) * 1000) / System.TimeSpan.TicksPerMillisecond;

            // fill the microseconds field
            String strMicrosec = microsec.ToString((IFormatProvider)CultureInfo.InvariantCulture.GetFormat(typeof(System.Int64)));

            if (strMicrosec.Length > 6)
            {
                strMicrosec = strMicrosec.Substring(0, 6);
            }
            dmtfDateTime = dmtfDateTime + strMicrosec.PadLeft(6, '0');
            // adding the UTC offset
            dmtfDateTime = dmtfDateTime + UtcString;

            return(dmtfDateTime);
        }
Beispiel #3
0
        /** Convert
         */
        public static void Convert(System.Int64 a_in_value, System.Text.StringBuilder a_out_stringbuilder, ConvertToJsonStringOption a_option)
        {
            string t_string = a_in_value.ToString(Config.CULTURE);

            a_out_stringbuilder.Append(t_string);

            if ((a_option & ConvertToJsonStringOption.NoSignedNumberSuffix) == 0)
            {
                a_out_stringbuilder.Append("l");
            }
        }
        /** Convert
         */
        public static void Convert(System.Int64 a_in_value, System.Text.StringBuilder a_out_stringbuilder, ConvertToJsonStringOption a_option)
        {
            try{
                string t_string = a_in_value.ToString(Config.CULTURE);
                a_out_stringbuilder.Append(t_string);

                if ((a_option & ConvertToJsonStringOption.NoSignedNumberSuffix) == 0)
                {
                    a_out_stringbuilder.Append("l");
                }
                return;
            }catch (System.Exception t_exception) {
                Tool.DebugReThrow(t_exception);
            }

            //不明。
            Tool.Assert(false);
            return;
        }
Beispiel #5
0
        /// <summary>
        /// <para>Converts a given <see cref='System.TimeSpan'/> object to DMTF time interval.</para>
        /// </summary>
        /// <param name='timespan'> A <see cref='System.TimeSpan'/> object representing the datetime to be converted to DMTF time interval.
        /// </param>
        /// <returns>
        /// <para>A string that represents the DMTF time interval for the given TimeSpan object.</para>
        /// </returns>
        /// <remarks>
        ///			<para> Time interval in WMI is represented in DMTF datetime format. This format
        ///				is explained in WMI SDK documentation. The lowest precision in
        ///				DMTF is microseconds and in <see cref='System.TimeSpan'/> is Ticks , which is equivalent
        ///				to 100 of nanoseconds.During conversion these Ticks are converted to
        ///				microseconds and rounded off to the the nearest microsecond.
        ///			</para>
        /// </remarks>
        /// <example>
        ///    <code lang='C#'>
        ///	// Construct a Timespan object and convert it to DMTF format
        ///	System.TimeSpan ts = new System.TimeSpan(10,12,25,32,456);
        ///	String dmtfTimeInterval = ManagementDateTimeConverter.ToDmtfTimeInterval(ts);
        ///    </code>
        ///    <code lang='VB'>
        ///	// Construct a Timespan object and convert it to DMTF format
        ///	Dim ts as System.TimeSpan = new System.TimeSpan(10,12,25,32,456)
        ///	Dim dmtfTimeInterval as String = ManagementDateTimeConverter.ToDmtfTimeInterval(ts)
        ///    </code>
        /// </example>
        public static string ToDmtfTimeInterval(TimeSpan timespan)
        {
            string          dmtftimespan = timespan.Days.ToString((IFormatProvider)CultureInfo.InvariantCulture.GetFormat(typeof(System.Int32))).PadLeft(8, '0');
            IFormatProvider frmInt32     = (IFormatProvider)CultureInfo.InvariantCulture.GetFormat(typeof(System.Int32));

            // Days that can be represented is more than what can be represented
            // then throw an exception
            // and also negative timespan cannot be represented in DMTF
            if (timespan.Days > MAXDATE_INTIMESPAN || timespan < TimeSpan.Zero)
            {
                throw new System.ArgumentOutOfRangeException();
            }

            dmtftimespan = (dmtftimespan + timespan.Hours.ToString(frmInt32).PadLeft(2, '0'));
            dmtftimespan = (dmtftimespan + timespan.Minutes.ToString(frmInt32).PadLeft(2, '0'));
            dmtftimespan = (dmtftimespan + timespan.Seconds.ToString(frmInt32).PadLeft(2, '0'));
            dmtftimespan = (dmtftimespan + ".");

            // Construct a DateTime with with the precision to Second as same as the passed DateTime and so get
            // the ticks difference so that the microseconds can be calculated
            TimeSpan tsTemp = new TimeSpan(timespan.Days, timespan.Hours, timespan.Minutes, timespan.Seconds, 0);

            System.Int64 microsec = ((timespan.Ticks - tsTemp.Ticks) * 1000) / System.TimeSpan.TicksPerMillisecond;

            // fill the microseconds field
            String strMicrosec = microsec.ToString((IFormatProvider)CultureInfo.InvariantCulture.GetFormat(typeof(System.Int64)));

            if (strMicrosec.Length > 6)
            {
                strMicrosec = strMicrosec.Substring(0, 6);
            }
            dmtftimespan = dmtftimespan + strMicrosec.PadLeft(6, '0');

            dmtftimespan = dmtftimespan + ":000";

            return(dmtftimespan);
        }
Beispiel #6
0
        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.DelayedFloatField(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 in the scene that matches the masks.")))
            {
                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 #7
0
 public System.String ToJSON()
 {
     return("{\"data\" : " + data.ToString() + "}");
 }
Beispiel #8
0
        public override void OnInspectorGUI(NavGraph target)
        {
            RecastGraph graph = target as RecastGraph;

            bool preEnabled = GUI.enabled;

            //if (graph.forceBounds) {

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

            if (estWidth * estDepth >= 1024 * 1024 || estDepth >= 1024 * 1024 || estWidth >= 1024 * 1024)
            {
                GUIStyle helpBox = GUI.skin.FindStyle("HelpBox");
                if (helpBox == null)
                {
                    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("Width (samples)", estWidth.ToString());

            EditorGUILayout.LabelField("Depth (samples)", estDepth.ToString());

            /*} else {
             *      GUI.enabled = false;
             *      EditorGUILayout.LabelField ("Width (samples)","undetermined");
             *      EditorGUILayout.LabelField ("Depth (samples)","undetermined");
             * }*/
            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.cellHeight = EditorGUILayout.FloatField(new GUIContent("Cell Height", "Height of one voxel in world units"), graph.cellHeight);
            if (graph.cellHeight < 0.001F)
            {
                graph.cellHeight = 0.001F;
            }

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

            EditorGUI.BeginDisabledGroup(!graph.useTiles);

            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.EndDisabledGroup();

            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.walkableClimb   = EditorGUILayout.FloatField(new GUIContent("Walkable Climb", "How high can the character climb"), graph.walkableClimb);
            graph.characterRadius = EditorGUILayout.FloatField(new GUIContent("Character Radius", "Radius of the character, it's good to add some margin though"), graph.characterRadius);

            graph.maxSlope      = EditorGUILayout.Slider(new GUIContent("Max Slope", "Approximate maximum slope"), graph.maxSlope, 0F, 90F);
            graph.maxEdgeLength = EditorGUILayout.FloatField(new GUIContent("Max Edge Length", "Maximum length of one edge in the completed navmesh before it is split. A lower value can often yield better quality graphs"), 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"), 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"), 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"), graph.colliderRasterizeDetail);
                EditorGUI.indentLevel--;
            }


            Separator();

            graph.forcedBoundsCenter = EditorGUILayout.Vector3Field("Center", graph.forcedBoundsCenter);
            graph.forcedBoundsSize   = EditorGUILayout.Vector3Field("Size", graph.forcedBoundsSize);

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

            Separator();

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

            Separator();

            graph.showMeshOutline     = EditorGUILayout.Toggle(new GUIContent("Show mesh outline", "Toggles gizmos for drawing an outline of the mesh"), graph.showMeshOutline);
            graph.showNodeConnections = EditorGUILayout.Toggle(new GUIContent("Show node connections", "Toggles gizmos for drawing node connections"), graph.showNodeConnections);

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


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

            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);
            //graph.mask = 1 << EditorGUILayout.LayerField ("Mask",(int)Mathf.Log (graph.mask,2));
        }
Beispiel #9
0
 /// <summary>
 /// Deletes a existing resource.
 /// </summary>
 /// <param name="ID">The ID of the resource to be deleted.</param>
 public void Delete(System.Int64 ID) => this.Delete(ID.ToString());
Beispiel #10
0
 /// <summary>
 /// Deletes a existing resource.
 /// </summary>
 /// <param name="ID">The ID of the resource to be deleted.</param>
 public async System.Threading.Tasks.Task DeleteAsync(System.Int64 ID) => await this.DeleteAsync(ID.ToString());
Beispiel #11
0
        // Post Order
        public PostOrderResult PostOrder(string CID, string CSVMessId)
        {
            PostOrderResult ReturnResult = new PostOrderResult();

            ReturnResult.Status = 0;
            System.Int64   CusID = System.Convert.ToInt64(CID);
            List <Address> CustomerAddressList = Address.List.FindAll(x => x.CID == CusID);
            Customer       ObjCustomer         = Customer.List.Find(x => x.CID == CusID);

            if (ObjCustomer == null)
            {
                ReturnResult.Msg = "Please Login Again Your Id Not Found";
                return(ReturnResult);
            }
            System.TimeSpan OpeningTime         = new System.TimeSpan(6, 0, 0);
            System.TimeSpan ClosingTime         = new System.TimeSpan(22, 0, 0);
            Settings        OrderOpeningTimeObj = Settings.List.Find(x => x.KeyName == "OrderOpeningTime");
            Settings        OrderClosingTimeObj = Settings.List.Find(x => x.KeyName == "OrderClosingTime");

            if (OrderOpeningTimeObj != null)
            {
                string[] ArrayOpeningTime = OrderOpeningTimeObj.KeyValue.Split(',');
                OpeningTime = new System.TimeSpan(int.Parse(ArrayOpeningTime[0]), int.Parse(ArrayOpeningTime[1]), int.Parse(ArrayOpeningTime[2]));
            }
            if (OrderClosingTimeObj != null)
            {
                string[] ArrayClosingTime = OrderClosingTimeObj.KeyValue.Split(',');
                ClosingTime = new System.TimeSpan(int.Parse(ArrayClosingTime[0]), int.Parse(ArrayClosingTime[1]), int.Parse(ArrayClosingTime[2]));
            }
            System.DateTime OpeningDT = System.DateTime.Now.Date.Add(OpeningTime);
            System.DateTime ClosingDT = System.DateTime.Parse(System.DateTime.Now.Date.Add(ClosingTime).ToString("dd/MM/yyyy hh:mm:ss tt"));
            if (System.DateTime.Now > OpeningDT && ClosingDT > System.DateTime.Now)
            {
            }
            else
            {
                ReturnResult.Msg = "Cannot Order Before :" + System.DateTime.Now.Date.Add(OpeningTime).ToString("hh:mm tt") + " & After " + System.DateTime.Now.Date.Add(ClosingTime).ToString("hh:mm tt");
                return(ReturnResult);
            }


            List <Cart> ListCart = Cart.List.FindAll(x => x.CID == CusID);

            if (ListCart.Count <= 0)
            {
                ReturnResult.Status = 101;
                ReturnResult.Msg    = "Order Not Complete Because No Item Added";
                return(ReturnResult);
            }
            //check Balance
            double PayableAmt = 0;

            foreach (Cart Obj in ListCart)
            {
                Food ObjFood = Food.List.Find(x => x.FID == Obj.FID);
                PayableAmt += Obj.Count * ObjFood.Price;
            }
            double Bal = Ledger.List.FindAll(x => x.CID == CusID).Select(y => y.Credit - y.Debit).Sum();

            if (Bal < PayableAmt)
            {
                ReturnResult.Status = 102;
                ReturnResult.Msg    = "No Balance In Wallet";
                return(ReturnResult);
            }


            IEnumerable <IGrouping <string, Cart> > CartItemByMealType = ListCart.GroupBy(x => x.MealType).ToList();

            string[] MealTypes = CartItemByMealType.Select(x => x.Key).ToArray();

            // check Address Type For Lunch Dinner and Breakfast
            foreach (string Key in MealTypes)
            {
                Address CustAddress = CustomerAddressList.Find(x => x.Type == Key);
                if (CustAddress == null)
                {
                    ReturnResult.Status = 103;
                    ReturnResult.Msg    = Key;
                    return(ReturnResult);
                }
            }
            string OrderIds = "";

            foreach (var MealTypeList in CartItemByMealType)
            {
                string MealTypeKey = MealTypeList.Key;
                Orders ObjOrders   = new Orders()
                {
                    Create_By   = CusID,
                    Create_Date = System.DateTime.Now,
                    CID         = CusID,
                    MessIDs     = CSVMessId,
                    Status      = "1",
                    Type        = MealTypeKey,
                    HubId       = int.Parse(CustomerAddressList.Find(x => x.Type == MealTypeKey).Hub)
                };
                System.Int64 NewOID = ObjOrders.Save();
                if (NewOID > 0)
                {
                    ReturnResult.Status = 1;
                    OrderIds           += NewOID.ToString() + ",";
                    foreach (Cart Obj in MealTypeList.ToList())
                    {
                        Food      ObjFood = Food.List.Find(x => x.FID == Obj.FID);
                        OrderItem ObjID   = new OrderItem()
                        {
                            FID    = Obj.FID,
                            Price  = ObjFood.Price,
                            Count  = Obj.Count,
                            Qty    = ObjFood.Qty,
                            OID    = NewOID,
                            MessID = Obj.MessID,
                            Status = 0
                        };
                        if (ObjID.Save() <= 0)
                        {
                            Orders order = new Orders();
                            order.DeleteOrderAndOrderItem(NewOID);
                            ReturnResult.Status = 0;
                            ReturnResult.Msg    = "Unable To Place Order-Items at this time";
                            return(ReturnResult);
                        }
                    }
                }
                else
                {
                    ReturnResult.Msg = "Unable To Place Order at this time";
                    return(ReturnResult);
                }
            }
            var OrderidsArray = Regex.Split(OrderIds, ",").Where(x => x != string.Empty).ToArray();

            OrderIds         = string.Join(",", OrderidsArray);
            ReturnResult.Msg = OrderIds;
            Cart.List.RemoveAll(x => x.CID == CusID);
            Ledger ObjLedger = new Ledger()
            {
                CID         = CusID,
                Debit       = PayableAmt,
                Description = OrderIds,
                LedgerType  = "1"// 1 FOR CUSTOMER TYPE LEDGER;
            };

            if (ObjLedger.Save() == 0)
            {
                foreach (string OID in OrderidsArray)
                {
                    Orders order = new Orders();
                    order.DeleteOrderAndOrderItem(System.Int64.Parse(OID));
                }
                ReturnResult.Msg = "Unable To Deduct balance For Order";
            }
            return(ReturnResult);
        }
Beispiel #12
0
 /// <summary>
 /// Gets a single resource by ID.
 /// </summary>
 /// <param name="ID">The ID of the resource to show.</param>
 /// <returns>A resource represented by ID.</returns>
 public T Show(System.Int64 ID) => this.Show(ID.ToString());
Beispiel #13
0
 /// <summary>
 /// convert integer to string
 /// </summary>
 public static string Convert(System.Int64 i)
 {
     return(i.ToString());
 }
Beispiel #14
0
 /// <summary>
 /// Updates a resource partially.
 /// </summary>
 /// <param name="ID">The ID of the resource to be modified.</param>
 /// <param name="Model">The object that contains the fields and values ​​to be modified.</param>
 /// <returns>The modified resource.</returns>
 public T Modify(System.Int64 ID, System.Object Model) => this.Modify(ID.ToString(), Model);
Beispiel #15
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