ALFA.Shared.ServerInterop.ReadCExoString C# (CSharp) Метод

ReadCExoString() статический приватный Метод

Read a CExoString from an arbitrary virtual address and return a CLR string representation of it.
static private ReadCExoString ( IntPtr Offset ) : string
Offset System.IntPtr Supplies the offset of the CExoString /// object.
Результат string
        internal static string ReadCExoString(IntPtr Offset)
        {
            if (Offset == IntPtr.Zero)
                return String.Empty;

            CExoString ExoStr = (CExoString)Marshal.PtrToStructure(Offset, typeof(CExoString));
            return ExoStr.ToString();
        }

Usage Example

            /// <summary>
            /// StoreCampaignObject hook.  Called when the server script
            /// function StoreCampaignObject is called by any script.
            /// </summary>
            /// <param name="CodeBaseObject">Supplies the code base this
            /// pointer.</param>
            /// <param name="CampaignName">Supplies the campaign name.</param>
            /// <param name="VarName">Supplies the variable name.</param>
            /// <param name="PlayerName">Supplies the player name.</param>
            /// <param name="Cls">Always supplies the value 'O'.</param>
            /// <param name="Data">Supplies the raw GFF buffer.</param>
            /// <param name="Size">Supplies the count of raw GFF bytes in the
            /// data buffer.</param>
            /// <returns>True if the object was stored, else false if the
            /// object was not stored.
            private Int32 AddBinaryDataHook(IntPtr CodeBaseObject, IntPtr CampaignName, IntPtr VarName, IntPtr PlayerName, Byte Cls, IntPtr Data, UInt32 Size)
            {
                string CampaignNameStr = ServerInterop.ReadCExoString(CampaignName);

                //
                // If the campaign is the virtual database, call registered
                // event handlers.
                //

                if (CampaignNameStr.StartsWith("VDB_"))
                {
                    try
                    {
                        StoreCampaignDatabaseEventArgs EventArgs;
                        string VarNameStr    = ServerInterop.ReadCExoString(VarName);
                        string PlayerNameStr = ServerInterop.ReadCExoString(PlayerName);
                        byte[] GFF           = new byte[(int)Size];

                        Marshal.Copy(Data, GFF, 0, (int)Size);

                        EventArgs = new StoreCampaignDatabaseEventArgs(CampaignNameStr.Substring(4), VarNameStr, PlayerNameStr, GFF);
                        CampaignDatabase.StoreCampaignDatabaseEvent(null, EventArgs);

                        return(EventArgs.Handled ? 1 : 0);
                    }
                    catch (Exception e)
                    {
                        Logger.Log("CampaignDatabaseHook.AddBinaryDataHook: Exception: {0}", e);
                        return(0);
                    }
                }

                //
                // Pass through to the original server implementation that uses
                // the standard campaign database.
                //

                return(CCodeBase_AddBinaryData_OriginalDelegate(CodeBaseObject, CampaignName, VarName, PlayerName, Cls, Data, Size));
            }
All Usage Examples Of ALFA.Shared.ServerInterop::ReadCExoString