Exemple #1
0
        /// <summary>
        /// Maps the current resource to a specified subresource
        /// </summary>
        /// <param name="subresource">The index of the target subresource to map</param>
        /// <returns>An <see cref="IntPtr"/> for the newly mapped resource</returns>
        internal IntPtr Map(int subresource)
        {
            IntPtr mappedResource = NativeResource?.Map(subresource) ?? throw new InvalidOperationException("Missing resource");

            MappedResource = mappedResource;
            return(mappedResource);
        }
Exemple #2
0
        public IntPtr Map(int subresource)
        {
            IntPtr mappedResource = NativeResource.Map(subresource);

            MappedResource = mappedResource;
            return(mappedResource);
        }
Exemple #3
0
            /// <summary>
            /// Gets the resource string from a library using the string format "@[library path],[id]". Optionally, it can be contained in a "$([string])" wrapper.
            /// </summary>
            /// <param name="resourceReference">The resource reference string.</param>
            /// <returns>If <paramref name="resourceReference"/> equals <c>null</c>, <c>null</c> is returned. Otherwise, it returns the referenced string pulled from the library using the identifier.</returns>
            /// <exception cref="System.ArgumentException">
            /// Invalid string format. - resourceReference
            /// or
            /// Invalid resource identifier. - resourceReference
            /// </exception>
            public static string GetResourceString(string resourceReference)
            {
                // If null, return null
                if (resourceReference == null)
                {
                    return(null);
                }
                // Extract inner value if in $(fn,i) format
                if (resourceReference.StartsWith(@"$(") && resourceReference.EndsWith(")"))
                {
                    resourceReference = resourceReference.Substring(2, resourceReference.Length - 3);
                }
                // Match parts
                var m = System.Text.RegularExpressions.Regex.Match(resourceReference, @"^@(?<f>.+),(?<i>-?\d+)(?:;(?<c>.*))?$");

                if (!m.Success)
                {
                    throw new ArgumentException(@"Invalid string format.", nameof(resourceReference));
                }
                // Load referenced library and extract string from identifier
                int id;

                if (!int.TryParse(m.Groups["i"].Value, out id) || id > 0)
                {
                    throw new ArgumentException(@"Invalid resource identifier.", nameof(resourceReference));
                }
                using (var nr = new NativeResource(m.Groups["f"].Value))
                    return(nr.GetString(-id));
            }
Exemple #4
0
        public MockAltV(string entryPoint)
        {
            //var resource = new MockResourceLoader(IntPtr.Zero, string.Empty, entryPoint).Init();
            IResource resource            = null;
            var       playerFactory       = new MockPlayerFactory <TPlayer>(resource.GetPlayerFactory());
            var       vehicleFactory      = new MockVehicleFactory <TVehicle>(resource.GetVehicleFactory());
            var       blipFactory         = new MockBlipFactory <TBlip>(resource.GetBlipFactory());
            var       checkpointFactory   = new MockCheckpointFactory <TCheckpoint>(resource.GetCheckpointFactory());
            var       voiceChannelFactory = new MockVoiceChannelFactory <TVoiceChannel>(resource.GetVoiceChannelFactory());
            var       colShapeFactory     = new MockColShapeFactory <TColShape>(resource.GetColShapeFactory());
            var       playerPool          = new MockPlayerPool(playerFactory);
            var       vehiclePool         = new MockVehiclePool(vehicleFactory);
            var       blipPool            = new MockBlipPool(blipFactory);
            var       checkpointPool      = new MockCheckpointPool(checkpointFactory);
            var       voiceChannelPool    = new MockVoiceChannelPool(voiceChannelFactory);
            var       colShapePool        = new MockColShapePool(colShapeFactory);
            var       entityPool          = new MockBaseEntityPool(playerPool, vehiclePool);
            var       baseObjectPool      =
                new MockBaseBaseObjectPool(playerPool, vehiclePool, blipPool, checkpointPool, voiceChannelPool, colShapePool);
            var server = new MockServer(IntPtr.Zero, baseObjectPool, entityPool, playerPool, vehiclePool, blipPool,
                                        checkpointPool, voiceChannelPool, null);
            var cSharpNativeResource = new NativeResource(IntPtr.Zero, IntPtr.Zero);
            var module = resource.GetModule(server, AssemblyLoadContext.Default, cSharpNativeResource, baseObjectPool, entityPool, playerPool,
                                            vehiclePool, blipPool, checkpointPool, voiceChannelPool, colShapePool, null);

            resource.OnStart();
        }
Exemple #5
0
 public void Unmap(int subresource)
 {
     NativeResource.Unmap(subresource);
     MappedResource = IntPtr.Zero;
 }
Exemple #6
0
 public virtual void Dispose()
 {
     NativeResource.Dispose();
 }
Exemple #7
0
 /// <inheritdoc/>
 public virtual void Dispose() => NativeResource?.Dispose();
Exemple #8
0
 /// <summary>
 /// Unmaps a subresource specified by a given index
 /// </summary>
 /// <param name="subresource">The index of the subresource to unmap</param>
 internal void Unmap(int subresource)
 {
     NativeResource?.Unmap(subresource);
     MappedResource = IntPtr.Zero;
 }
Exemple #9
0
 public void CloseHandle(NativeResource n)
 {
     //......
 }
 /// <summary>
 /// Unmaps a subresource specified by a given index
 /// </summary>
 internal void Unmap()
 {
     NativeResource?.Unmap(0);
     MappedResource = IntPtr.Zero;
 }