小编Hos*_*ani的帖子

如何在Visual Studio中对字段,属性和方法进行排序?

我知道为了清楚代码,我必须编写第一个字段然后编写构造函数然后编写方法等.但是我如何在Visual Studio中自动化它?

visual-studio

34
推荐指数
4
解决办法
3万
查看次数

如何为iOS 9设置audioSession类别?

如何访问旧API以设置audioSession类别?我有一个旧iPad,我使用的视频应用程序卡在iOS 9.3上.我正在使用Xcode 10.我认为这只是我需要的方法,但我不确定如何找到它.

func configureAudioSession() {
    let audioSession = AVAudioSession.sharedInstance()
    do {
        if #available(iOS 10.0, *) {
            try audioSession.setCategory(.playback, mode: .moviePlayback, options: .allowBluetooth)
        } else {
            // Fallback on earlier versions
        }
    }
    catch {
        print("Setting category to AVAudioSessionCategoryPlayback failed.")
    }
}
Run Code Online (Sandbox Code Playgroud)

谢谢.

avaudiosession swift

12
推荐指数
1
解决办法
562
查看次数

如何在c#中裁剪倾斜图像

我通过手机拍摄倾斜图像.我想在两侧的两个矩形之间切割图像的部分/部分,以找出它们之间的圆圈.我有中间部分的所有4个坐标,如(x0,y0),(x1,y1),(x2,y2),(x3,y3).

我的形象看起来像, 在此输入图像描述

但作物功能我有类似的东西

public static Bitmap CropImage(int x, int y, int width, int height, Bitmap bitmap)
{

    Bitmap croppedImage;
    var originalImage = bitmap;
    {
        Rectangle crop = new Rectangle(x, y, width, height);
        croppedImage = originalImage.Clone(crop, originalImage.PixelFormat);

    } // Here we release the original resource - bitmap in memory and file on disk.

    return croppedImage;
}  
Run Code Online (Sandbox Code Playgroud)

但上面的功能切割部分为矩形,如第1和第2红色框所示.
我正在寻找切割第3个红色矩形所示部分的代码.我搜索了代码并找到了下面的代码

List<IntPoint> corners = new List<IntPoint>();

corners.Add(new IntPoint(x0, y0));
corners.Add(new IntPoint(x3, y3));
corners.Add(new IntPoint(x1 + 30, y1 + 20));
corners.Add(new IntPoint(x2 + 30, y2 …
Run Code Online (Sandbox Code Playgroud)

c# asp.net image-processing aforge omr

10
推荐指数
1
解决办法
314
查看次数

Spring 表达式语言使用映射作为上下文

我正在使用 spring 表达式语言来解析一些表达式。我遇到这样一种情况:运行表达式的上下文是 BeanUtils 创建的映射或动态 bean

Map<String, Object> props= new HashMap<>();
props.put("name", "john");
ExpressionParser parser = new SpelExpressionParser();
EvaluationContext context = new StandardEvaluationContext();
Expression exp = parser.parseExpression("name==john");
boolean s  = exp.getValue(context, Boolean.class);
Run Code Online (Sandbox Code Playgroud)

这会爆炸,因为名称不是上下文中定义的公共属性。关于如何使用 spring 表达式语言来实现此类功能的任何想法

java spring

9
推荐指数
2
解决办法
6872
查看次数

如何诊断GCM结果为"成功"但未到达设备的通知

这实际上是我发布的另一个问题的延续,除了现在我正在使用Azure的推送通知遥测,Google在Play控制台中停止了FCM诊断.

我收到用户的报告称他们没有收到通知.但Azure遥测会显示这些结果,即使对于这些通知:

"GcmOutcomeCounts": {
    "Outcome": {
        "Name": "Success",
        "Count": "1"
    }
}
Run Code Online (Sandbox Code Playgroud)

Crashlytics没有显示崩溃,所以我唯一想到的就是调用日志API来查看它失败或停止工作的地方,但在这种情况下它甚至都没有到达应用程序.

必须有一种方法来确定通知失败的确切位置和原因.它是什么?

android azure push-notification firebase-cloud-messaging

7
推荐指数
1
解决办法
299
查看次数

如何在 .net 标准项目中通过 nuget 获取 stylecop 规则集

我们正试图为我们所有的项目提供一个带有 stylecop 规则集的 nuget 包。我们获取了项目中的文件,但规则集不适用于我们的项目。它仍然使用 minimimumrecomended.ruleset。

我们现在拥有的是:

custom.stylecop.props

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <RunCodeAnalysis>true</RunCodeAnalysis>
    <CodeAnalysisRuleSet>Custom.StyleCop.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)

custom.stylecop.targets

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup>
    <AdditionalFiles Include="$(MSBuildThisFileDirectory)\Content\stylecop.json">
      <Link>stylecop.json</Link>
    </AdditionalFiles>
  </ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)

custom.stylecop.nuspec

<contentFiles>
    <files include="Content/stylecop.json" buildAction="EmbeddedResource" />
</contentFiles>
....
<files>
    <file src="build\**" target="build" />
    <file src="Content/stylecop.json" target="contentFiles" />
</files>
Run Code Online (Sandbox Code Playgroud)

