使用UIAutomation获取Datagrid的完整内容

我需要使用UIAutomation从外部应用程序检索Datagrid中的所有项目。 目前,我只能检索(并在UISpy中查看)可见项目。 有没有办法缓存Datagrid中的所有项目然后拉它们? 这是代码: static public ObservableCollection GetLogins() { ObservableCollection returnLogins = new ObservableCollection(); var id = System.Diagnostics.Process.GetProcessesByName(“”)[0].Id; var desktop = AutomationElement.RootElement; var bw = AutomationElement.RootElement.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.ProcessIdProperty, id)); var datagrid = bw.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.AutomationIdProperty, “lv”)); var loginLines = datagrid.FindAll(TreeScope.Children, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.DataItem)); foreach (AutomationElement loginLine in loginLines) { var loginInstance = new Login { […]

在mvc4中的Global.asax中的会话超时重定向

我试图检测会话何时结束,然后在我的全局asax文件中完成此操作后将用户重定向到主页。 我使用下面的代码,我在这里找到 Global.asax中: protected void Session_Start() { if (Context.Session != null) { if (Context.Session.IsNewSession) { string sCookieHeader = Request.Headers[“Cookie”]; if ((null != sCookieHeader) && (sCookieHeader.IndexOf(“ASP.NET_SessionId”) >= 0)) { //intercept current route HttpContextBase currentContext = new HttpContextWrapper(HttpContext.Current); RouteData routeData = RouteTable.Routes.GetRouteData(currentContext); //Substitute route Data Token Values for the Area routeData.DataTokens[“area”] = “”; routeData.DataTokens[“UseNamespaceFallback”] = true; //substitute […]

流利的Apientity framework核心

用户可以拥有1个或0个帐户 public class User { public int UserId { get; set; } public string Name { get; set; } public string Email { get; set; } public Account Account { get; set; } } public class Account { public int AccountId { get; set; } public DateTime CreatedDateTime { get; set; } public User User […]

空字符串加倍C#

此刻我正试图从文本框中获取双倍值,如下所示: String.IsNullOrEmpty(textBox1.Text) ? 0.0 : Double.Parse(textBox1.Text) 但是有一个问题,我无法解决如何解析空文本框? 例如,如果使用带有空文本框的OleDb和Excel尝试此代码,我们将收到错误 System.FormatException:输入字符串的格式不正确。

WebAPI / Owin – 登录后未授权身份

我正在使用WebAPI / Owin 3.0实现简单的登录/密码身份validation。 这是我的配置方法: public void ConfigureAuth(IAppBuilder app) { // Configure the db context and user manager to use a single instance per request app.CreatePerOwinContext(ApplicationDbContext.Create); app.CreatePerOwinContext(ApplicationUserManager.Create); app.UseCookieAuthentication(new CookieAuthenticationOptions() { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString(“/#sign-in”) }); } 这是Login方法 [Authorize] [RoutePrefix(“api/Account”)] public class AccountController : ApiController { [AllowAnonymous] [Route(“Login”)] public async Task Login(LoginBindingModel login) […]

“填充无效,无法删除” – 这段代码有什么问题?

每次运行和加密时,输出都是可变的,当我尝试解密时,我得到“填充无效且无法删除”。 现在和这一天打了一两天,我不知所措。 private static string strIV = “abcdefghijklmnmo”; //The initialization vector. private static string strKey = “abcdefghijklmnmoabcdefghijklmnmo”; //The key used to encrypt the text. public static string Decrypt(string TextToDecrypt) { return Decryptor(TextToDecrypt); } private static string Encryptor(string TextToEncrypt) { //Turn the plaintext into a byte array. byte[] PlainTextBytes = System.Text.ASCIIEncoding.ASCII.GetBytes(TextToEncrypt); //Setup the AES providor for […]

使用Caliburn.Micro MVVM WPF建议视图导航

我是Caliburn Micro的新手,想要了解我的应用程序界面和视图之间导航的路径。 我的想法是有一个MainWindow,它将包含一个按钮菜单,每个按钮与特定视图相关。 每个视图都将存储在单独的WPF UserControl中。 mainWindow还将包含一个TabControl,该TabControl绑定到viewmodel上的ObservableCollection选项卡。 每次单击菜单上的按钮时,我想添加一个内部有ContentPresenter的新选项卡,它将动态加载视图及其相应的视图模型。 所以我的问题: 1)我应该在这里使用屏幕collections吗? 2)UserControl应该实现Screen界面吗? 3)如何告诉MainWindow ViewModel在新添加的选项卡上加载哪个视图来维护viewmodels解耦? 感谢大家提前。 UPDATE 经过大量的阅读和社区的帮助后,我设法解决了这个问题。 这是由此产生的AppViewModel: class AppViewModel : Conductor.Collection.OneActive { public void OpenTab(Type TipoVista) { bool bFound = false; Screen myScreen = (Screen)Activator.CreateInstance(TipoVista as Type); myScreen.DisplayName = myScreen.ToString(); foreach(Screen miItem in Items) { if (miItem.ToString() == myScreen.ToString()) { bFound = true; ActivateItem(miItem); } } […]

unit testing自定义OnRender-Method

我有一个自定义控件MyControl ,它inheritance自Canvas ,并且在OnRender -Method中有自己的逻辑。 它应该在绘图上下文中绘制一些矩形和文本。 public class MyControl : Canvas { protected override void OnRender(DrawingContext dc) { // do something like dc.DrawRectangle(…); // do something like dc.DrawText(…); } } 由于我必须开发测试驱动,我想对OnRender -Method进行unit testing。 我尝试了几种不起作用的解决方案。 所有这些都需要一个inheritance的类用于测试目的,我将调用TestingMyControl并以下面的forms公开OnRender TestingMyControl : public class TestingMyControl : MyControl { public void Render(DrawingContext dc) { base.OnRender(dc); } } 由于DrawingContext是一个抽象类,我想我可以实现一个实现DrawingContext的测试类。 然后我可以收集它应该绘制的所有矩形和文本,并对此进行断言。 问题 : DrawingContext有一个内部构造函数,所以我不能inheritance它。 […]

BuildManager解析页面inheritance

我编写了一个VirtualPathProvider来改变aspx页面加载到ASP.Net应用程序的方式。 作为此过程的一部分,我删除了Code-Behind文件,我只是确定我的页面inheritance自特定的页面类。 例如: 如果我这样做,我会得到以下exception: HttpParseException无法加载类型’Namespace.PageClass’ 我也尝试过以下方法: 这会产生以下错误: HttpParseException无法加载程序集“AssemblyName”。 确保在访问页面之前编译它。 当应用程序启动时,我将所需的Assembly加载到当前的App域中: AppDomain.Current.Load(…) 目前我假设问题在于BuildManager能够解析命名空间/程序集参考….但如果诚实……这是一个猜测:-) 有人能够对此有所了解吗?

可以从时间表列表中观察到

如果我有一个包含时间戳的对象列表 – 如何在时间戳之间的相对时间生成一个可观察到的事件? 例如。 如果我有三个带有时间戳的对象2014-01-01 10:30,2014-01-01 10:45和2014-01-01 11:30,我希望第一个事件立刻开始,接下来的15分钟后,最后一个45分钟后。 我怎样才能加快这个过程,1分钟等于1秒? 因此,第一个事件将像以前一样立即开始,但下一个事件将在15秒后而不是15分钟之后开始,依此类推。