小编Has*_*sef的帖子

在.NET Core中将视图返回为字符串

我发现了一些文章如何在ASP.NET中将视图返回到字符串,但无法转换为能够使用.NET Core运行它

public static string RenderViewToString(this Controller controller, string viewName, object model)
{
    var context = controller.ControllerContext;
    if (string.IsNullOrEmpty(viewName))
        viewName = context.RouteData.GetRequiredString("action");

    var viewData = new ViewDataDictionary(model);

    using (var sw = new StringWriter())
    {
        var viewResult = ViewEngines.Engines.FindPartialView(context, viewName);
        var viewContext = new ViewContext(context, viewResult.View, viewData, new TempDataDictionary(), sw);
        viewResult.View.Render(viewContext, sw);

        return sw.GetStringBuilder().ToString();
    }
}
Run Code Online (Sandbox Code Playgroud)

假设能够使用以下控制器从控制器调用:

var strView = this.RenderViewToString("YourViewName", yourModel);
Run Code Online (Sandbox Code Playgroud)

当我尝试将上述内容运行到.NET Core时,我遇到了很多编译错误.

我试图将其转换为使用.NET Core,但失败了,任何人都可以帮助提及所需的using ..和所需"dependencies": { "Microsoft.AspNetCore.Mvc": "1.1.0", ... },project.json.

其他一些示例代码在这里, …

c# asp.net razor .net-core asp.net-core

53
推荐指数
7
解决办法
3万
查看次数

在点网核心中使用外部.dll

我有自己的.dll文件,我曾经在nodejs中使用Edge.js,我现在尝试使用dot net core app,但是没有找到/不知道如何访问它,或者定义它.

是否有类似的东西

"files":
{
    "":"MyLibrary.dll"
}
Run Code Online (Sandbox Code Playgroud)

或者喜欢

using MyLibraryFile.dll
Run Code Online (Sandbox Code Playgroud)

这样我可以使用它中的功能?

我的程序集文件结构是: MyLibraryFile.dll

namespace MyLibrary
{
    public class Inventory
    {
        public async Task<object> Invoke(object input)
    {
}
Run Code Online (Sandbox Code Playgroud)

既不工作using MyLbrary;也不 using MyLbraryFile;工作

我需要在MS Code编辑器中使用它,而不是在MS Studio中使用它.并且不想使用NuGet package

c# .net-core

32
推荐指数
2
解决办法
6万
查看次数

如何将数据从子窗口小部件传递到其父窗口

我有以下自定义小部件,它可以创建Switch并读取其状态(true/false)

然后我将这个添加到我的主应用程序小部件(父级),如何让父级知道交换机的值!

import 'package:flutter/material.dart';

class Switchy extends StatefulWidget{
  Switchy({Key key}) : super(key: key);

  @override
  State<StatefulWidget> createState() => new _SwitchyState();
  }

class _SwitchyState extends State<Switchy> {
  var myvalue = true;

  void onchange(bool value) {
    setState(() {
      this.myvalue = value;      // I need the parent to receive this one!
      print('value is: $value');
    });
  }

