Пример #1
0
        public static void Register(Assembly?assembly = null)
        {
            var standardPlatform = new StandardRuntimePlatform();
            var os = standardPlatform.GetRuntimeInfo().OperatingSystem;

            AssetLoader.RegisterResUriParsers();
            AvaloniaLocator.CurrentMutable
            .Bind <IRuntimePlatform>().ToConstant(standardPlatform)
            .Bind <IAssetLoader>().ToConstant(new AssetLoader(assembly))
            .Bind <IDynamicLibraryLoader>().ToConstant(
                os switch
            {
                OperatingSystemType.WinNT => new Win32Loader(),
                OperatingSystemType.OSX => new UnixLoader(),
                OperatingSystemType.Linux => new UnixLoader(),
                OperatingSystemType.Android => new UnixLoader(),
                // iOS, WASM, ...
                _ => (IDynamicLibraryLoader) new NotSupportedLoader()
            }
Пример #2
0
            public UnmanagedBlob(StandardRuntimePlatform plat, int size)
            {
                try
                {
                    if (size <= 0)
                    {
                        throw new ArgumentException("Positive number required", nameof(size));
                    }
                    _plat    = plat;
                    _address = plat.Alloc(size);
                    GC.AddMemoryPressure(size);
                    Size = size;
                }
                catch
                {
                    GC.SuppressFinalize(this);
                    throw;
                }
#if DEBUG
                _backtrace = Environment.StackTrace;
                lock (_btlock)
                    Backtraces.Add(_backtrace);
#endif
            }