我已经为我的观点设置了文化并在控制器中改变了文化,但我似乎无法找到如何知道我目前在控制器中使用的文化,我正在寻找类似的东西:
public class HomeController : Controller {
public async Task<IActionResult> Index()
{
// Something like the next line
var requestCulture = GetRequestedCulture()
return View();
}
}
Run Code Online (Sandbox Code Playgroud)
感谢你的帮助
我正在使用storyboard作为iOS应用程序,我的故事板看起来像这样:http://d.pr/7yAY(droplr url)
问题是当我单击登录按钮时,我将捕获的用户名发送到事件表视图控制器.为此我使用prepareForSegue函数,但显然当我尝试设置用户名时抛出异常.
我的代码如下:
ViewController.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
- (IBAction) logintButton:(id)sender;
@property (weak, nonatomic) IBOutlet UITextField *username_tf; // textfield
@end
Run Code Online (Sandbox Code Playgroud)
ViewController.m
#import "ViewController.h"
#import "EventsTableViewController.h"
@interface ViewController ()
@end
@implementation ViewController
@synthesize username_tf;
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([[segue identifier] isEqualToString:@"ToMainApp"])
{
EventsTableViewController * dest = (EventsTableViewController *)[segue destinationViewController];
NSString * username = [[NSString alloc] initWithFormat:@"%@", username_tf.text];
[dest setUsername:username];
}
}
- (IBAction) logintButton:(id)sender
{
//NSLog(@"Logint button pressed");
[self performSegueWithIdentifier:@"ToMainApp" sender:sender];
} …Run Code Online (Sandbox Code Playgroud) 我刚刚阅读了https://laravel.com/docs/5.6/passport文档,我有些疑惑,希望有人可以帮助我:
首先,在某些上下文中,我想使用Passport作为为我的移动应用程序(第一方应用程序)提供Oauth身份验证的方法.
当我使用时,php artisan passport:client --password我会找回客户端ID和客户端密钥.这个值是否必须在我的应用上修复?例如,将它们存储为硬编码或"设置"文件?如果不应存储这些值,那么它应该如何工作?
要将用户注册到我的应用程序,我使用:$user->createToken('The-App')->accessToken;我得到的是accessToken将用于发送我的所有请求作为标题(Authorization => Bearer $ accessToken),但究竟什么是"The-App"值?
要登录我正在使用网址的用户:http://example.com/oauth/token并作为参数发送:
{"username":"user@email.com","password":"userpassword","grant_type":"password","client_id":1,//我从命令获得的客户端ID(问题1) "client_secret":"嘘"//我从命令得到的客户端秘密(问题1)}
当我使用前一个端点登录用户时,我得到了一个refresh_token,我读到我可以通过http://example.com/oauth/token/refresh刷新令牌,但我尝试请求刷新我得到错误419,我从csrf验证中删除了url oauth/token/refresh,现在我回来了"message": "Unauthenticated.",我正在提出以下请求:
Content-Type:x-www-form-urlencoded grant_type:refresh_token refresh_token:-refresh-token //我从命令获得的刷新令牌(问题3)client_id:1 //我从命令获得的客户端ID (问题1)client_secret:嘘//我从命令(问题1)范围得到的客户端秘密:''
我应该使用这个端点吗?鉴于我正在努力开发的应用程序,或者没有必要.
oauth/clients*,oauth/personal-access-tokens*是有办法从护照公布的端点删除它们?非常感谢你的帮助!
我正在尝试释放重新分配的内存但我收到错误...
float * foo = NULL;
float * bar = NULL;
void update()
{
...
foo = (float *)malloc( a * 2 * sizeof(float));
...
bar = (float *)realloc( foo, a * 2 * sizeof(float));
...
free( foo );
...
// when i do
if(bar != NULL)
{
free(bar); // <-- error at executing
}
}
Run Code Online (Sandbox Code Playgroud)
我收到错误:http://d.pr/mpBF和visual studio向我显示以下文件:
osfinfo.c
=========
void __cdecl _unlock_fhandle (
int fh
)
{
LeaveCriticalSection( &(_pioinfo(fh)->lock) );
}
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我想在触发时创建一个片段,它将围绕给定的文本.目前我的片段是:
{
"Function Creator Helper": {
"prefix": "_w",
"body": [
"public function $TM_SELECTED_TEXT () {",
" $1",
"}",
],
"description": "Creates a function given the text selection"
}
}
Run Code Online (Sandbox Code Playgroud)
结果如下:
我所做的是:
_w)结果如下:
public function () {
}
Run Code Online (Sandbox Code Playgroud)
但我在期待
public function person () {
}
Run Code Online (Sandbox Code Playgroud)
关于如何制作此片段或如何正确触发它的任何想法?
我正在尝试在UIViewController中使用GLKView,我的代码看起来像这样
CustomViewController.h
#import <UIKit/UIKit.h>
#import <GLKit/GLKit.h>
@interface CustomViewController : UIViewController
{
NSString * name;
}
@property NSString * name;
Run Code Online (Sandbox Code Playgroud)
CustomViewController.m
#import "CustomViewController.h"
@interface CustomViewController ()
@end
@implementation CustomViewController
@synthesize name;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
EAGLContext * context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
CGRect mainScreen = [[UIScreen mainScreen] bounds];
GLKView * …Run Code Online (Sandbox Code Playgroud) 我想使用oscpack(http://code.google.com/p/oscpack/)作为我项目的静态库,但是当我尝试将其添加到示例中时,我会收到链接错误,例如:
1> oscpackd.lib(UdpSocket.obj):错误LNK2019:未解析的外部符号__imp__socket @ 12在函数"public:__thiscall UdpSocket :: Implementation :: Implementation(void)"中引用(?? 0Implementation @ UdpSocket @@ QAE @XZ)
1> oscpackd.lib(UdpSocket.obj):错误LNK2019:未解析的外部符号__imp__closesocket @ 4在函数"public:__thiscall UdpSocket :: Implementation :: ~Installation(void)"中引用(?? 1Implementation @ UdpSocket @@ QAE @ XZ )
...
基本上,我创建了一个用于构建oscpack.lib的解决方案,在项目中我添加了相应的.h和.cpp文件.
然后在示例解决方案中,我添加了我的main.cpp然后我包含了(属性> C/C++>其他包含目录)oscpack库的文件夹,然后在链接器选项卡上我添加了libs的文件夹位置和名称的库.
我正在使用 asp.net-core v1.1.0 :)
我想从服务类而不是从控制器访问应用程序设置值,我的代码是:
应用程序设置.json
// appsettings.json
{
"ImagesDBSettings": {
"Endpoint": "",
"Key": "",
}
}
Run Code Online (Sandbox Code Playgroud)
启动.cs
// Startup.cs
...
public void ConfigureServices(IServiceCollection services)
{
...
services.AddOptions();
services.Configure<ImagesDBSettings>(Configuration.GetSection("ImagesDBSettings"));
...
}
...
Run Code Online (Sandbox Code Playgroud)
ImagesDBSettings.cs
// ImagesDBSettings.cs
public class ImagesDBSettings
{
public string Endpoint { get; set; }
public string Key { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
ImagesDBService.cs
// ImagesDBService.cs
public class ImagesDBService
{
private readonly ImagesDBSettings _settings;
public ImagesDBService(IOptions<ImagesDBSettings> settings)
{
_settings = settings.Value;
}
}
Run Code Online (Sandbox Code Playgroud)
编译时我收到错误:
没有给出与“ImagesDBService.ImagesDBService(IOptions)”所需的形式参数“设置”相对应的参数
关于如何使依赖注入工作有什么想法吗?
我正在使用Ionic选项卡导航
<ion-tabs #mainTabs>
<ion-tab [root]="tab1" tabTitle="Page1" tabIcon="icon-tasks"></ion-tab>
<ion-tab [root]="tab2" tabTitle="Page2" tabIcon="icon-calendar"></ion-tab>
<ion-tab [root]="tab3" tabTitle="Page3" tabIcon="icon-profile"></ion-tab>
</ion-tabs>
Run Code Online (Sandbox Code Playgroud)
一切正常,但是当我点击一个标签时,它会转到该堆栈上的最后一个访问页面而不是堆栈的根页面.
例如:
Page1
Subpage1 (root)
Subpage2
Subpage3 <-- Last visited page
Page2
Page3
Run Code Online (Sandbox Code Playgroud)
如果我在最后访问的页面(Subpage3)上,那么我触摸选项卡Page3然后我触摸选项卡上的Page1它返回到Subpage3但我希望它转到Subpage1这是root.
谢谢你的帮助!
我的班级出现以下错误:"无法在file.do第26行修改非左值子程序调用." 我的file.do看起来像这样:
line 2: use BookController;
line 3: my $bookdb = BookController->new();
...
line 26: $bookdb->dbh = 0;
Run Code Online (Sandbox Code Playgroud)
我的BookController.pm看起来像这样:
#!/usr/bin/perl
package BookController;
use strict;
sub new
{
my $this = shift;
my $class = ref($this) || $this;
my $self = {};
$self->{DBH} = undef;
bless $self, $class;
return ($self);
}
sub dbh
{
my $self = shift;
$self->{DBH} = shift if (@_);
return $self->{DBH};
}
1;
Run Code Online (Sandbox Code Playgroud)
有什么建议?
c++ ×2
ios ×2
angular ×1
asp.net ×1
asp.net-core ×1
asp.net-mvc ×1
c# ×1
class ×1
function ×1
glkit ×1
ionic2 ×1
ionic3 ×1
laravel ×1
memory ×1
oauth ×1
perl ×1
php ×1
storyboard ×1
typescript ×1
visual-c++ ×1