Windows Universal(Windows 10应用程序)中的Geolocation新API提供了一种允许访问用户位置的新方法.
从Windows 10开始,在访问用户的位置之前调用RequestAccessAsync方法.那时,您的应用必须位于前台,并且必须从UI线程调用RequestAccessAsync.
我在UI线程上运行一些非常简单的Geolocation代码,如下所示,但我每次都获得"拒绝"的位置权限,并且没有提示允许位置权限.有没有其他人遇到这个?如何获得在Windows 10应用程序中允许地理位置的位置权限的提示?
地理定位方法
private async Task<ForecastRequest> GetPositionAsync()
{
try
{
// Request permission to access location
var accessStatus = await Geolocator.RequestAccessAsync();
if (accessStatus == GeolocationAccessStatus.Allowed)
{
// Get cancellation token
_cts = new CancellationTokenSource();
CancellationToken token = _cts.Token;
// If DesiredAccuracy or DesiredAccuracyInMeters are not set (or value is 0), DesiredAccuracy.Default is used.
Geolocator geolocator = new Geolocator { DesiredAccuracyInMeters = _desireAccuracyInMetersValue };
// Carry out the operation
_pos = await geolocator.GetGeopositionAsync().AsTask(token);
return new …Run Code Online (Sandbox Code Playgroud) 在工作中,我们经常使用Unity.它的功能非常棒,但您使用的越多,配置文件越多,运行时问题就越多,您为每个测试项目重新创建统一配置的次数就越多.
因此,我们最终与具有翻过几个项目被复制,当谈到时间部署,你最终不得不追查你忘记添加到引用的DLL一个巨大的统一配置部分,但你只发现这些在运行时.不好玩.
我猜测有人遇到过这个问题而且有一个解决方案.理想情况下,我想弄清楚如何以一种使用约定优于配置的方式配置Unity,并减少运行时问题(即,庞大的配置文件).有人知道用最小配置实现Unity的好方法吗?
编辑:有一件事:我必须坚持只使用Unity.无法真正切换到Ninject等
我正在尝试用下拉列表做最简单的事情,但它只是不起作用.我有一个名为的整数属性SearchCriteria.Distance.这是一个简单的整数属性.我正在尝试将该属性绑定到整数的drowpdown列表,但它不会绑定.价值总是如此0.这是代码:
@Html.LabelFor(x => x.SearchCriteria.Distance, "Radius (miles)", new { @class="control-label" })
<div class="controls">
@Html.DropDownListFor(x => x.SearchCriteria.Distance, new SelectList(new int[] { 5, 15, 25, 50 }), new { @class="input-small", style="height:36px;"})
</div>
Run Code Online (Sandbox Code Playgroud)
因为它是一个简单的整数列表,所以不要Text Value将它与之关联起来.我在这做错了什么?
编辑:原来这个问题是我的一个愚蠢错误的结果.我有一个隐藏的字段,SearchCriteria.Distance我的表单上的id,我忘了,这阻止了设置下拉值.我将下面的解决方案标记为答案,因为它是正确的.
除了 Telerik 之外,是否还有与新的 UWP Windows 10 应用程序框架兼容的图表/数据可视化库?我遇到过许多图表库,但没有一个与这种新的 UWP 项目类型兼容。
我正在使用ServiceStack构建一个相当简单的服务,但是我在我的几个服务上遇到了这个非描述性错误(在浏览器中尝试查看uri时).errorCode:RequestBindingException.消息:无法绑定请求.
这是我的DTO:
[Route("/jtip/cases/{Count}, GET")]
public class AgencyCaseSummary : IReturn<AgencyCaseSummaryResponse>
{
public int Count { get; set; }
}
public class CaseSummary
{
public int Id { get; set; }
public string AgencyCaseNumber { get; set; }
public string AgencyRepName { get; set; }
public string Service { get; set; }
public string Milestone { get; set; }
public string Status { get; set; }
}
public class AgencyCaseSummaryResponse
{
public List<CaseSummary> CaseSummary { get; set; }
public int ActiveCaseCount { …Run Code Online (Sandbox Code Playgroud) 我按照Aurelia教程中的示例设置了nav-bar.html和nav-bar.js.后来,我想在nav-bar.js VM中添加一些功能,但发现它的属性或方法都没有调用过.
我正在尝试在我的顶部导航中使用Aurelia Auth过滤,但即使省略了auth功能,也无法调用top-nav-bar.js中的任何内容.
代码如下:
顶级NAV-bar.js
import {bindable} from 'aurelia-framework';
import {inject} from 'aurelia-framework';
import {AuthService} from 'aurelia-auth';
//import {AuthFilterValueConverter} from './authFilter';
//import {Router} from 'aurelia-router';
@inject(AuthService )
export class TopNavBar {
_isAuthenticated=false;
@bindable router = null;
constructor(auth){
console.log('called nav bar constructor'); //NEVER CALLED
this.auth = auth;
}
//@computedFrom(this.auth)
get isAuthenticated(){
return this.auth.isAuthenticated(); //NEVER CALLED
}
}
Run Code Online (Sandbox Code Playgroud)
顶级NAV-一个bar.html
<template>
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<!-- <require from="paulvanbladel/aurelia-auth"></require> -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle Navigation</span>
<span class="icon-bar"></span> …Run Code Online (Sandbox Code Playgroud) 我在Aurelia视图中有一个简单的选择列表,我试图在'Select ...'上设置默认值.我还使用aurelia-validation插件来确保在提交表单之前更改值.该插件非常适合我项目中的其他字段类型.
<div class="form-group">
<label for="agencies" class="control-label">Agency</label>
<select value.bind="agencyId" class="form-control">
<option value="">Select..</option>
<option repeat.for="agency of agencies" value.bind="agency.id">${agency.name}</option>
</select>
</div>
Run Code Online (Sandbox Code Playgroud)
在VM中:
constructor(validation) {
this.agencies = null;
this.agencyId = 0;
this.validation = validation.on(this)
.ensure('agencyId')
.isNotEmpty();
}
activate() {
//call api and populate this.agencies
}
Run Code Online (Sandbox Code Playgroud)
页面最初加载后,我在列表中获取我的代理,我的默认值是正确的,但它显示验证错误消息:

其他表单字段(如文本框)不会执行此操作,并且在用户与表单控件交互之前不会显示任何错误消息.
我是否需要为选择列表做一些特殊操作来隐藏视图初始加载时的验证错误?我怀疑在视图中绑定选择列表会以某种方式触发更改事件.
我正在尝试在ServiceStack中使用FluentNHibernate和Funq IoC容器,基于每个请求的会话,我遇到了一个问题,在第二次请求我的服务时,我得到一个ObjectDisposedException.Funq不应该为每个请求创建一个新的Session吗?
我的理解是,通过在Funq中使用ReusedWithin(ReuseScope.Request),每个请求都会得到一个新的ISession,但这只发生在第一个请求中.在我的AppHost中,我有以下内容:
public static NH.ISession CurrentSession
{
get
{
SessionFactory = GetFactory();
NH.ISession session = SessionFactory.OpenSession();
return session;
}
}
private static NH.ISessionFactory GetFactory()
{
return Fluently.Configure().Database(MsSqlConfiguration.MsSql2008
.ConnectionString(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString)).Mappings(m =>
{ m.FluentMappings.AddFromAssemblyOf<Case>(); })
.BuildSessionFactory();
}
Run Code Online (Sandbox Code Playgroud)
并注册容器:
container.Register<NH.ISession>(c => CurrentSession).ReusedWithin(Funq.ReuseScope.Request);
container.Register<ILog>(c => LogManager.GetLogger(GetType()));
Run Code Online (Sandbox Code Playgroud) 我正在使用 ASP.Net Core Web 应用程序,并使用 Startup.cs 类中的典型注册方法来注册我的服务。
我需要访问 IServiceCollection 中注册的服务,以便迭代它们以查找特定的服务实例。
如何使用 ASP.Net Core DI 容器来完成此操作?我需要在控制器之外执行此操作。
下面是我正在尝试做的事情的一个例子。请注意,ServiceCollection 上不存在 All 方法,这就是我想要弄清楚的:
public class EventContainer : IEventDispatcher
{
private readonly IServiceCollection _serviceCollection;
public EventContainer(IServiceCollection serviceCollection)
{
_serviceCollection = serviceCollection;
}
public void Dispatch<TEvent>(TEvent eventToDispatch) where TEvent : IDomainEvent
{
foreach (var handler in _serviceCollection.All<IDomainHandler<TEvent>>())
{
handler.Handle(eventToDispatch);
}
}
}
Run Code Online (Sandbox Code Playgroud) 我需要在两个机场之间找到距离(如空中客车A320飞行,而不是超级准确),最好使用IATA代码(例如PHX,LAX,CLT).
我看到许多网站都这样做,但我需要找到一个API(谷歌地图,Bing地图?),我可以用来计算距离.我知道我可能需要对IATA代码进行地理编码,但我想避免这种情况(我知道使用谷歌地图你可以指定IATA代码+机场,它会得到位置)
有什么建议?
c# ×5
api ×2
aurelia ×2
geolocation ×2
servicestack ×2
uwp ×2
xaml ×2
aurelia-auth ×1
charts ×1
funq ×1
javascript ×1
windows ×1
windows-10 ×1