小编Sex*_*yMF的帖子

访问c#web应用程序中的内容文件

我现在已经有3天这个问题了.
我有一个标记为Content和的xml文件Always Copy.
该文件已复制到:
C:\Users\avi\Documents\Visual Studio 2010\Projects\ExpressBroker\ExpressBroker\bin\XMLMetadata\Actions.1.xml

访问文件时:

//like that:
XDocument actions = XDocument.Load("bin\\XMLMetadata\\Actions.1.xml");
//or like that:
XDocument actions = XDocument.Load("XMLMetadata\\Actions.1.xml");
//or like that:
XDocument actions = XDocument.Load("Actions.1.xml");
Run Code Online (Sandbox Code Playgroud)

我得到以下异常: Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Program Files\IIS Express\bin\XMLMetadata\Actions.1.xml'.

为什么在IIS文件夹中搜索过?我该如何访问该文件?

我正在使用IIs Express和VWD2010

c# xml iis linq-to-xml virtual-directory

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

T4代码模板触发器生成:其他文件保存/ xml更改(VS 2010)

我有一个t4模板,它循环遍历项目中的xml文件并生成代码.
是否可以在保存某个文件或构建项目时使T4运行?
VS 2010

谢谢

.net c# t4

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

从.cs文件获取特定方法源代码(在运行时)

1 -我在光盘上有这个文件内容(cs文件,未编译):

    namespace Test
    {
        using System;
        public class TestClass 
        {
            public string SomeTestMethod(){
                return "test here";
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

如何将运行时间输入变量方法:

public string SomeTestMethod(){
    return "test here";
}
Run Code Online (Sandbox Code Playgroud)

例如: SourceCodeParser.GetMothod("path to file","SomeTestMethod");

2 - 访问者成员的内容是否可能?

   public string SomeMember {
        get {
            return "test here";
        }
    }
Run Code Online (Sandbox Code Playgroud)

c# parsing

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

类似 VueJs 的 Angular ng-init

我使用vuejs,有一段时间我需要在模板中创建新变量。

在角度我可以去:

<div ng-app="" ng-init="myText='Hello World!'">
<h1>{{myText}}</h1>
Run Code Online (Sandbox Code Playgroud)

如何在vuejs 中实现

谢谢!

vue.js

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

Angular 5 将 ElementRef 转换回组件

是否可以转换回ElementRef组件。
我有一种情况,我手上有nativeElement,我需要将它转换为组件。看一下console.log,我想解压出来name,可以投回去吗?谢谢 https://stackblitz.com/edit/angular-8aoq7f?file=src%2Fapp%2Fapp.component.ts

@Component({
  selector: 'my-app',
  template: `<sub-component [name]="'test'"></sub-component>`,
})
export class AppComponent {
 constructor(private ref : ElementRef){
    console.log((<SubComponent>this.ref.nativeElement).name); //<--- .name is undefined
 }
}

@Component({
  selector: 'sub-component',
  template: `<div>{{name}}</div>`,
})
export class SubComponent  {
  @Input() name : string
}
Run Code Online (Sandbox Code Playgroud)

typescript angular

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

Google Analytics拦截所有请求

每当Google Analytics(分析)将数据发送到服务器时,我都希望获得回调。我也想将相同的数据发送到我的服务器。有可能吗?

https://jsfiddle.net/bk1j8u7o/2/

<script async src="https://www.googletagmanager.com/gtag/js?id=UA-143361924-1"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-143361924-1');
</script>
Run Code Online (Sandbox Code Playgroud)

javascript google-analytics

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

NHibernate json代理序列化与ReferencesAny

我有以下映射:

    public class TimeLineEntityMap : BaseEntityMap<TimeLineEntity>
    {
        public TimeLineEntityMap()
        {
            Table("time_line_entity");
            Map(x => x.Message);
            Map(x => x.ResearchId, "research_id");//.Cascade.All().Not.LazyLoad();
            ReferencesAny(x => x.EntityRef)
                .AddMetaValue<EmailEntity>(typeof(EmailEntity).Name)
                .AddMetaValue<UrlEntity>(typeof(UrlEntity).Name)
                .AddMetaValue<PhoneEntity>(typeof(PhoneEntity).Name)
                .EntityTypeColumn("entity_type")
                .IdentityType<long>()
                .EntityIdentifierColumn("entity_ref_id")
                .Not.LazyLoad();
        }
    }
Run Code Online (Sandbox Code Playgroud)

从数据库中获取时EntityRef作为代理。

TimeLineEntity res = timeLineRepository.Find(x => x.Id == id);
JsonConvert.SerializeObject(res);
Run Code Online (Sandbox Code Playgroud)

JsonConvert抛出:

Newtonsoft.Json.JsonSerializationException: Self referencing loop detected for property 'ManifestModule' with type 'System.Reflection.RuntimeModule'. Path 'Data[0].EntityRef._proxyFactoryInfo._getIdentifierMethod.Module.Assembly'.
Run Code Online (Sandbox Code Playgroud)

这是我的json设置:

     x.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
     x.SerializerSettings.ContractResolver = new NHibernateContractResolver();
Run Code Online (Sandbox Code Playgroud)
    public class NHibernateContractResolver : CamelCasePropertyNamesContractResolver
    {
        protected override JsonContract CreateContract(Type objectType)
        {
            if (typeof(NHibernate.Proxy.INHibernateProxy).IsAssignableFrom(objectType)) …
Run Code Online (Sandbox Code Playgroud)

nhibernate json

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

在 .net core 3.1 应用程序中使用 AddEnvironmentVariables

我生成了一个新的网络项目。似乎在 .net core 3.1 中生成了 appSettings.jsons 并且工作正常。问题是它们是由运行时加载和控制的,而不是我。所以我不能调用AddEnvironmentVariables

AddEnvironmentVariables在这种情况下打电话的正确地点在哪里?

public class Startup
{
    public Startup(IConfiguration configuration)
    {
        Configuration = configuration;
    }
}

    public class Program
    {
        public static void Main(string[] args)
        {
            CreateHostBuilder(args).Build().Run();
        }

        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.UseStartup<Startup>();
                });
    }
Run Code Online (Sandbox Code Playgroud)

appsettings .net-core-3.1

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

PyCharm 中的类型检查类静态变量

我在 PyCharm 项目中有以下 Python 代码:

class Category:
    text: str

a = Category()
a.text = 1.5454654  # where is the warning?
Run Code Online (Sandbox Code Playgroud)

当我尝试设置错误类型的属性时,编辑器应该显示警告。看看下面的设置:

PyCharm 设置配置的屏幕截图

python static-variables typechecking pycharm python-typing

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

React NavLink根据isActive改变子元素

我有以下链接:

<NavLink to={x.url} className={(x) = x.isActive ? 'active' : 'not-active' } >
    <img src={`icon-default.svg`} /> // change from default.svg to active.svg       
    Link Text
</NavLink>
Run Code Online (Sandbox Code Playgroud)

img我的图标位于 HTML 而不是 CSS 中,我想根据 isActive 调用不同的 img,是否可以在子元素(标签)上执行此操作?

react-router-dom": "^6.0.2"

谢谢

reactjs react-router react-router-dom

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