在其中一个项目上,我已切换到C#8。而且我一直在将所有switch语句移到表达式上。但是,我发现我的项目开始工作的方式有所不同,而且我发现这是因为这种switch表达。让我们获取此代码为例
class Program
{
public enum DataType
{
Single,
Double,
UInt16,
UInt32,
UInt64,
Int16,
Int32,
Int64,
Byte
}
static void Main(string[] args)
{
dynamic value1 = 5;
dynamic value2 = 6;
var casted = CastToType(value1, DataType.Int16);
var casted1 = CastToTypeExpression(value2, DataType.Int16);
var type = casted.GetType(); // Int16
var type1 = casted1.GetType(); // Double
var bytes = BitConverter.GetBytes(casted); // byte arr with 2 el => [5, 0] <- expected behavior
var bytes1 = BitConverter.GetBytes(casted1); // byte arr …Run Code Online (Sandbox Code Playgroud) 我决定通过构建博客应用程序来一次学习Angular 4和ASP Net Core 2。我到了要为每个组件存储全局数据的地步。
例如,我希望当用户登录时将登录状态传递给我的导航栏组件,这样我就可以更改按钮,显示当前用户名等。
如何从LoginComponent传递数据到NavbarComponent等?
我有一个这样的查询
return await _ctx.Activities
.Include(a => a.Attributes)
.Include(a => a.Roles)
.Include(a => a.Bookmarks)
.Include(a => a.VideoMetas)
.ThenInclude(vm => vm.Instances)
.Include(a => a.ImageMetas)
.ThenInclude(im => im.Instances)
.Include(a => a.Procedure)
.ThenInclude(p => p.Attributes)
.FirstOrDefaultAsync(a => a.Id == id);
Run Code Online (Sandbox Code Playgroud)
事实证明这是非常缓慢的。在EF 6你可以做的.Include(v => v.VideoMetas.Select(vm => vm.Instances)更快一点(我想,还没有看过 SQL Profiler 和实际查询 tbh)。我该如何优化?我也可以使用EF Plus它有.IncludeOptimized()但没有版本的.ThenInclude(). 我听说我可以使用.Select而不是,.Include()但真的不确定如何在此查询中处理它。
我目前正在实现一个范围滑块,并在滑块的开头有一个标签,该标签位于滑块的正上方。该标签代表量表的低端。现在我需要在滑块末端的相同位置添加一个标签来表示刻度的最高端。但是,我只能让标签出现在刻度的开头但在下面。我正在使用 Bootstrap CSS。
<div class="container">
<label for="agitated">Agitated</label>
<input type="range" min="0" max="10" value="5" id="fader">
</br>
<label for="happy">Happy</label>
<input type="range" min="0" max="10" value="5" id="fader">
</br>
<label for="tired">Tired</label>
<input type="range" min="0" max="10" value="5" id="fader">
</br>
<label for="scared">Scared</label>
<input type="range" min="0" max="10" value="5" id="fader">
</div>
Run Code Online (Sandbox Code Playgroud) I have a string containing 13:00 , i have an duration of 90 for example and i have to convert the duration to hh:mm which i made it. Now i have a string with 1:30. How can i add this 1:30 string to the other 13:00 string so i can compare it with another strings? This is how i conver the duration
var bookH = Math.floor(data[0]['Duration'] / 60);
var bookM = data[0]['Duration'] % 60;
var bookingDurationToHour = bookH + …Run Code Online (Sandbox Code Playgroud) 我必须在视频进度悬停时创建“预览”。我正在使用精灵图像和 WebVTT 文件。使用ffmpeg和imagemagick。然而,从 mp4 视频生成缩略图真的很慢(2 小时和 20 分钟长的视频需要 20-30 分钟)。视频是全高清,H246 编码,2GB 大。使用的命令
"ffmpeg.exe -i largevideo.mp4 -f image2 -bt 20M -vf fps=1/5 thumbs-%03d.jpg"
Run Code Online (Sandbox Code Playgroud)
这意味着每 5 秒视频一次拇指。有没有办法让它更快?prod 中的视频可以更大。
操作系统:Win10,稍后使用ImageMagick从所有使用ffmpeg创建的缩略图创建精灵。
我正在接收分块的文件内容。正如我所阅读的,建议使用 Azure blob 存储的最新 nuget 是Azure.Storage.Blobs,但我找不到任何示例或方法如何以块的形式上传文件?支持吗?
我收到范围作为Range标题。我正在使用这个快速入门
我对单元测试特别是 Angular 非常陌生。我有一个问题,在我的TestBed.configureTestingModule提供程序中,它具有私有 getter,并且该 getter 依赖于从文件中获取值的自定义通用服务。如何模拟此值,而不必依赖搜索特定文件的自定义服务?可以说吸气剂是url。我尝试过
{
provide: SomeService, useValue: {
url: 'www.test.com'
}
},
Run Code Online (Sandbox Code Playgroud)
但后来我的组件出现错误this.someService.SomeFunction is not a function,我错过了什么?
我正在通过创建我们的 wpf 应用程序之一来学习 flutter 和 dart。
但是,我的DataTable抛出异常:
======== Exception caught by rendering library =====================================================
A RenderFlex overflowed by 10.0 pixels on the right.
Run Code Online (Sandbox Code Playgroud)
做了一些研究,有一些选项可以使用Expanded,SingleChildScrollView等等,但仍然没有任何帮助。
如果我让数据行字符串变小,一切都很好。
小工具代码
class WorkList extends StatefulWidget {
WorkListState createState() => new WorkListState();
}
class WorkListState extends State<WorkList> with SingleTickerProviderStateMixin {
List<DataRow> _activities = [
DataRow(
cells: <DataCell>[
DataCell(Text('William')),
DataCell(Text('27')),
DataCell(Text('Associate Professor')),
DataCell(Text('Associate Professor1')),
DataCell(Text('Associate Professor1')),
]
)
];
void initState() {
super.initState();
SystemChrome.setPreferredOrientations([
DeviceOrientation.landscapeRight,
DeviceOrientation.landscapeLeft,
]);
_controller = TabController(length: 2, …Run Code Online (Sandbox Code Playgroud) 我有一个小的 API 可以提供文件服务。请求的文件来自我们的 ClickOnce 应用程序。GET是否可以通过单个GET操作获取所有路由参数,以便构建相对路径,而不是进入请求的文件夹/文件的多个操作。
GET路线示例
/api/ApplicationFiles
/api/ApplicationFiles/somefile
/api/ApplicationFiles/someFolder/somefile
/api/ApplicationFiles/someFolder/someFolder/someFolder/someFile
Run Code Online (Sandbox Code Playgroud)
所以我必须定义多个GET端点。
c# ×4
angular ×2
asp.net-core ×2
azure ×1
dart ×1
ffmpeg ×1
flutter ×1
html ×1
javascript ×1
sql-server ×1