小编And*_*erd的帖子

等待Silverlight单元测试中的事件触发

我正在使用Silverlight单元测试框架来测试一些View Manager类.某些测试需要触发PropertyChanged事件.

我目前正在使用EnqueueConditionalWaitHandles的组合

例1

[TestMethod]
[Asynchronous]
[Timeout(1000)]
public void TestNotificationExample()
{
    var manager = new UserManager();

    var waitHandle = new ManualResetEvent(false);
    manager.PropertyChanged += (sender, propChangArgs) =>
                                {
                                    waitHandler.Set();
                                };
    manager.DoTheThingThatTriggersNotification();
    // The notification event fires aynshronously to this
    EnqueueConditional (() => waitHandler.WaitOne(0));
    // Enqueue other tests here....
    EnqueueTestComplete();
}
Run Code Online (Sandbox Code Playgroud)

这有效.但我有些问题唠叨着我:

我真的需要使用WaitHandle吗?如果我只使用一个bool,它会表现得同样如此吗?

例2

bool fHasFiredEvent = false;
manager.PropertyChanged += (sender, propChangeArgs) =>
                           { 
                               fHasFiredEvent = true;
                           }
manager.DoTheThingThatTriggersNotification();    
EnqueueConditional (() => fHasFiredEvent);
EnqueueTestComplete();
Run Code Online (Sandbox Code Playgroud)

或者如果我保留WaitHandle会更好,但会丢失TimeoutAttribute并在等待时间超时?

例3 …

.net silverlight multithreading unit-testing

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

绘制列图,列之间没有空格

我正在使用WPF工具包,我正在尝试渲染一个看起来像直方图的图形.特别是,我希望每列都与每个列相对应.列之间应该没有间隙.

创建列图时,您应用了许多组件.(参见下面的示例XAML).有没有人知道你是否可以在其中一个元素上设置属性,这些元素指的是列之间的空白宽度?

                <charting:Chart Height="600" Width="Auto" HorizontalAlignment="Stretch" Name="MyChart"
                    Title="Column Graph" LegendTitle="Legend">

                    <charting:ColumnSeries 
                        Name="theColumnSeries"
                        Title="Series A"
                        IndependentValueBinding="{Binding Path=Name}"                
                        DependentValueBinding="{Binding Path=Population}"
                        Margin="0"
                        >
                    </charting:ColumnSeries>

                    <charting:Chart.Axes>
                        <charting:LinearAxis 
                            Orientation="Y" 
                            Minimum="200000" 
                            Maximum="2500000" 
                            ShowGridLines="True" />
                        <charting:CategoryAxis
                            Name="chartCategoryAxis"
                            />
                    </charting:Chart.Axes>
                </charting:Chart>
Run Code Online (Sandbox Code Playgroud)

wpf charts graph wpftoolkit silverlight-toolkit

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

追加数组与自身相反

我创建了一个颜色值数组,表示颜色从红色到蓝色的平滑过渡.

现在我希望这个数组能够让你从红色变为蓝色并再次返回.显而易见的解决方案是将数组的反转附加到数组.

我已经编写了代码来执行此操作,但它无法正常工作.相反,它正在创建反向数组,重复.而不是"从红到蓝,从蓝到红",而是"蓝到红,蓝到红".

很明显,我还没有掌握javascript中的一些数组行为.

我该怎么办?

我的第一次尝试是这样的:

colors = colors.concat(colors.reverse());
Run Code Online (Sandbox Code Playgroud)

基于第一个stackoverflow答案,我试过这个:

var arrayCopy = colors;
arrayCopy.reverse();
colors = colors.concat(arrayCopy);
Run Code Online (Sandbox Code Playgroud)

但这会产生相同的结果!

对于上下文,这是周围的代码:

            ///////////////////////////////////////////////////////////
            // Creating the array which takes you from Red to Blue
            //
            var colorSteps = 400;
            var startColor = [255, 0, 0];
            var endColor = [0, 127, 255];
            var steps = new Array();
            var j = 0;
            for (j = 0; j < 3; ++j) {
                steps[j] = (endColor[j] - startColor[j]) / colorSteps;
            }
            var colors = Array();
            for …
Run Code Online (Sandbox Code Playgroud)

javascript

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

