private async void RemoveButton_Click(object sender, RoutedEventArgs e) { var btn = (MenuFlyoutItem)sender; var config = (IAdapterConfig)btn.DataContext; var(secondaryAsClose, result) = await Utils.NotifyUser("Remove this config?", primaryCommandText : "Yes"); if (result != ContentDialogResult.Primary) { return; } try { File.Delete(config.Path); adapterConfigs.Remove(config); if (config.Path == AdapterConfig.GetDefaultConfigFilePath() && adapterConfigs.Count > 0) { AdapterConfig.SetDefaultConfigFilePath(adapterConfigs[0].Path); } } catch (Exception ex) { await Utils.NotifyUser("Error while deleting config file: " + ex.Message); } }
public override void Initialize() { AdapterConfig = new() { SwapChain = true, Debug = false, Bindless = true, //SingleQueue }; Adapter = new(AdapterConfig); Device = new(Adapter); SwapChain = new(Device, new() { Source = GetSwapchainSource(Adapter), ColorSrgb = false, Height = Window.Height, Width = Window.Width, VSync = false, DepthFormat = Adapter.DepthFormat is VkFormat.Undefined ? null : Adapter.DepthFormat }); Context = new(Device); Framebuffer = new(SwapChain); Camera.SetPosition(0, 0.34f, -18.5f); uniform = new(Camera.Projection, Camera.View); CreateBuffers(); CreatePipelineState(); }
public override void Initialize() { AdapterConfig = new() { SwapChain = true, Debug = true }; Adapter = new(AdapterConfig); Device = new(Adapter); SwapChain = new(Device, new() { Source = GetSwapchainSource(Adapter), ColorSrgb = false, Height = Window.Height, Width = Window.Width, VSync = false, DepthFormat = Adapter.DepthFormat is VkFormat.Undefined ? null : Adapter.DepthFormat }); Context = new(Device); Framebuffer = new(SwapChain); cmd_compute = new(Device, CommandBufferType.AsyncCompute); CreatePipelineState(); }
private async void SaveButton_Click(object sender, RoutedEventArgs e) { if (isSaving) { return; } isSaving = true; try { if (string.IsNullOrEmpty(config.Path)) { var dir = await Utils.GetAdapterConfigDirectory(); var file = await dir.CreateFileAsync(Guid.NewGuid().ToString() + ".json", CreationCollisionOption.GenerateUniqueName); config.Path = file.Path; } CachedFileManager.DeferUpdates(await StorageFile.GetFileFromPathAsync(config.Path)); config.SaveToFile(config.Path); AdapterConfig.SetDefaultConfigFilePath(config.Path); await CachedFileManager.CompleteUpdatesAsync(await StorageFile.GetFileFromPathAsync(config.Path)); Frame.GoBack(); } catch (Exception ex) { await Utils.NotifyUser("Cannot save config: " + ex.Message); } finally { isSaving = false; } }
public async void Init() { if (running) { return; } running = true; adapterFactory = AdapterConfig.GetAdapterFactoryFromDefaultFile(); dispatchWorker = Task.Run(() => doWork()); w.PacketPoped += W_PopPacket; w.DnsPacketPoped += W_DnsPacketPoped; TcpSocket.EstablishedTcp += W_EstablishTcp; w.Init(); while (running) { await Task.Delay(250); await executeLwipTask(() => { w.CheckTimeout(); return(0); }); } }
private async Task LoadAdapterConfigs() { loadProgressBar.Visibility = Visibility.Visible; try { var directory = await ConfigUtils.AdapterConfigFolderTask; var files = await directory.GetFilesAsync(); adapterConfigs.Clear(); foreach (var config in await Task.WhenAll(files.Select( f => AdapterConfig.GetConfigFromFilePath(f.Path).AsTask()))) { adapterConfigs.Add(config); } } catch (Exception ex) { await UiUtils.NotifyUser("Error loading config list: " + ex.ToString()); Frame.GoBack(); } finally { loadProgressBar.Visibility = Visibility.Collapsed; } }
private async Task SaveAsync(bool setAsDefault) { if (isSaving) { return; } isSaving = true; try { var file = await ConfigUtils.SaveServerAsync(config); config.Path = file.Path; if (setAsDefault) { AdapterConfig.SetDefaultConfigFilePath(config.Path); } await CachedFileManager.CompleteUpdatesAsync(file); Frame.GoBack(); } catch (Exception ex) { await UiUtils.NotifyUser("Cannot save config: " + ex.Message); } finally { isSaving = false; } }
public object Convert(object configPath, Type targetType, object parameter, string language) { if (AdapterConfig.GetDefaultConfigFilePath() == configPath as string) { return(FontWeights.Bold); } return(FontWeights.Normal); }
private async void SetDefaultButton_Click(object sender, RoutedEventArgs e) { var btn = (MenuFlyoutItem)sender; var defaultConfig = (IAdapterConfig)btn.DataContext; AdapterConfig.SetDefaultConfigFilePath(defaultConfig.Path); await LoadAdapterConfigs(); }
public override void Initialize() { AdapterConfig = new() { SwapChain = true, }; Camera.SetPosition(0, -0.55f, -8.0f); Camera.Update(); Adapter = new(AdapterConfig); Device = new(Adapter); SwapChain = new(Device, new() { Source = GetSwapchainSource(Adapter), ColorSrgb = false, Height = Window.Height, Width = Window.Width, VSync = false, DepthFormat = Adapter.DepthFormat is VkFormat.Undefined ? null : Adapter.DepthFormat }); Context = new(Device); Framebuffer = new(SwapChain); uniform = new(Camera.Projection, Model, Camera.View); light = new() { Ambient = new Vector4(0.5f, 0.5f, 0.5f, 1.0f), Diffuse = new Vector4(0.8f, 0.8f, 0.8f, 1.0f), Direction = new Vector3(1, 1, -1.05f), }; ConstBuffer = new(Device, new() { BufferFlags = BufferFlags.ConstantBuffer, Usage = ResourceUsage.CPU_To_GPU, SizeInBytes = Interop.SizeOf <TransformUniform>(), }); ConstBuffer2 = new(Device, new() { BufferFlags = BufferFlags.ConstantBuffer, Usage = ResourceUsage.CPU_To_GPU, SizeInBytes = Interop.SizeOf <Light>(), }); GLTFModel = new(Device, Constants.ModelsFile + "chinesedragon.gltf"); CreatePipelineState(); }
public override void Initialize() { AdapterConfig = new() { SwapChain = true, Debug = false, Fullscreen = false, }; Camera.SetPosition(0, -8, -40.0f); Camera.Update(); Adapter = new(AdapterConfig); Device = new(Adapter); SwapChain = new(Device, new() { Source = GetSwapchainSource(Adapter), ColorSrgb = false, Height = Window.Height, Width = Window.Width, VSync = false, DepthFormat = Adapter.DepthFormat is VkFormat.Undefined ? null : Adapter.DepthFormat }); Context = new(Device); Framebuffer = new(SwapChain); uniform = new(Camera.Projection, Model, Camera.View); light = new(new Vector4(1.0f, 1.0f, 1.0f, 1.0f), new Vector3(0.0f, 0.0f, 0.0f)); BufferDescription bufferDescription = new() { BufferFlags = BufferFlags.ConstantBuffer, Usage = ResourceUsage.CPU_To_GPU, SizeInBytes = Interop.SizeOf <TransformUniform>(), }; ConstBuffer = new(Device, bufferDescription); ConstBuffer2 = new(Device, bufferDescription); ConstBuffer3 = new(Device, bufferDescription); ConstBuffer4 = new(Device, new() { BufferFlags = BufferFlags.ConstantBuffer, Usage = ResourceUsage.CPU_To_GPU, SizeInBytes = Interop.SizeOf <Light>(), }); CreatePipelineState(); GLTFModel = new(Device, Constants.ModelsFile + "mesh_mat.gltf"); }
public void DefaultValuesShouldBeSet() { var config = new AdapterConfig(new FakeConfigurer()); Assert.AreEqual(true, config.UseOutlookStyle); Assert.AreEqual(true, config.TrimSignature); Assert.AreEqual(true, config.AllowImplicitCommand); Assert.AreEqual(5, config.MaxRetry); Assert.AreEqual(5, config.SubscriptionLifetime); }
protected override void Validate() { // see Microsoft.BizTalk.Adapter.Sftp.SftpRLConfig.Validate() // see Microsoft.BizTalk.Adapter.Wcf.Config.RLConfig.ValidateBinding() var binding = AdapterConfig.CreateBinding(new SftpRHConfig()); binding.CreateBindingElements(); // see Microsoft.BizTalk.Adapter.Wcf.Config.RLConfig.ValidateAddress() AdapterConfigValidationHelper.ValidateAddress(GetAddress(), UriKind.Absolute, binding.Scheme, null); }
protected override void Validate() { // see Microsoft.BizTalk.Adapter.Sftp.SftpTLConfig.Validate() // see Microsoft.BizTalk.Adapter.Wcf.Config.TLConfig.ValidateBinding() var binding = AdapterConfig.CreateBinding(new SftpTHConfig()); binding.CreateBindingElements(); // see Microsoft.BizTalk.Adapter.Wcf.Config.TLConfig.ValidateAddress() AdapterConfigValidationHelper.ValidateAddress(GetAddress().Replace("%", WebUtility.UrlEncode("%")), UriKind.Absolute, binding.Scheme, null); }
private async Task LoadAdapterConfigs() { var directory = await Utils.GetAdapterConfigDirectory(); var files = await directory.GetFilesAsync(); adapterConfigs.Clear(); foreach (var config in files.Select(f => AdapterConfig.GetConfigFromFilePath(f.Path))) { adapterConfigs.Add(config); } }
public ClearScreenExample() : base() { AdapterConfig = new() { SwapChain = true, Debug = true, Fullscreen = false, Bindless = false, ConditionalRendering = false, ConservativeRasterization = false, RayTracing = false, ShadingRate = false, }; }
public void ValuesCanBeConfigured() { var fake = new FakeConfigurer() { Data = new Dictionary <string, string>() { { "MMBOT_EXCHANGE_EMAIL", "*****@*****.**" }, { "MMBOT_EXCHANGE_SUBSCRIPTIONLIFETIME", "30" }, { "MMBOT_EXCHANGE_USEOUTLOOKSTYLE", "false" } } }; var config = new AdapterConfig(fake); Assert.AreEqual("*****@*****.**", config.Email); Assert.AreEqual(30, config.SubscriptionLifetime); Assert.AreEqual(false, config.UseOutlookStyle); }
public async void Init() { if (running) { return; } adapterFactory = await AdapterConfig.GetAdapterFactoryFromDefaultFile(); running = true; taskChannel = Channel.CreateUnbounded <Action>(new UnboundedChannelOptions() { SingleReader = true }); var _ = Task.Run(() => doWork()); wintun.PacketPoped += W_PopPacket; TcpSocket.EstablishedTcp += W_EstablishTcp; wintun.Init(); int i = 0; while (running) { i++; await executeLwipTask(() => { wintun.CheckTimeout(); return(0); }).ConfigureAwait(false); if (i % 10 == 0) { tunAdapters.RemoveAll(w => !w.TryGetTarget(out var a) /* TODO: || a.IsShutdown == 1 */); if (DebugLogger.LogNeeded()) { DebugLogger.Log("# of connections in local stack: " + ConnectionCount); DebugLogger.Log($"# of open/all adapters: {TunSocketAdapter.OpenCount} {tunAdapters.Count}"); DebugLogger.Log($"# of recv/send: {TunSocketAdapter.RecvingCount} {TunSocketAdapter.SendingCount}"); } } await Task.Delay(250).ConfigureAwait(false); } }
public override void Initialize() { AdapterConfig = new() { SwapChain = true, Debug = true, }; Adapter = new Adapter(AdapterConfig); Device = new Device(Adapter); SwapChain = new SwapChain(Device, new() { Source = GetSwapchainSource(Adapter), ColorSrgb = false, Height = Window.Height, Width = Window.Width, VSync = false, DepthFormat = Adapter.DepthFormat is VkFormat.Undefined ? null : Adapter.DepthFormat }); Context = new GraphicsContext(Device); Framebuffer = new Framebuffer(SwapChain); Camera = new(45f, 1f, 0.1f, 64f); Camera.SetPosition(0, 0, -3.0f); Camera.AspectRatio = (float)Window.Width / Window.Height; Camera.Update(); // Reset Model Model = Matrix4x4.Identity; Uniform = new(Camera.Projection, Model, Camera.View); CreateBuffers(); CreatePipelineState(); }
public void Init(string configName) { this.Changed = new HashSet <ChangedItem>(); this.DataItems = this.FindImplementations(); this.Config = this._ctx.Adapters.FirstOrDefault(o => o.Name == configName); if (this.Config == null) { this.Config = new AdapterConfig(); this.Config.Created = DateTime.UtcNow; this.Config.PollRate = 500; this._ctx.Adapters.Add(this.Config); } else { this._ctx.Entry(this.Config).State = System.Data.Entity.EntityState.Modified; } this.Config.Name = configName; this.Config.LastStarted = DateTime.UtcNow; foreach (KeyValuePair <Type, dynamic> kvp in this.DataItems) { (kvp.Value as ADataItem).DataItemChanged += DataItemChanged; var configItem = this.Config.Items.FirstOrDefault(o => o.Name == kvp.Value.Name); if (configItem == null) { configItem = new DataItem(); this.Config.Items.Add(configItem); this._ctx.Entry(configItem).State = System.Data.Entity.EntityState.Added; configItem.Name = kvp.Value.Name; configItem.IsActive = kvp.Value.IsActive; configItem.TickFrequency = kvp.Value.TickFrequency; } else { kvp.Value.IsActive = configItem.IsActive; kvp.Value.TickFrequency = configItem.TickFrequency; } } this._ctx.SaveChanges(); }
public static async Task SaveServersAsync(List <IAdapterConfig> configs) { var lastConfig = ""; foreach (var config in configs) { if (string.IsNullOrEmpty(config.Path)) { var dir = await GetAdapterConfigDirectory(); var file = await dir.CreateFileAsync(Guid.NewGuid().ToString() + ".json", CreationCollisionOption.GenerateUniqueName); config.Path = file.Path; } config.SaveToFile(config.Path); lastConfig = config.Path; } if (!string.IsNullOrEmpty(lastConfig)) { AdapterConfig.SetDefaultConfigFilePath(lastConfig); } }
public void ParseConfigUsesDefault() { Assert.AreEqual("foobar", AdapterConfig.ParseConfig <string>(null, "foobar")); }
private async void RemoveButton_Click(object sender, RoutedEventArgs e) { var btn = (MenuFlyoutItem)sender; IList <object> configs; ContentDialogResult result; if (configList.SelectedItems.Count == 0) { var config = (IAdapterConfig)((FrameworkElement)sender).DataContext; configs = new List <object>() { config }; (_, result) = await UiUtils.NotifyUser("Remove this config?", primaryCommandText : "Yes"); } else { configs = configList.SelectedItems; (_, result) = await UiUtils.NotifyUser($"Remove {configList.SelectedItems.Count} configs?", primaryCommandText : "Yes"); } if (result != ContentDialogResult.Primary) { return; } var deletedConfigs = new List <IAdapterConfig>(configs.Count); loadProgressBar.IsIndeterminate = true; loadProgressBar.Value = 0; loadProgressBar.Visibility = Visibility.Visible; try { var defaultConfigPath = AdapterConfig.GetDefaultConfigFilePath(); var tasks = configs.Select(async obj => { var config = (IAdapterConfig)obj; var file = await StorageFile.GetFileFromPathAsync(config.Path); await file.DeleteAsync(); deletedConfigs.Add(config); if (config.Path == defaultConfigPath) { AdapterConfig.ClearDefaultConfigFilePath(); } loadProgressBar.IsIndeterminate = false; loadProgressBar.Value = (double)deletedConfigs.Count / configs.Count; }); await Task.WhenAll(tasks); } catch (Exception ex) { await UiUtils.NotifyUser("Error while deleting config file: " + ex.ToString()); } finally { if (deletedConfigs.Count == adapterConfigs.Count) { adapterConfigs.Clear(); } else { foreach (var deleted in deletedConfigs) { adapterConfigs.Remove(deleted); } } loadProgressBar.IsIndeterminate = true; loadProgressBar.Visibility = Visibility.Collapsed; } }
public void Connect(VpnChannel channel) { State = VpnPluginState.Connecting; LogLine("Connecting", channel); try { var transport = new DatagramSocket(); channel.AssociateTransport(transport, null); DebugVpnContext context = null; if (channel.PlugInContext == null) { LogLine("Initializing new context", channel); #if YT_MOCK channel.PlugInContext = context = new DebugVpnContext(); #else var configPath = AdapterConfig.GetDefaultConfigFilePath(); if (string.IsNullOrEmpty(configPath)) { channel.TerminateConnection("Config not set"); return; } try { var config = AdapterConfig.GetConfigFromFilePath(configPath); if (config == null) { throw new Exception("Cannot read config file."); } } catch (Exception ex) { channel.TerminateConnection("Error reading config file:" + ex.Message); } channel.PlugInContext = context = new DebugVpnContext("9008"); #endif } else { LogLine("Context exists", channel); context = (DebugVpnContext)channel.PlugInContext; } transport.BindEndpointAsync(new HostName("127.0.0.1"), "9007").AsTask().ContinueWith(t => { LogLine("Binded", channel); }).Wait(); #if !YT_MOCK context.Init(); #endif /* var rport = context.Init(transport.Information.LocalPort, str => * { * LogLine(str, channel); * return null; * }); */ var rport = "9008"; transport.ConnectAsync(new HostName("127.0.0.1"), rport).AsTask().ContinueWith(t => { LogLine("r Connected", channel); }); VpnRouteAssignment routeScope = new VpnRouteAssignment() { ExcludeLocalSubnets = true }; var inclusionRoutes = routeScope.Ipv4InclusionRoutes; // myip.ipip.net //inclusionRoutes.Add(new VpnRoute(new HostName("36.99.18.134"), 32)); // qzworld.net //inclusionRoutes.Add(new VpnRoute(new HostName("188.166.248.242"), 32)); // DNS server inclusionRoutes.Add(new VpnRoute(new HostName("1.1.1.1"), 32)); // main CIDR inclusionRoutes.Add(new VpnRoute(new HostName("172.17.0.0"), 16)); var assignment = new VpnDomainNameAssignment(); var dnsServers = new[] { // DNS servers new HostName("1.1.1.1"), }; assignment.DomainNameList.Add(new VpnDomainNameInfo(".", VpnDomainNameType.Suffix, dnsServers, new HostName[] { })); var now = DateTime.Now; LogLine("Starting transport", channel); channel.StartWithMainTransport( new[] { new HostName("192.168.3.1") }, null, null, routeScope, assignment, 1500u, 1512u, false, transport ); var delta = DateTime.Now - now; LogLine($"Finished starting transport in {delta.TotalMilliseconds} ms.", channel); LogLine("Connected", channel); State = VpnPluginState.Connected; } catch (Exception ex) { LogLine("Error connecting", channel); LogLine(ex.Message, channel); LogLine(ex.StackTrace, channel); channel.TerminateConnection("Cannot connect to local tunnel"); State = VpnPluginState.Disconnected; } }
public override void Initialize() { AdapterConfig = new() { SwapChain = true, }; Camera.SetPosition(0, 0, -8.0f); Camera.Update(); Adapter = new(AdapterConfig); Device = new(Adapter); SwapChain = new(Device, new() { Source = GetSwapchainSource(Adapter), ColorSrgb = false, Height = Window.Height, Width = Window.Width, VSync = false, DepthFormat = Adapter.DepthFormat is VkFormat.Undefined ? null : Adapter.DepthFormat }); Context = new(Device); Framebuffer = new(SwapChain); uniform = new(Camera.Projection, Camera.View); light = new() { Ambient = new Vector4(0.5f, 0.5f, 0.5f, 1.0f), Diffuse = new Vector4(0.8f, 0.8f, 0.8f, 1.0f), Direction = new Vector3(1, 1, -1.05f), Specular = new(1, 1, 1), SpecularPower = 30, }; ConstBuffer = new(Device, new() { BufferFlags = BufferFlags.ConstantBuffer, Usage = ResourceUsage.CPU_To_GPU, SizeInBytes = Interop.SizeOf <TransformUniform>(), }); ConstBuffer2 = new(Device, new() { BufferFlags = BufferFlags.ConstantBuffer, Usage = ResourceUsage.CPU_To_GPU, SizeInBytes = Interop.SizeOf <Light>(), }); Sphere = new(Device, Vultaik.Toolkit.GeometricPrimitives.PrimitiveType.Sphere); Sphere.Position = new(-2.5f, 1.5f, 0.0f); Torus = new(Device, Vultaik.Toolkit.GeometricPrimitives.PrimitiveType.Torus); Torus.Position = new(2.5f, 1.5f, 0.0f); Pyramid = new(Device, Vultaik.Toolkit.GeometricPrimitives.PrimitiveType.Pyramid); Pyramid.Position = new(-2.5f, -1.5f, 0.0f); Cube = new(Device, Vultaik.Toolkit.GeometricPrimitives.PrimitiveType.Cube); Cube.Position = new(2.5f, -1.5f, 0.0f); Capsule = new(Device, Vultaik.Toolkit.GeometricPrimitives.PrimitiveType.Capsule); Capsule.Position = new(0, 0, 0.0f); Capsule.Size = new(0.4f, 0.4f, 0.4f); CreatePipelineState(); }
protected override void Save(IPropertyBag propertyBag) { AdapterConfig.Save(propertyBag as ExplorerOM::Microsoft.BizTalk.ExplorerOM.IPropertyBag); }
public void ParseConfigSafelyConvertsNull() { Assert.AreEqual(false, AdapterConfig.ParseConfig <bool>(null)); }
public void ParseConfigHandlesBadConversions() { Assert.AreEqual(5, AdapterConfig.ParseConfig <int>("not an int", 5)); }
public void ParseConfigHandlesEmptyString() { Assert.AreEqual(0, AdapterConfig.ParseConfig <int>("")); }
public void ParseConfigUsesTypeDefault() { Assert.AreEqual(0, AdapterConfig.ParseConfig <int>(null)); }