Tag: c#

如何关联function输入和输出?

考虑下面的简单程序。 它有一个可观察的整数和一个函数来计算最近发布的整数是偶数还是奇数。 出乎意料的是,该程序在报告数字发生变化之前报告最近的数字是偶数/奇数。 static void Main(string[] args) { int version = 0; var numbers = new Subject(); IObservable isNumberEven = numbers.Select(i => i % 2 == 0); isNumberEven .Select(i => new { IsEven = i, Version = Interlocked.Increment(ref version) }) .Subscribe(i => Console.WriteLine($”Time {i.Version} : {i.IsEven}”)); numbers .Select(i => new { Number = i, Version […]

AngularJS:如何获得系统远程?

请让我详细说明我的目标是什么 如何从运行Windows系统的Windows应用程序的Angular.js应用程序中获取远程桌面连接。 我的服务器是Google App Engine。 到目前为止我所想到的: Windows应用程序将拍摄屏幕截图并发送到Google App Engine Channel API。 Google App Engine频道API会通知Angular应用并向其发送屏幕截图并进行显示。 这种方法的问题在于它非常昂贵且速度慢。 请求 请建议一些工具或api或制作屏幕共享应用程序的方法。

使用HLSL进行YUV到RGB转换的奇怪模糊边缘图案

我正在尝试在HLSL中将YUV写入RGB着色器。 具体来说,它转换Yuv420p格式,该格式由Y值的N M平面组成,接着是U值的(N / 2) (M / 2)平面,然后是(N / 2)*(M / 2)平面V值。 例如这张1280×720图片: 在YUV格式中看起来像这样解释为8位,1280×1080纹理: 在Direct3D11中,我将其作为Texture2D加载,格式为R8_UNorm,尺寸为1280×1080。 棘手的部分是重建U和V平面,因为正如你所看到的,一半的线位于纹理的左侧,另一半位于右侧。 在着色器中,我这样做: struct PS_IN { float4 pos : SV_POSITION; float2 tex : TEXCOORD; }; Texture2D picture; SamplerState pictureSampler; float4 PS(PS_IN input) : SV_Target { int pixelCoord = input.tex.y * 720; bool evenRow = (pixelCoord / 2) % 2 == 0; […]

在解决方案中检索Roslyn的所有类型

有谁知道如何在解决方案中检索所有可用类型(语义)? 从几个项目中创建汇编很容易。 MSBuildWorkspace workspace = MSBuildWorkspace.Create(); var solution = await workspace.OpenSolutionAsync(solutionPath, cancellationToken); var compilations = await Task.WhenAll(solution.Projects.Select(x => x.GetCompilationAsync(cancellationToken))); 迭代所有ClassDeclarations对我来说是不够的,因为我想要所有类型和它们之间的连接。 foreach (var tree in compilation.SyntaxTrees) { var source = tree.GetRoot(cancellationToken).DescendantNodes(); var classDeclarations = source.OfType(); }

Linq VAR和Typed对象

我想要一个代码示例。 目前我在c#和asp.net 4 ef4中使用linq var querySlotOrder = from slot in context.CmsSlots where slot.SlotId == myCurrentSlotId select slot; if (querySlotOrder.SlotOrder == myNewSlotOrder) e.Cancel = true; 此linq查询仅返回记录。 使用VAR我无法获取Typed对象,我无法访问其属性SlotOrder。 如何更改查询? 谢谢你的帮助 有用的资源主题: http://msdn.microsoft.com/en-us/library/bb384065.aspx http://msdn.microsoft.com/en-us/library/bb397947.aspx http://msdn.microsoft.com/en-us/library/bb397678.aspx

Console.ReadLine Break

我试图找出如何使用Console.ReadLine和一个计时器。 我的控制台程序旨在自动运行一个长进程,此进程在上一个进程完成后每30秒重新启动一次。 我想通过键入命令让用户能够打破自动运行。 如果我使用Console.ReadLine(),它将等到用户输入内容,而我希望程序在30秒内没有输入任何内容的情况下继续循环。 。 。 有什么想法吗?? 例如: RunProcess>等待30秒进行用户输入。 如果没有:继续循环 非常感谢!

团结和代表

我正在使用Unitydependency injection框架。 我有两个类,每个类在构造函数中使用相同的delegate参数。 解决后,每个类应该获得不同的方法。 我可以不使用属性进行设置吗? 如果不是,你会如何使用属性?

entity framework快照历史记录

我试图弄清楚如何使用Code First Entity Framework并保留某些表的快照历史记录。 这意味着对于我想要跟踪的每个表,我希望有一个后缀为_History的重复表。 每次我对跟踪的表行进行更改时,数据库中的数据都会在将新数据保存到原始表之前复制到历史表中,并且版本列会递增。 所以想象我有一个名为Record的表。 我有一排(ID:1,名称:一,版本:1)。 当我将其更改为(ID1:Name:Changed,Version:2)时,Record_History表获取一行(ID:1,Name:One,Version:1)。 我已经看到了很好的示例,并且知道有些库可以使用Entity Framework保留更改的审核日志,但我需要在SQL报告的每个修订版本中提供实体的完整快照。 在我的C#中,我有一个基类,我的所有“Tracked”表等效实体类都inheritance自: public abstract class TrackedEntity { [Column(TypeName = “varchar”)] [MaxLength(48)] [Required] public string ModifiedBy { get; set; } [Required] public DateTime Modified { get; set; } public int Version { get; set; } } 我的一个实体类的示例是: public sealed class Record : TrackedEntity { [Key] public […]

如何将ASP.NET MVC应用程序读取权限授予注册表项?

我已经阅读了有关如何实现这一目标的其他post,但无济于事。 当我将我的应用程序部署到服务器(2008)时,我在运行时收到以下exception: Access to the registry key ‘HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\TeamFoundation\Servers’ is denied. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.UnauthorizedAccessException: Access to the registry key ‘HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\TeamFoundation\Servers’ is denied. ASP.NET is not […]

XNA DrawString()仅绘制部分字符串

我在XNA遇到DrawString()问题。 我为多个逻辑层使用多个SpriteBatches 。 例如:背景,对象,菜单等。 在我的菜单批处理中,我绘制了一个菜单(背景中的大灰色框),按钮(菜单上较小的灰色框)和按钮的字符串。 问题: http : //ompldr.org/vaGw4YQ/Unbenannt.png 但由于某种原因,字符串不是完全绘制的。 有谁知道为什么? 编辑: _menuLayer.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend); if (_menu != null) { _menuLayer.Draw(_menuBoard, new Vector2(graphics.PreferredBackBufferWidth / 2 – 160, graphics.PreferredBackBufferHeight / 2 – 240), Color.White); } _menuLayer.End(); _buttonLayer.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend); if (_menu != null) { foreach (Button button in _menu.Buttons) { if (button.Pressed) { _buttonLayer.Draw(_menuButtonPressed, button.Location, Color.White); _buttonLayer.DrawString(_text, button.Text, […]