在图像渲染后,MediaPlayer无法渲染到TextureView

我有一个MediaPlayer渲染视频TextureView.这很有效.

现在,我希望在TextureView给定时间MediaPlayer内在此上显示静止图像,然后将视频呈现为相同TextureView.

这是我渲染位图的代码:

Canvas canvas = mTextureView.lockCanvas();
canvas.drawBitmap(sourceBitmap, matrix, new Paint());
mTextureView.unlockCanvasAndPost(canvas);
Run Code Online (Sandbox Code Playgroud)

在此之后,任何播放视频的尝试都会导致ERROR_INVALID_OPERATION(-38)从视频播放器触发.

我试着评论出来的电话drawBitmap,但错误仍然发生了.如此看来,中调用简单的动作lockCanvas,然后unlockCanvasAndPost在结果TextureView是不适合MediaPlayer使用.

有什么方法可以将其重置为TextureView允许MediaPlayer使用它的状态吗?

我正在研究Android 4.2.2.

video android android-mediaplayer textureview

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

通过"新"azure门户配置端点监控

我正在阅读2015年3月发布的" 考试参考70-532开发Microsoft Azure解决方案 "一书.在第一章中,它有一个"配置端点监视"部分,其中提供了使用经典管理门户配置端点监视的步骤和预览门户.

按照给出的步骤,我可以通过经典门户设置端点监控.

但是,我似乎无法通过新门户网站这样做.

以下是本书中列出的前两个步骤:

  1. 导航到通过https://portal.azure.com访问的门户网站中的网站刀片
  2. 向下滚动到"监控",然后单击"Web测试".

我在我的网站的azure门户网站上看不到任何对"监控"或"Webtests"的引用.

此功能是否已从预览门户中删除?

有没有办法通过新门户配置端点监控?

azure

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

具有OpenIdAuthentication的ASP.NET:如果未授权,则重定向到url

我正在尝试编写使用混合身份验证方案的ASP.NET应用程序。用户可以将其用户名和密码哈希存储在UserStore中,也可以通过Azure Active Directory进行身份验证。

我创建了如图所示的登录表单。它具有标准UserNamePassword输入,还具有“通过Active Directory登录”按钮。

在此处输入图片说明

这很好。

现在解决问题:应用程序的主页具有[Authorize]属性。

public class DefaultController : Controller
{
    [Authorize]
    public ViewResult Index()
    { 
    // Implementation
    }
}
Run Code Online (Sandbox Code Playgroud)

如果用户未登录,我希望它重定向到page Account/Login,允许用户选择身份验证方法。

一旦添加IAppBuilder.UseOpenIdConnectAuthentication到管道设置中,它就不再重定向到该页面。而是直接转到“ Microsoft登录”页面。

如何配置它,使OpenID身份验证成为系统的一部分,但允许我指定在未验证用户身份时如何执行重定向?

这是我建立管道的代码:

