public AppHost(SciterWindow window) : base() { _window = window; var assembly = Assembly.Load("SciterCore.SciterSharp.Utilities"); var attributes = assembly.GetCustomAttributes <SciterCoreArchiveAttribute>(); foreach (var attribute in attributes) { var archive = new SciterArchive(attribute.Uri) .Open(assembly: assembly, attribute.ResourceName); AttachedArchives.TryAdd(archive.Uri.Scheme, archive); if (attribute.InitScripts?.Any() != true) { continue; } foreach (var initScript in attribute.InitScripts) { var byteArray = Encoding.UTF8.GetBytes($"include \"{initScript}\";"); var pinnedArray = GCHandle.Alloc(byteArray, GCHandleType.Pinned); var pointer = pinnedArray.AddrOfPinnedObject(); Sciter.SciterApi.SciterSetOption(IntPtr.Zero, SciterXDef.SCITER_RT_OPTIONS.SCITER_SET_INIT_SCRIPT, pointer); pinnedArray.Free(); } } }
//private SciterControl _control; //public SciterControl Window //{ // get // { // return _control; // } // set // { // _control = value; // if (value?.SciterWnd != null) // { // Host.SetupWindow(window: _control?.SciterWnd); // } // } //} public SciterArchiveComponent() { if (this.DesignMode) { return; } Archive = new SciterArchive(); }
public void Open_archive_with_a_custom_uri_and_incorrect_item_scheme_returns_null() { using (var archive = new SciterArchive("custom://app/")) { archive.OpenAsync(_assembly); var buffer = archive.GetItem("notme://app/index.html"); Assert.IsNull(buffer); } }
public void Open_archive_with_a_custom_uri_from_string() { using (var archive = new SciterArchive("custom://app/")) { archive.OpenAsync(_assembly); var buffer = archive.GetItem("index.html"); Assert.NotNull(buffer); } }
//private static SciterWindow _vm_wnd;// keep the same VM alive public static void Setup() { if (_archive == null) { _archive = new SciterArchive(); _archive.Open(SciterAppResource.ArchiveResource.resources); } /*if(_vm_wnd == null) * { * _vm_wnd = new SciterWindow(); * _vm_wnd.CreateMainWindow(0, 0, SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_MAIN | SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_TITLEBAR | SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_ENABLE_DEBUG); * }*/ }
public void SetUp() { _assembly = GetType().Assembly; _archive = new SciterArchive(); }