小编Spy*_*Spy的帖子

Windows Phone 7引脚用于从应用程序内部启动磁贴

我为我的应用程序制作了大约100个Hubtiles,我希望他们在点击时读取XML文件,并且用户能够在应用程序外的屏幕上"固定"所需的Hubtile.

每个Hubtile都读取不同的XML文件,并且必须能够固定以启动.

我知道要启动它的代码,并且我知道使它读取XML的代码,但是有100个区块,这将是许多编码和复制/粘贴行.

这是我的代码,可以从应用程序中弹出一个tile,并固定在xaml上:

<toolkit:HubTile Name="Monday" Title="Monday" Source="Days\Weekdays\Monday.png" Margin="15" Tap="day_Tap">
    <toolkit:ContextMenuService.ContextMenu>
        <toolkit:ContextMenu>
            <toolkit:MenuItem Name="monday" Header="pin to start" Tap="monday_Tap"/>
        </toolkit:ContextMenu>
    </toolkit:ContextMenuService.ContextMenu>
</toolkit:HubTile>
Run Code Online (Sandbox Code Playgroud)

以及CS文件背后的代码,用于制作并检查它是否已存在:

private void monday_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
    CreateLiveTile(Monday, "path-to-xml", "monday_Square_0.png");
}

private void CreateLiveTile(HubTile hubtile, string link, string id)
{
    StandardTileData LiveTile = new StandardTileData
    {
        Title = hubtile.Title,
        BackBackgroundImage = (hubtile.Source as BitmapImage).UriSource
    };
    ShellTile Tile = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("id=" + id));
    {
        if (Tile == null)
        {
            ShellTile.Create(new Uri("/Show.xaml?id=" + id + "&link=" + link, UriKind.Relative), …
Run Code Online (Sandbox Code Playgroud)

c# xml windows-phone-7

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

集成测试 multipart/form-data c#

我在尝试为我的后调用创建一个集成测试时遇到了麻烦,该测试接受一个具有其他值的视图模型,一个 IFormFile,它使此调用从 application/json 到 multipart/form-data

我的 IntegrationSetup 类

protected static IFormFile GetFormFile()
        {
            byte[] bytes = Encoding.UTF8.GetBytes("test;test;");

            var file = new FormFile(
                baseStream: new MemoryStream(bytes),
                baseStreamOffset: 0,
                length: bytes.Length,
                name: "Data",
                fileName: "dummy.csv"
            )
            {
                Headers = new HeaderDictionary(),
                ContentType = "text/csv"
            };

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

我的测试方法

public async Task CreateAsync_ShouldReturnId()
        {
            //Arrange
            using var content = new MultipartFormDataContent();
            var stringContent = new StringContent(
                JsonConvert.SerializeObject(new CreateArticleViewmodel
                {
                    Title = "viewModel.Title",
                    SmallParagraph = "viewModel.SmallParagraph",
                    Url = "viewModel.Url",
                    Image = GetFormFile()
                }), …
Run Code Online (Sandbox Code Playgroud)

c# integration-testing web-api-testing asp.net-core asp.net-core-webapi

2
推荐指数
1
解决办法
2822
查看次数

如何在asp.net mvc c#项目中插入脚本

当我创建一个默认的mvc asp.net c#项目时,在body标签内的_layout.cshtml上有Render.Body(),在关闭主体之前有jquery和bootstrap的脚本包.当我尝试在我的View中编写脚本时,它表示没有定义jQuery.这很明显,因为脚本包在Render.Body()之后被调用.所以我问这个愚蠢的问题.将包移到Render.Body()上面是不对的?

c# asp.net asp.net-mvc jquery

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