public SteamParamStringArray(System.Collections.Generic.IList <string> strings)
            {
                if (strings == null)
                {
                    m_pSteamParamStringArray = IntPtr.Zero;
                    return;
                }

                m_Strings = new IntPtr[strings.Count];
                for (int i = 0; i < strings.Count; ++i)
                {
                    byte[] strbuf = new byte[Encoding.UTF8.GetByteCount(strings[i]) + 1];
                    Encoding.UTF8.GetBytes(strings[i], 0, strings[i].Length, strbuf, 0);
                    m_Strings[i] = Marshal.AllocHGlobal(strbuf.Length);
                    Marshal.Copy(strbuf, 0, m_Strings[i], strbuf.Length);
                }

                m_ptrStrings = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)) * m_Strings.Length);
                SteamParamStringArray_t stringArray = new SteamParamStringArray_t()
                {
                    m_ppStrings   = m_ptrStrings,
                    m_nNumStrings = m_Strings.Length
                };

                Marshal.Copy(m_Strings, 0, stringArray.m_ppStrings, m_Strings.Length);

                m_pSteamParamStringArray = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(SteamParamStringArray_t)));
                Marshal.StructureToPtr(stringArray, m_pSteamParamStringArray, false);
            }
Esempio n. 2
0
            public SteamParamStringArray(IList <string> strings)
            {
                if (strings == null)
                {
                    m_pSteamParamStringArray = IntPtr.Zero;
                    return;
                }
                m_Strings = new IntPtr[strings.Count];
                for (int i = 0; i < strings.Count; i++)
                {
                    byte[] array = new byte[Encoding.UTF8.GetByteCount(strings[i]) + 1];
                    Encoding.UTF8.GetBytes(strings[i], 0, strings[i].Length, array, 0);
                    m_Strings[i] = Marshal.AllocHGlobal(array.Length);
                    Marshal.Copy(array, 0, m_Strings[i], array.Length);
                }
                m_ptrStrings = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)) * m_Strings.Length);
                SteamParamStringArray_t structure = new SteamParamStringArray_t
                {
                    m_ppStrings   = m_ptrStrings,
                    m_nNumStrings = m_Strings.Length
                };

                Marshal.Copy(m_Strings, 0, structure.m_ppStrings, m_Strings.Length);
                m_pSteamParamStringArray = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(SteamParamStringArray_t)));
                Marshal.StructureToPtr(structure, m_pSteamParamStringArray, fDeleteOld: false);
            }
Esempio n. 3
0
 public SteamParamStringArray(IList <string> strings)
 {
     if (strings == null)
     {
         this.m_pSteamParamStringArray = IntPtr.Zero;
     }
     else
     {
         this.m_Strings = new IntPtr[strings.Count];
         for (int i = 0; i < strings.Count; i++)
         {
             byte[] bytes = new byte[Encoding.UTF8.GetByteCount(strings[i]) + 1];
             Encoding.UTF8.GetBytes(strings[i], 0, strings[i].Length, bytes, 0);
             this.m_Strings[i] = Marshal.AllocHGlobal(bytes.Length);
             Marshal.Copy(bytes, 0, this.m_Strings[i], bytes.Length);
         }
         this.m_ptrStrings = Marshal.AllocHGlobal((int)(Marshal.SizeOf(typeof(IntPtr)) * this.m_Strings.Length));
         SteamParamStringArray_t structure = new SteamParamStringArray_t {
             m_ppStrings   = this.m_ptrStrings,
             m_nNumStrings = this.m_Strings.Length
         };
         Marshal.Copy(this.m_Strings, 0, structure.m_ppStrings, this.m_Strings.Length);
         this.m_pSteamParamStringArray = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(SteamParamStringArray_t)));
         Marshal.StructureToPtr(structure, this.m_pSteamParamStringArray, false);
     }
 }
			public SteamParamStringArray(System.Collections.Generic.IList<string> strings) {
				if (strings == null) {
					m_pSteamParamStringArray = IntPtr.Zero;
					return;
				}

				m_Strings = new IntPtr[strings.Count];
				for (int i = 0; i < strings.Count; ++i) {
					byte[] strbuf = new byte[Encoding.UTF8.GetByteCount(strings[i]) + 1];
					Encoding.UTF8.GetBytes(strings[i], 0, strings[i].Length, strbuf, 0);
					m_Strings[i] = Marshal.AllocHGlobal(strbuf.Length);
					Marshal.Copy(strbuf, 0, m_Strings[i], strbuf.Length);
				}

				m_ptrStrings = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)) * m_Strings.Length);
				SteamParamStringArray_t stringArray = new SteamParamStringArray_t() {
					m_ppStrings = m_ptrStrings,
					m_nNumStrings = m_Strings.Length
				};
				Marshal.Copy(m_Strings, 0, stringArray.m_ppStrings, m_Strings.Length);

				m_pSteamParamStringArray = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(SteamParamStringArray_t)));
				Marshal.StructureToPtr(stringArray, m_pSteamParamStringArray, false);
			}
Esempio n. 5
0
 public SteamParamStringArray(IList<string> strings)
 {
     if (strings == null)
     {
         this.m_pSteamParamStringArray = IntPtr.Zero;
         return;
     }
     this.m_Strings = new IntPtr[strings.Count];
     for (int i = 0; i < strings.Count; i++)
     {
         byte[] array = new byte[Encoding.UTF8.GetByteCount(strings[i]) + 1];
         Encoding.UTF8.GetBytes(strings[i], 0, strings[i].Length, array, 0);
         this.m_Strings[i] = Marshal.AllocHGlobal(array.Length);
         Marshal.Copy(array, 0, this.m_Strings[i], array.Length);
     }
     this.m_ptrStrings = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)) * this.m_Strings.Length);
     SteamParamStringArray_t steamParamStringArray_t = new SteamParamStringArray_t
     {
         m_ppStrings = this.m_ptrStrings,
         m_nNumStrings = this.m_Strings.Length
     };
     Marshal.Copy(this.m_Strings, 0, steamParamStringArray_t.m_ppStrings, this.m_Strings.Length);
     this.m_pSteamParamStringArray = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(SteamParamStringArray_t)));
     Marshal.StructureToPtr(steamParamStringArray_t, this.m_pSteamParamStringArray, false);
 }