小编Har*_*aka的帖子

如何使Readity实体框架数据上下文

我需要向第三方插件公开实体框架数据上下文.目的是允许这些插件仅获取数据,而不是让它们发出插入,更新或删除或任何其他数据库修改命令.因此,我如何只读取数据上下文或实体.

.net datacontext entity-framework readonly entity-framework-4

103
推荐指数
3
解决办法
4万
查看次数

RxJS中的链接可观察量

我正在学习RxJS和Angular 2.假设我有一个带有多个异步函数调用的promise链,它取决于前一个的结果,如下所示:

var promiseChain = new Promise((resolve, reject) => {
  setTimeout(() => {
    resolve(1);
  }, 1000);
}).then((result) => {
  console.log(result);

  return new Promise((resolve, reject) => {
    setTimeout(() => {
      resolve(result + 2);
    }, 1000);
  });
}).then((result) => {
  console.log(result);

  return new Promise((resolve, reject) => {
      setTimeout(() => {
      resolve(result + 3);
        }, 1000);
  });
});

promiseChain.then((finalResult) => {
  console.log(finalResult);
});
Run Code Online (Sandbox Code Playgroud)

我在不使用promise的情况下单独使用RxJS的尝试产生了以下结果:

var observableChain = Observable.create((observer) => {
  setTimeout(() => {
    observer.next(1);
    observer.complete();
  }, 1000);
}).flatMap((result) => {
  console.log(result);

  return Observable.create((observer) …
Run Code Online (Sandbox Code Playgroud)

javascript reactive-programming promise rxjs rxjs5

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

为什么Github项目文档页面URL区分大小写?有什么负面影响?

我刚刚为我的github项目repo gh-pages分支上传了一个示例index.html页面.但是,用于访问文档的URL似乎区分大小写.正确的网址如下,

http://harindaka.github.com/ASPTokenInput/

但是,如果我在小写github中使用相同的URL显示页面未找到消息.即

http://harindaka.github.com/asptokeninput/

  1. 为什么URL区分大小写?
  2. 这会对搜索引擎可见性和浏览器缓存等产生负面影响吗?
  3. 区分大小写的网址方法有哪些缺点/优点?
  4. 这是否意味着其他一些项目可以在github上的不同情况下具有相同的名称和URL?(颤抖:-O)

提前致谢.

git url github case-sensitive

14
推荐指数
4
解决办法
5655
查看次数

可以防止Child AppDomains中未处理的异常导致主进程崩溃吗?

我正在编写一个小插件库,它使用app域来隔离使用.Net framework 4.0的插件.因此,每个插件中的代码都不受我的控制.当其中一个插件出现未处理的异常时,我发现结果是混合包.它们如下.

当未处理的异常被插入到插件的主线程中时,调用插件的execute方法的主要可插拔应用程序能够清楚地捕获并处理它.没有问题.然而,

  1. 如果插件在插件的Execute方法中启动基于WinForms的应用程序的消息循环,并且在WinForm应用程序中抛出未处理的异常(即在表单中),那么可插拔应用程序只能在Visual Studio调试器内部运行时捕获异常.否则(在VS外部调用时)主插件应用程序与插件一起崩溃.

  2. 如果在插件的Execute方法产生的单独线程中抛出未处理的异常,则可插拔应用程序无法捕获异常并且崩溃.

我创建了一个简单的VS 2010项目,以在下面的链接中模拟此行为. http://www.mediafire.com/file/1af3q7tzl68cx1p/PluginExceptionTest.zip

在其中,可插拔应用程序中的主要方法如下所示

namespace PluginExceptionTest
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Press enter to load plugin");
            Console.ReadLine();

            Assembly entryAsm = Assembly.GetEntryAssembly();
            string assemblyFileName = Path.Combine(Path.GetDirectoryName(entryAsm.Location), "EvilPlugin.exe");


            AppDomainSetup domainSetup = new AppDomainSetup();
            AppDomain domain = AppDomain.CreateDomain("PluginDomain", null, domainSetup);
            PluginBase plugin = (PluginBase)domain.CreateInstanceFromAndUnwrap(assemblyFileName, "EvilPlugin.Plugin");

            Console.WriteLine("Plugin Loaded.");

            //SCENARIO 1: WinForms based plugin
            Console.WriteLine("Press Enter to execute winforms plugin. (Remember to click on the button in the form to raise exception)");
            Console.ReadLine();

            try …
Run Code Online (Sandbox Code Playgroud)

.net crash process appdomain unhandled-exception

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

如何在编译期间生成文本文件并将其内容包含在输出中?

我正在尝试执行与如何在编译时创建静态字符串几乎相同的操作

构建.rs

use std::{env};
use std::path::Path;
use std::io::{Write, BufWriter};
use std::fs::File;

fn main() {
    let out_dir = env::var("OUT_DIR").unwrap();
    let dest_path = Path::new(&out_dir).join("file_path.txt");
    let mut f = BufWriter::new(File::create(&dest_path).unwrap());

    let long_string = dest_path.display();
    write!(f, "{}", long_string).unwrap();
}
Run Code Online (Sandbox Code Playgroud)

主文件

fn main() {

    static LONG_STRING: &'static str = include_str!("file_path.txt");
    println!("{}", LONG_STRING);
}
Run Code Online (Sandbox Code Playgroud)

cargo build我收到错误时:

use std::{env};
use std::path::Path;
use std::io::{Write, BufWriter};
use std::fs::File;

fn main() {
    let out_dir = env::var("OUT_DIR").unwrap();
    let dest_path = Path::new(&out_dir).join("file_path.txt");
    let mut f = …
Run Code Online (Sandbox Code Playgroud)

build build-script embedded-resource rust rust-cargo

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

身份验证后,如何向 ASP.Net Core 中的 OpenIdConnect 中间件生成的身份验证 cookie 添加自定义声明?

我有一个使用 IdentityServer4 Hybrid Auth Flow 的 ASP.Net Core 应用程序项目。设置如下,

public void ConfigureServices(IServiceCollection services)
{
    services.Configure<CookiePolicyOptions>(options =>
    {
        // This lambda determines whether user consent for non-essential cookies is needed for a given request.
        options.CheckConsentNeeded = context => true;
        options.MinimumSameSitePolicy = SameSiteMode.None;
    });

    services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

    JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();

    services.AddAuthentication(options =>
    {
        options.DefaultScheme = "Cookies";
        options.DefaultChallengeScheme = "oidc";
    }).AddCookie("Cookies")
      .AddOpenIdConnect("oidc", options =>
      {   
          options.Authority = IdentityServerUrl;
          options.RequireHttpsMetadata = false;

          options.ClientId = ClientId;
          options.ClientSecret = ClientSecret;
          options.ResponseType = "code id_token";
          options.SaveTokens = true;

          options.GetClaimsFromUserInfoEndpoint = true; …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-core-mvc asp.net-core identityserver4

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

如何使用AnkhSVN将VS2010项目添加到Google Code SVN?

嗨,我需要将以下项目中的源文件添加到Google Code SVN. http://code.google.com/p/tnliveplaya/

我已经在Visual Studio 2010中安装了AnkhSVN,并尝试了"添加Subversion的解决方案",但我不清楚指定什么作为repo URL等或任何其他必要的步骤,因为这是我第一次使用Subversion或subversion客户端.我也提到了Google Code入门指南,但这并没有帮助.

如果您知道如何通过AnkhSVN将VS2010解决方案添加到Google代码,请提供帮助.:(

svn ankhsvn google-code add visual-studio

5
推荐指数
1
解决办法
5059
查看次数

如何将两个JSON对象与Rust合并?

我有两个JSON文件:

JSON 1

{
  "title": "This is a title",
  "person" : {
    "firstName" : "John",
    "lastName" : "Doe"
  },
  "cities":[ "london", "paris" ]
}
Run Code Online (Sandbox Code Playgroud)

JSON 2

{
  "title": "This is another title",
  "person" : {
    "firstName" : "Jane"
  },
  "cities":[ "colombo" ]
}
Run Code Online (Sandbox Code Playgroud)

我想将#2合并到#1,其中#2覆盖#1,产生以下输出:

{
  "title": "This is another title",
  "person" : {
    "firstName" : "Jane",
    "lastName" : "Doe"
  },
  "cities":[ "colombo" ]
}
Run Code Online (Sandbox Code Playgroud)

我检查了crate json-patch,它做了这个,但它不能编译对稳定的Rust.有可能做类似serde_json和稳定的Rust 这样的东西吗?

json rust json-patch serde serde-json

5
推荐指数
2
解决办法
726
查看次数

在以下上下文中,如何解决“引用的生命周期比借用内容的生命周期更长”?

我的 lib.rs 中有以下结构

pub enum ConfigurationSource {
    StringContent(String),
    FileContent(PathBuf)    
}

pub struct ConfigurationBuilder<'a> {
    config: Value,
    bundles: HashMap<&'a str, &'a Vec<ConfigurationSource>>    
}

impl<'a> ConfigurationBuilder<'a>{
    pub fn new(base_source: &ConfigurationSource) -> ConfigurationBuilder{
        let base_config: Value = from_str("{}").unwrap();

        let mut config_builder = ConfigurationBuilder{
            config: base_config,
            bundles: HashMap::new()
        };

        config_builder.merge_source(&base_source);

        return config_builder;
    }

    //more code here

    pub fn define_bundle(&mut self, bundle_key: &str, sources: &Vec<ConfigurationSource>){
        self.bundles.insert(bundle_key, sources);
    }
}
Run Code Online (Sandbox Code Playgroud)

我不希望 ConfigurationBuilder 实例中的包 Hashmap 拥有传递给方法的bundle_keys 或sources define_bundle

我在构建时收到以下两个编译错误

error[E0312]: lifetime of …
Run Code Online (Sandbox Code Playgroud)

struct compiler-errors hashmap rust borrow-checker

5
推荐指数
1
解决办法
1562
查看次数

是否有宏或类似的解决方法可以在编译时包含源文件夹(src)路径?

是否有 Rust 宏或类似的解决方法来包含cargo new在我的源文件中创建的“src”文件夹的路径作为编译时或具体执行时的字符串文字cargo build

我已经成功地完成了类似的操作,用于include_str!包含文件内容,但我需要知道是否可以直接在代码中包含 src 路径。

code-generation compilation rust rust-cargo rust-macros

5
推荐指数
1
解决办法
2147
查看次数