在C#中,如何使用较短的方法(带?)表示以下if else语句:
if (condition1 == true && count > 6)
{
dothismethod(value);
}
else if (condition2 == false)
{
dothismethod(value);
}
Run Code Online (Sandbox Code Playgroud)
我的代码看起来非常混乱这些陈述.有人可以指导我一个很好的资源,如果那么其他捷径语法?
我有2个guid列表:
IEnumerable<dynamic> userids = null;
IEnumerable<dynamic> lsCheckedUsers = null;
Run Code Online (Sandbox Code Playgroud)
userid和lsCheckedUsers列表使用dapper从SQL数据库填充.
我现在希望找到不在lsCheckedUsers中的所有用户标识.
我尝试了以下内容
var userdifference = userids.Where(i => !lsCheckedUsers.Contains(lsCheckedUsers));
var userdifference = userids.Except(lsCheckedUsers);
Run Code Online (Sandbox Code Playgroud)
以上都没有实际返回2之间的差异.
如何获得两者中不存在的guid的区别.
我确信lsCheckedUsers有用户ID中的Guids
如何格式化以下Redis连接字符串:
连接字符串:myIP,keepAlive = 180,ConnectRetry = 30,ConnectTimeout = 5000
我开始编写单元测试,但一直得到一个输入字符串没有正确的格式错误消息
[TestFixtureSetUp]
private void Init()
{
var redisConnectionString = "myIP,keepAlive=180,ConnectRetry=30,ConnectTimeout=5000";
_clientsManager = new PooledRedisClientManager(redisConnectionString);
}
[Test]
public void CanConnectToRedis()
{
var readWrite = (RedisClient) _clientsManager.GetClient();
using (var redis = _clientsManager.GetClient())
{
var redisClient = redis;
}
}
Run Code Online (Sandbox Code Playgroud) 如何减少 MigraDoc 文档的上边距?
我在文档的右上角添加了一个图像,但是文档顶部和图像之间的空间太大。
这是我设置图像的方法:
Section section = document.AddSection();
Image image = section.AddImage(@"C:\img\mentSmallLogo.png");
image.Height = "1.5cm";
image.Width = "4cm";
image.LockAspectRatio = true;
image.RelativeVertical = RelativeVertical.Line;
image.RelativeHorizontal = RelativeHorizontal.Margin;
image.Top = ShapePosition.Top;
image.Left = ShapePosition.Right;
image.WrapFormat.Style = WrapStyle.Through;
Run Code Online (Sandbox Code Playgroud)
以及文档样式:
Style style = document.Styles["Normal"];
style.Font.Name = "Verdana";
style = document.Styles[StyleNames.Header];
style.ParagraphFormat.AddTabStop("16cm", TabAlignment.Right);
style = document.Styles[StyleNames.Footer];
style.ParagraphFormat.AddTabStop("8cm", TabAlignment.Center);
// Create a new style called Table based on style Normal
style = document.Styles.AddStyle("Table", "Normal");
style.Font.Name = "Verdana";
style.Font.Name = "Times New Roman";
style.Font.Size = …Run Code Online (Sandbox Code Playgroud) 我正在尝试连接到我的c#.Net应用程序中的MySQL数据库
我尝试连接时收到此错误:不支持关键字:'port'.
该错误似乎表明我的连接字符串存在问题
<add name="mydataEntities" connectionString="server=myserver.com;port=3306;password=xxxx;user id=yyyy;database= mydatabase;persistsecurityinfo=True" providerName="MySql.Data.MySqlClient" />
Run Code Online (Sandbox Code Playgroud)
我有参考添加:MySql.Data 6.9.7.0(MySQL的ADO.Net驱动程序)和MySql.Data.Entity.EF6 6.9.7.0(支持实体框架6.0)
在我的配置中,我有:
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Culture=neutral, PublicKeyToken=c5687fc88969c44d">
</provider>
</providers>
</entityFramework>
<dependentAssembly>
<assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.9.7.0" newVersion="6.9.7.0" />
</dependentAssembly>
<system.data>
<DbProviderFactories>
<remove invariant="MySql.Data.MySqlClient" />
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>
Run Code Online (Sandbox Code Playgroud)
连接字符串在这里设置:
public class Repository
{
protected mydataEntities DbContext;
public Repository()
{ …Run Code Online (Sandbox Code Playgroud) 我最近在 beanstalk 上部署了一个新的 node.js 应用程序并不断遇到以下错误?
[实例:i-cce89e4a] 命令在实例上失败。返回代码:1 输出:(TRUNCATED)...opt/elasticbeanstalk/containerfiles/ebnode.py", line 180, in npm_install raise e subprocess.CalledProcessError: Command '['/opt/elasticbeanstalk/node-install/node-v4 .4.6-linux-x64/bin/npm', '--production', 'rebuild']' 返回非零退出状态 254。挂钩 /opt/elasticbeanstalk/hooks/configdeploy/pre/50npm.sh 失败。了解更多详细信息,请使用控制台或 EB CLI 检查 /var/log/eb-activity.log。
我的节点版本是:4.4.7
部署似乎在下面的最后一行失败:
except Exception, e:
npm_debug_log = '/var/log/nodejs/npm-debug.log'
app_npm_debug_log = os.path.join(app_path, "npm-debug.log")
write_event('Failed to run npm install. Snapshot logs for more details.', 'ERROR')
if not os.path.exists(app_npm_debug_log):
utc_time_str = datetime.datetime.utcnow().strftime("UTC %Y/%m/%d %H:%M:%S")
err_msg = str.format("{0} cannot find application npm debug log at {1} \n", utc_time_str, app_npm_debug_log)
print(err_msg)
with open(npm_debug_log, 'a') as f:
f.write(err_msg) …Run Code Online (Sandbox Code Playgroud) 在我的 node.js 应用程序中,我想上传一个文件并计算 sha1 。
我尝试了以下操作:
export function calculateHash(file, type){
const reader = new FileReader();
var hash = crypto.createHash('sha1');
hash.setEncoding('hex');
const testfile = reader.readAsDataURL(file);
hash.write(testfile);
hash.end();
var sha1sum = hash.read();
console.log(sha1sum);
// fd.on((end) => {
// hash.end();
// const test = hash.read();
// });
}
Run Code Online (Sandbox Code Playgroud)
该文件是通过在我的网站上使用文件上传按钮选择文件而形成的。
如何计算 sha1 哈希值?
我最近在我的Ubuntu Linux机器上安装了ffmpeg版本0.8.5-4:0.8.5.
当我执行"ffprobe -show_frames http://test.com/test.mp4 "时,我收到以下错误:
无法识别的选项'show_frames'
我已经尝试安装各种ffmpeg依赖包来修复这个没有任何成功.
有人可以帮我解决这个错误,告诉我需要安装什么才能解决这个问题吗?
谢谢
如何隐藏默认的选择文件按钮?
这是我的html:
<div class="col-md-4">
<span class="btn btn-info "><i class="glyphicon glyphicon-plus"> </i> Browse
<input type="file" style="position:relative;overflow:hidden" id="inPutArtistImage" name="ArtistImage" accept="image/png, image/jpeg" />
</span>
</div>
Run Code Online (Sandbox Code Playgroud)
该按钮的样式很好,带有引导按钮信息颜色和加号图标。
我根本无法摆脱灰色的“选择文件”按钮。任何帮助表示赞赏。
我已经在StackOverflow上尝试了所有解决方案
我是视频编码的新手,并尝试为apple itunes视频商店编码音乐视频.
我目前正在使用FFmpeg进行编码.
我的源文件是mp4文件类型,文件大小= 650MB
我使用Apple ProRes 422(HQ)编解码器对文件进行编码并输出mov文件.
ffmpeg -y -i busy1.mp4 -vcodec prores -profile:v 3 -r "29.97" -c:a mp2 busy2.mov
Run Code Online (Sandbox Code Playgroud)
我正在尝试根据以下规范对视频进行编码:
●Apple ProRes 422(HQ)●VBR预计为~220 Mbps
编码PASP转换为ProRes从1920 x 1080 1:1 HDCAM SR,D5,ATSC 1280 x 720 1:1 ATSC渐进
视频源每秒29.97个隔行扫描帧
音乐视频音频源配置文件
●MPEG-2第二层立体声●384 kpbs●48Khz
该文件编码完全正常,但输出大小为6Gb.
编码后为什么文件会这么大?
我在这里做错了吗?