小编ctr*_*yan的帖子

.Net:如何使用TypeDescriptor.GetProperties获取自定义属性?

我创建了自己的属性来装饰我的对象.

 [AttributeUsage(AttributeTargets.All)]
    public class MyCustomAttribute : System.Attribute { }
Run Code Online (Sandbox Code Playgroud)

当我尝试使用传入我的自定义属性的TypeDescriptor.GetProperties时,即使使用该属性修饰了类型,它也不会返回任何内容.

  var props = TypeDescriptor.GetProperties(
              type, 
              new[] { new Attributes.FlatLoopValueInjection()});
Run Code Online (Sandbox Code Playgroud)

如何让TypeDescriptor.GetProperties识别我的自定义类型?

.net custom-attributes typedescriptor

3
推荐指数
1
解决办法
4254
查看次数

WPF实现INotifyPropertyChanged

我已经设置了一个属性并实现了INotifyPropertyChanged

像这样......

public event PropertyChangedEventHandler PropertyChanged;

public FlowProcess LastSelectedFlowProcess
{
    get { return _lastSelectedFlowProcess; }
    set
    {
        _lastSelectedFlowProcess = value;
        Notify("LastSelectedFlowProcess");
        UpdateFlows();
    }
}

private void Notify(string propName)
{
    if (PropertyChanged != null)
        PropertyChanged(this, new PropertyChangedEventArgs(propName));
}
Run Code Online (Sandbox Code Playgroud)

我在其他类上使用了这个确切的设置,但由于某些原因,在Notify方法中,PropertyChanged变量返回null.

在其他类中,当这个工作时,PropertyChanged事件不为null并且计算为委托?我在这里错过了什么?

我在课堂上调用公共访问器会有所作为吗?

data-binding wpf inotifypropertychanged

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

限制 SQL 临时数据库增长

我在我的生产服务器中面临一个严重的问题,临时数据库呈指数增长。有什么办法可以在不重启SQL服务的情况下恢复tempDB空间?

干杯坎南。

sql-server-2005 tempdb

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

Perl:如何写入除bin之外的目录?

我想在perl中输出一个文件.

我像这样打开文件和输出..

open(my $out, ">",  "output.html") or die "Can't open output.txt: $!";
print $out "something!";
Run Code Online (Sandbox Code Playgroud)

哪个效果很好.如果我把它改成这个

open(my $out, ">",  "c:\somedirectory\output.html") or die "Can't open output.txt: $!";
print $out "something!";
Run Code Online (Sandbox Code Playgroud)

它运行正常(我没有得到'无法打开output.txt'消息),但当我在目录中查看我刚输出的文件不存在.如果我没有路径,则在bin中找到该文件.

我在这里错过了什么?如何让它输出另一个位置.

另外..我使用这个.bat文件运行.pl.

cd\

cd \xampp\perl\bin

perl "C:\somedirectory\languages.pl"

pause
Run Code Online (Sandbox Code Playgroud)

perl

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

jQuery:.each如何引用匹配的对象

我如何获得匹配的元素的引用?'这'不正确.

例如,我在这里尝试提醒元素值.

//how do i get this to reference the object it matches.
$("#txtFirstName,#txtLastName,#txtDOB").each(
    function() { alert(this.val()); }
);
Run Code Online (Sandbox Code Playgroud)

javascript jquery

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

无法识别的属性'targetFramework'.在4.0站点与2.0子文件夹?

我最近将网站升级到.net 4.0.我更改了应用程序池,几乎一切都正常.

但是,由于某种原因,位于"admin"子文件夹中且具有自己的web.config的站点的管理部分仍然在2.0下运行.当我左键单击IIS中的子目录并检查属性的ASP.net选项卡时,它获得ASP.NET版本2.0.50727.

如果我单击"编辑配置",我会收到此错误"尝试读取配置时出现错误".错误消息是:

无法识别的属性'targetFramework'.请注意,属性名称区分大小写.

受保护的Web配置直接看起来像这样

<?xml version="1.0"?>
<!-- 
    Note: As an alternative to hand editing this file you can use the 
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in 
    machine.config.comments usually located in 
    \Windows\Microsoft.Net\Framework\v2.x\Config 
-->
<configuration>
    <appSettings/>
    <connectionStrings/>
    <system.web>
        <authorization>
            <deny users="?"/>
        </authorization>
        <customErrors mode="Off"></customErrors>
    </system.web>
</configuration>
Run Code Online (Sandbox Code Playgroud)

当我尝试导航到管理部分时,我得到"服务器应用程序不可用",并且应用程序日志中的条目抱怨两个不同的版本.

一切都在4.0的同一个应用程序池下运行.为什么子文件夹不是4.0,我该如何解决?

iis .net-4.0

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

如何在没有ConcurrentModificationException的情况下对Collection <T>进行交互并修改其项目?

我需要做这样的事......

Collection<T> myCollection; ///assume it is initialized and filled


for(Iterator<?> index = myCollection.iterator(); index.hasNext();)
{
    Object item = index.next();
    myCollection.remove(item);
}
Run Code Online (Sandbox Code Playgroud)

显然这会引发ConcurrentModificationException ...

所以我尝试了这个但是看起来并不优雅/高效并且抛出了Type安全:从Object到T的未经检查的强制转换警告

Object[] list = myCollection.toArray();
for(int index = list.length - 1; index >= 0; index--) {
 myCollection.remove((T)list[index]);
}
Run Code Online (Sandbox Code Playgroud)

java collections iterator concurrentmodification

0
推荐指数
1
解决办法
500
查看次数