  @override
  Widget build(BuildContext context) {
    return             
      new Card(
      child: new Container(
        child: new Row(
          mainAxisAlignment: MainAxisAlignment.end,
          children: <Widget>[
            new Text("Enable/Disable the app in the background",
              textAlign: …
Run Code Online (Sandbox Code Playgroud)

dart flutter

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

类声明 - TypeScript 中的类型不存在属性

我是新手typescript,并且尝试将 javascript 代码转换成 typescript,所以我最终得到了下面的代码。我对typescript中的类的理解如下,可能有误,是: 1.定义类后,必须用 来声明后面要使用的参数this,减速的形式为variableName:variableType。2. 在构造函数中,变量可以赋值为this.variableName = x 3. 在methods下面的class变量中可以使用 withthis.

在下面的代码中,我收到了错误[ts] Property 'escapeRegExp' does not exist on type 'typeof Listen'.,如附图所示。

namespace CORE{
    export class Listen{
         commandsList:[RegExp, string, string];
         debugStyle:string;
         optionalParam:RegExp;
         optionalRegex:RegExp;
         namedParam:RegExp;
         splatParam:RegExp;
         escapeRegExp:RegExp;
        constructor(){
            this.commandsList = [];
            this.debugStyle = 'font-weight: bold; color: #00f;';
            this.optionalParam = /\s*\((.*?)\)\s*/g;
            this.optionalRegex = /(\(\?:[^)]+\))\?/g;
            this.namedParam    = /(\(\?)?:\w+/g;
            this.splatParam    = /\*\w+/g;
            this.escapeRegExp  = /[\-{}\[\]+?.,\\\^$|#]/g;
        }

        public static commandToRegExp(command:string):RegExp{
            command …
Run Code Online (Sandbox Code Playgroud)

typescript

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

如何使用 FFI 从 Dart 调用 Go lib

我需要在 中编写一个函数GO,将其编译为共享库,然后从 中调用它Dart。例如,要返回一个密钥,如下面的代码所示:

package main

func getKey() string {
    theKey := "123-456-789"
    return theKey
}

func main() {}
Run Code Online (Sandbox Code Playgroud)

go dart

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

使用vanilla JavaScript在其中心周围旋转SVG rect

这不是另一个问题的重复.我发现这个问题是关于使用XML的中心轮换,尝试使用类似于vanilla的JavaScript实现相同rotate(45, 60, 60)但不适用于我.

与我合作的方法是下面的片段中的一个,但发现矩形不是围绕其中心旋转,并且它移动了一点点,矩形应该在第一次点击时开始旋转,并且应该在第二次点击时停止,我很好.

任何想法,为什么项目在移动,以及如何解决它.

var NS="http://www.w3.org/2000/svg";  
var SVG=function(el){
    return document.createElementNS(NS,el);
}

var svg = SVG("svg");
    svg.width='100%';
    svg.height='100%';
document.body.appendChild(svg);

class myRect {
  constructor(x,y,h,w,fill) {
   this.SVGObj= SVG('rect'); // document.createElementNS(NS,"rect");
   self = this.SVGObj;
      self.x.baseVal.value=x;
      self.y.baseVal.value=y;
      self.width.baseVal.value=w;
      self.height.baseVal.value=h;
      self.style.fill=fill;
      self.onclick="click(evt)";
      self.addEventListener("click",this,false);
  }
}

Object.defineProperty(myRect.prototype, "node", {
    get: function(){ return this.SVGObj;}
});

Object.defineProperty(myRect.prototype, "CenterPoint", {
    get: function(){ 
                   var self = this.SVGObj;
                   self.bbox = self.getBoundingClientRect();  // returned only after the item is drawn   
                   self.Pc = {
                       x: self.bbox.left + self.bbox.width/2,
                       y: …
Run Code Online (Sandbox Code Playgroud)

javascript svg

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

How can a range be used in a Vec?

This code works fine:

fn main() {
    let v: i32 = vec![1, 2, 3, 4, 5].iter().map(|&x: &i32| x.pow(2)).sum();
    println!("{}", v);
}
Run Code Online (Sandbox Code Playgroud)

I tried to replace the vec![1, 2, 3, 4, 5] with vec![1..5] but iter and map did not work:

fn main() {
    let v: i32 = vec![1, 2, 3, 4, 5].iter().map(|&x: &i32| x.pow(2)).sum();
    println!("{}", v);
}
Run Code Online (Sandbox Code Playgroud)

I've also asked this question on the Rust user's forum.

rust

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

将Rust + Flutter + Kotlin集成到移动应用程序中

下周将为Rust 2018和Flutter 1.0启动importat,我想用构建一个使用Rust作为业务逻辑的应用程序和Flutter作为用户界面,可以在Android和iOS上运行,我构建了一个并在Android上测试它它工作正常.

我只是想知道如何衡量性能并将其与原生Android/iOS应用进行比较.

应用流程是:

  1. 主要在Flutter中,即通过platform_channel调用本机函数
  2. 本机函数通过JNI调用生锈库(JNI包装器需要调用生锈库)

结构如下:

在此输入图像描述

使用的代码是:

main.dart:

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  static …
Run Code Online (Sandbox Code Playgroud)

android rust dart kotlin flutter

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

dart lang 中的自定义注释/元数据

谁能给我解释一下 Dart 中注释的使用吗?

在文档中,我找到了这个例子:

library todo;

class todo {
  final String who;
  final String what;

  const todo(this.who, this.what);
}
Run Code Online (Sandbox Code Playgroud)

其次是

import 'todo.dart';

@todo('seth', 'make this do something')
void doSomething() {
 print('do something');
}
Run Code Online (Sandbox Code Playgroud)

那么,我应该在 main() 中编写什么来执行 doSomething() 函数呢?

谢谢

dart dart-mirrors

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

ListView.builder 不工作

在尝试实现flutter-firebase 时ListView.builder未能显示!

请注意,当我尝试在没有ListView.builder它的情况下显示第一个元素时,它工作正常,即错误仅与此代码块相关:

return ListView.builder(
    itemCount: snapshot.data.documents.length,
    padding: const EdgeInsets.only(top: 10.0),
    itemExtent: 25.0,
    itemBuilder: (context, index) {
    DocumentSnapshot ds = snapshot.data.documents[index];
    return Text(" ${ds['name']} ${ds['vote']}");
});
Run Code Online (Sandbox Code Playgroud)

我的完整代码是:

import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';

void main() => runApp(MyApp(
  textInput: Text("Text Widget"),
));

class MyApp extends StatefulWidget {
  final Widget textInput;
  MyApp({this.textInput});

  @override
  State<StatefulWidget> createState() => MyAppState();
}

class MyAppState extends State<MyApp> {
  bool checkBoxValue = false;
  @override
  Widget build(BuildContext ctxt) {
    return new MaterialApp(
      home: SafeArea(
        child: …
Run Code Online (Sandbox Code Playgroud)

dart flutter

6
推荐指数
2
解决办法
3094
查看次数