appBuilder.SetDefaultSignInAsAuthticationType(CookieAuthenticationDefaults.AuthenticationType_;
var cookieAuthenticationOptions = new CookieAuthenticationOptions
{
     AuthenticationType = DefaultAuthenticationType.ApplicationCookie,
     LoginPath = new Microsoft.Owin.PathString("/Account/Login"),
     Provider = new Security.CookieAuthenticationProvider()
};
appBuilder.UseCookieAuthentication(cookieAuthenticationOptions);
// Now the OpenId authentication
var notificationHandlers = new OpenIdConnectAuthenticationNotificationHandlers 
{
   AuthorizationCodeReceived = async(context) => {
       var jwtSecurityToken = context.JwtSecurityToken;
       // I've written …
Run Code Online (Sandbox Code Playgroud)

asp.net asp.net-identity azure-active-directory owin-middleware openid-connect

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

C#我遇到的问题是变量没有像我预期的那样发挥作用

我试图模仿一个骰子滚动,如果死亡落在一定数量上然后它做了一些事情,如果它落在另一个数字上它会做其他事情.但是,我遇到了麻烦.它说if (hitPoints = 1)我收到错误的地方:

无法将类型'int'隐式转换为'string'.

但你可以清楚地看到它确实是一个字符串.对此问题的任何帮助将非常感谢,提前谢谢你.

Random r = new Random();
    int hit = r.Next(1, 5);
    string hitPoints = hit.ToString();


    EmbedBuilder builder = new EmbedBuilder();



    if (hitPoints = 1)
    { 
        builder.WithTitle("");
    }
Run Code Online (Sandbox Code Playgroud)

c# string int visual-studio

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

如何让TextBlock逐字地说出"{Binding}"?

在XAML中,如果插入

<TextBlock Text="Hello World" />
Run Code Online (Sandbox Code Playgroud)

你会看到"Hello World"这个词.

如果你插入

<TextBlock Text="{Binding}" />
Run Code Online (Sandbox Code Playgroud)

它将触发数据绑定功能.但是如果我真的希望显示文字是"{Binding}"呢?"

XAML字符串中是否存在等效的转义字符?

或者是我唯一的解决方案:

<TextBlock>Binding</TextBlock>
Run Code Online (Sandbox Code Playgroud)

data-binding wpf xaml text textblock

3
推荐指数
2
解决办法
371
查看次数

将asp.net.mvc添加到ASP.NET:Controllers文件夹

我有一个ASP.NET应用程序,我试图将其转换为混合的ASP.NET/ASP.NET.MVC 4.0应用程序.

我尝试创建一个名为"Controllers"的文件夹,并在其中放置一个.cs文件:

public class PlayerGroupController : Controller
{
    public PlayerGroupController()
    {

    }

    public string Index()
    {
        return "Hello World!";
    }

    public ActionResult LayoutTemplates()
    {
        return View();
    }
}
Run Code Online (Sandbox Code Playgroud)

任何访问"PlayerGroup/LayoutTemplates"的尝试都不起作用(只是得到"未找到"错误)

然后我将此文件移入App_Code,它工作正常.我很高兴我有一些工作,但我宁愿遵循命名文件夹中的控制器类的约定Controllers.

我可以在某处设置一些神奇的设置,以便它开始识别Controllers为代码文件夹吗?

asp.net asp.net-mvc asp.net-mvc-4

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

Microsoft Graph Api:按 GUID 值过滤

我正在尝试使用 Microsoft Graph Api 来获取特定用户的详细信息。

我有一个可以使用图形浏览器演示的问题:https://developer.microsoft.com/en-us/graph/graph-explorer

如果我运行这个查询:

https://graph.microsoft.com/v1.0/users
Run Code Online (Sandbox Code Playgroud)

我获得了用户列表,包括他们的 ID。

我知道我可以通过将 id 附加到 url 来获取一个用户的详细信息。例如,这个查询:

https://graph.microsoft.com/v1.0/users/f71f1f74-bf1f-4e6b-b266-c777ea76e2c7
Run Code Online (Sandbox Code Playgroud)

结果是一位特定用户的详细信息。

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity",
    "id": "f71f1f74-bf1f-4e6b-b266-c777ea76e2c7",
    "businessPhones": [],
    "displayName": "CIE Administrator",
    "givenName": "CIE",
    "jobTitle": null,
    "mail": "admin@CIE493742.onmicrosoft.com",
    "mobilePhone": "+1 3528700812",
    "officeLocation": null,
    "preferredLanguage": "en-US",
    "surname": "Administrator",
    "userPrincipalName": "admin@CIE493742.onmicrosoft.com"
}
Run Code Online (Sandbox Code Playgroud)

$filter但是,就我而言,在字段上应用查询会更容易id

这是我尝试过的以及我得到的错误:

尝试一

.../users?$filter=id eq f71f1f74-bf1f-4e6b-b266-c777ea76e2c7
Run Code Online (Sandbox Code Playgroud)

返回以下消息:

检测到类型不兼容的二元运算符。找到操作符类型“Equal”的操作数类型“Edm.String”和“Edm.Guid”。

尝试二

..../users/$filter=id eq guid'f71f1f74-bf1f-4e6b-b266-c777ea76e2c7'
Run Code Online (Sandbox Code Playgroud)

返回以下消息:

无法识别“id eq guid”f71f1f74-bf1f-4e6b-b266-c777ea76e2c7”中“6”处的“Edm.String”文字“guid”f71f1f74-bf1f-4e6b-b266-c777ea76e2c7”。

odata microsoft-graph-api

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