小编Ste*_*erg的帖子

命名规则违规

我刚刚安装了visual studio 2017.当我打开一个现有的网站时,我收到各种各样的警告信息,例如:

IDE1006命名规则违规:这些单词必须以大写字符开头:swe_calc

在代码中,它被定义为:

[System.Runtime.InteropServices.DllImport("swedll32.dll")]
public static extern Int32 swe_calc(double tjd, int ipl, Int32 iflag, IntPtr xx, IntPtr serr);
Run Code Online (Sandbox Code Playgroud)

我的asp.net控件也会出现这种情况.作为DropDownList的示例:

IDE1006命名规则违规:这些单词必须以大写字符开头:ddlMonth_SelectedIndexChanged

如何在Visual Studio下消除这些类型的警告?

c# asp.net visual-studio-2017

78
推荐指数
6
解决办法
6万
查看次数

Swift将字符串转换为UnsafeMutablePointer <Int8>

我有一个映射到Swift的C函数定义为:

func swe_set_eph_path(path: UnsafeMutablePointer<Int8>) -> Void
Run Code Online (Sandbox Code Playgroud)

我试图传递一个路径到该功能,并尝试过:

        var path = [Int8](count: 1024, repeatedValue: 0);
        for i in 0...NSBundle.mainBundle().bundlePath.lengthOfBytesUsingEncoding(NSUTF16StringEncoding)-1
        {
            var range = i..<i+1
            path[i] = String.toInt(NSBundle.mainBundle().bundlePath[range])
        }
        println("\(path)")
        swe_set_ephe_path(&path)
Run Code Online (Sandbox Code Playgroud)

但在路径[i]行我得到错误:

'subscript'不可用:不能使用Int范围下标String

swe_set_ephe_path(NSBundle.mainBundle().bundlePath)
Run Code Online (Sandbox Code Playgroud)

也不

swe_set_ephe_path(&NSBundle.mainBundle().bundlePath)
Run Code Online (Sandbox Code Playgroud)

也不工作

除了没有工作,我觉得必须有一个更好,更少复杂的方式来做到这一点.使用CString的StackOverflow以前的答案似乎不再起作用了.有什么建议?

pointers swift xcode6

12
推荐指数
4
解决办法
2万
查看次数

在c#中使用gmail API修改消息标签时,权限[403]不足

我正在尝试使用gmail api阅读gmail邮件,并在阅读邮件后,我正在删除邮件标签,以便我不需要再次处理它.我能够成功读取邮件,但是当我尝试修改邮件时Label
(service.Users.Messages.Modify(mods, userId, messageId).Execute();)

然后我收到错误信息:

发生错误:Google.Apis.Requests.RequestError
权限不足[403]
错误[
消息[权限不足]位置[ - ]原因[insufficientPermis
sions]域[global]>
].

我无法弄明白,可能出了什么问题?提前致谢.

c# gmail-api

8
推荐指数
1
解决办法
3568
查看次数

A.Fake <Stream>().读取(...)抛出InvalidOperationException

使用NUnit 2.6.4和FakeItEasy 1.25.2对Visual Studio 2013 Community Edition中的C#代码进行单元测试

以下测试片段按预期执行

[Test]
public void test_whatIsUpWithStreamRead()
{
    Stream fakeStream = A.Fake<Stream>();

    byte[] buffer = new byte[16];

    int numBytesRead = fakeStream.Read(buffer, 0, 16);

    Assert.AreEqual(0, numBytesRead);

}
Run Code Online (Sandbox Code Playgroud)

但是只要我用CallTo/Returns()或ReturnsLazily()语句装饰我的假货......

[Test]
public void test_whatIsUpWithStreamRead()
{
    Stream fakeStream = A.Fake<Stream>();

    A.CallTo(() => fakeStream.Read(A<byte[]>.Ignored, A<int>.Ignored, A<int>.Ignored)).Returns(1);

    byte[] buffer = new byte[16];

    int numBytesRead = fakeStream.Read(buffer, 0, 16);

    Assert.AreEqual(1, numBytesRead);

}
Run Code Online (Sandbox Code Playgroud)

fakeStream.Read() 抛出System.InvalidOperationException并显示以下消息:

"指定的out和ref参数的值的数量与调用中的out和ref参数的数量不匹配."

从内部FakeItEasy.Configuration.BuildableCallRule.ApplyOutAndRefParametersValueProducer(IInterceptedFakeObjectCall fakeObjectCall),这对我来说似乎很奇怪,因为Stream.Read()没有任何out/ref参数.

这是我应该在https://github.com/FakeItEasy上报告的错误,还是我错过了什么?

谢谢

c# fakeiteasy

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

将 Python 绘图导出为 KML

如何使用 Matplotlib 创建经/纬度图,该图可以导出到 Google Earth,并且点可以正确显示在 GE 上。图片可以在这里看到: https: //i.stack.imgur.com/S2BX7.jpg 谷歌地球视图 似乎我导出的图形周围总是有一个轻微的边框,因此我在图中定义的点在 GE 中是关闭的

x = [0, 10, 10, 0, 0]
y = [10, 10, 0, 0, 10]
x1=[0,1,2,3,4,5,6,7,8,9,10]

fig = Figure(facecolor=None, frameon=False)
ax = fig.add_axes([0,0,1,1])
ax.axis('off')

ppl.plot(x, y, 'r',  axes=ax)
ppl.plot(x, y, '.b', axes=ax)
ppl.plot(x1, x1, 'g', axes=ax)

ppl.axis('off')
ppl.tight_layout(0,h_pad=0, w_pad=0)
border1 = ppl.axis(bbox_inches='tight')
ppl.show()

pngName = 'temp.png'
py.savefig(pngName, bbox_inches='tight', pad_inches=0, transparent=True)

bottomleft  = (border1[0],border1[2])
bottomright = (border1[1],border1[2])
topright    = (border1[1],border1[3])
topleft     = (border1[0],border1[3])

kml = simplekml.Kml()
ground = kml.newgroundoverlay(name='GroundOverlay')
ground.icon.href …
Run Code Online (Sandbox Code Playgroud)

python matplotlib kml

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

是否可以在Visual Studio Mac中使用DLL

我有一个使用第三方DLL的应用程序.在Visual Studio for Mac中是否有一种方法可以像在Windows上一样编写应用程序来访问它?

c# visual-studio-mac

4
推荐指数
1
解决办法
7058
查看次数

如何将流转换为BitmapImage

这是我的代码

 private async void OnGetImage(object sender, RoutedEventArgs e)
        {
            using (HttpClient client = new HttpClient())
            {
                try
                {
                    HttpResponseMessage response = await client.GetAsync(new Uri(txtUri.Text));

                    BitmapImage bitmap = new BitmapImage();

                    if (response != null && response.StatusCode == HttpStatusCode.OK)
                    {

                        using (InMemoryRandomAccessStream stream = new InMemoryRandomAccessStream())
                        {
                            await response.Content.WriteToStreamAsync(stream);
                            stream.Seek(0UL);
                            bitmap.SetSource(stream);
                        }
                        this.img.Source = bitmap;
                    }
                }
                catch (Exception)
                {

                    throw;
                }
            }
        } 
Run Code Online (Sandbox Code Playgroud)

但现在我不能在uwp中使用WriteToStreamAsync(),谁可以帮助我?

c# uwp

0
推荐指数
1
解决办法
3576
查看次数