有没有人在 github 上有任何想法或示例,我们可以在那里找到示例,因为我们找不到任何示例。

.net c# stylecop nuget .net-standard

7
推荐指数
1
解决办法
2076
查看次数

太空飞船运动-模拟

我已经编写了一些代码来模拟具有单个推进器的船舶的无重力运动。在大多数情况下,它可以正常工作,并且船只可以完美地到达目的地,但有时它会无限加速。但我不知道为什么。

seek(target) {
    var desired = p5.Vector.sub(target, this.position); // A vector pointing from the location to the target
    if (desired.mag()>0.1){

        this.orientation = desired;
        if (this.velocity.heading() - desired.heading() > 0.01 && this.velocity.mag() >0.01) {
            this.orientation = this.velocity.copy().mult(-1);
        }

        if ((this.velocity.mag()*this.velocity.mag())/(2*(this.maxForce/this.mass)) > desired.mag()) {
                this.orientation.mult(-1);
        }

        this.applyForce(this.orientation.normalize().mult(this.maxForce/this.mass));
    } else {
        this.velocity = createVector(0,0);
    }
}
Run Code Online (Sandbox Code Playgroud)

您可以在此处测试结果:

https://editor.p5js.org/Ahiru/sketches/r1rQ9-T5m

javascript p5.js

6
推荐指数
1
解决办法
107
查看次数

OpenXML - 将书签应​​用于word文档中的段落

下面的代码可以正常使用OPENXML(asp.net)并使用HEADING2打印word文档中的元素...我们如何将书签应用于特定的段落..

我们尝试的是在两个HEADING之间提取部分......我们想知道如何应用书签以及我们如何在两个书签之间使用该提取文本...

const string fileName = @"D:\DocFiles\Scan.docx";
const string documentRelationshipType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument";
const string stylesRelationshipType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles";
const string wordmlNamespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
XNamespace w = wordmlNamespace;
XDocument xDoc = null;
XDocument styleDoc = null;

using (Package wdPackage = Package.Open(fileName, FileMode.Open, FileAccess.Read))
{
    PackageRelationship docPackageRelationship =
      wdPackage
      .GetRelationshipsByType(documentRelationshipType)
      .FirstOrDefault();
    if (docPackageRelationship != null)
    {
        Uri documentUri =
            PackUriHelper
            .ResolvePartUri(
               new Uri("/", UriKind.Relative),
                     docPackageRelationship.TargetUri);
        PackagePart documentPart =
            wdPackage.GetPart(documentUri);

        //  Load the document XML in the part into an XDocument instance.  
        xDoc = …
Run Code Online (Sandbox Code Playgroud)

openxml

5
推荐指数
1
解决办法
103
查看次数

如何使用React-Intl呈现格式化消息列表

我有一个navigation标准项目,例如:联系方式,服务,价格等...我将其呈现为:

const menuItemList = menuItems.map((item, index) => {
    return (
        <li key={index}>
            <NavLink to={item.url}>{item.title}</NavLink>
        </li>
    );
});
Run Code Online (Sandbox Code Playgroud)

工作正常。但是现在我需要翻译此导航,并react-intl为此使用库。因此,对于react-intl 文档,我必须这样使用FormattedMessage

<p>
   <FormattedMessage id="mainText"/>
</p> 
Run Code Online (Sandbox Code Playgroud)

有用。但是如何将其用于列表呈现?我认为这可以解决此问题,但事实并非如此。

const menuItemsList = menuItems.map((item, index) => {
    return (
        <li key={index}>
            <NavLink to={item.url}>
                <FormattedMessage id="mainText" values={item.title}/>
            </NavLink>
        </li>
    );
});
Run Code Online (Sandbox Code Playgroud)

伙计们,请帮忙。如何React使用FormattedMessagefrom中的项目渲染列表react-intl

javascript reactjs react-intl

5
推荐指数
1
解决办法
594
查看次数

应该在 using 语句中使用 WebClient 吗?

如果HttpClient的是不应该在使用使用声明,请参阅以下链接: https://aspnetmonsters.com/2016/08/2016-08-27-httpclientwrong/ http://www.nimaara.com/2016/11 /01/beware-of-the-net-httpclient/

因此,如果您不应该在 using 语句中使用 HttpClient ,那么为什么有这么多示例将 WebClient 放在 using 语句中(包括 Microsoft);我还没有看到一篇关于不在using语句中放置 WebClient 的文章?最终在最低级别 WebClient 和 HttpClient 最终在同一个地方打开一个 TCP/IP 套接字。是否介于两者之间使 WebClient 可以放入using语句?

注意我提出这个问题是有原因的:我有一个在 WinXP、Win7 完整系统和嵌入式系统上运行的客户端应用程序,我用来将 XML POST 到我的后端主机(CentOS 系统)的代码如下所示:

void PostXml(string url, string xml, int id) {
    try
    {
        //Console.WriteLine("POST Request: " + xml);
        using (WebClient wc = new WebClient())
        {
            wc.Proxy = null;    //DEBUG: testing this to see if it helps webclient post failure after time x
            wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
            Byte[] d …
Run Code Online (Sandbox Code Playgroud)

c# webclient using httpclient

5
推荐指数
0
解决办法
1785
查看次数