小编Par*_*kht的帖子

枚举大小以字节为单位

以字节为单位的枚举大小是多少?

public enum MMTPCnxNckRsn 
{
    MMTPCnxNckRsnNoAnswer = -2, 
    MMTPCnxNckRsnSendError = -1, 
    MMTPCnxNckRsnOk = 0, 
    MMTPCnxNckRsnInvalidMember = 1, 
    MMTPCnxNckRsnHubNotReady = 2, 
    MMTPCnxNckRsnUnknownMember = 3, 
    MMTPCnxNckRsnLastCnxTooRecent = 4, 
    MMTPCnxNckRsnInvalidVersion = 5, 
    MMTPCnxNckRsnInvalidOptions = 6, 
    MMTPCnxNckRsnTooManyCnx = 7 
};
Run Code Online (Sandbox Code Playgroud)

我已经使用下面的代码找到它,但我认为它还不够......它是一个包含10个元素的字符串数组.我应该计算每个元素中的字符数,假设每个字符1个字节并添加所有字节的元素?那么无符号数呢?

var size = Enum.GetNames(typeof(MMTPCnxNckRsn)).Length;
var arr = Enum.GetNames(typeof (MMTPCnxNckRsn));
Run Code Online (Sandbox Code Playgroud)

我不确定是否重要的​​是提到我在marshalingc#的本机win32代码中间,并且找到用于管理内存中地址的枚举的大小是很重要的.

c# pinvoke

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

FtpWebResponse,操作超时

我想从ftp服务器下载基于日期时间的文件..我可以从CuteFtp第三方访问这个Ftp而且每件事都是Okey ..但是当我在第一行运行下面的代码时GetRespone()我得到这个错误:操作有时间出.我用webclient requet以编程方式从这个FTP下载了一个示例文件,它很好..但是我需要使用FtpWebRequest获取listDirectoryDe​​tail而webClient不支持..还有一件事,请求中有一个异常:FtpWebRequest.ContentType抛出异常类型System.NotSupportedException.

这是我的代码:

Uri uri = new Uri("ftp://192.168.1.5:2100/");//the private address
        if (uri.Scheme != Uri.UriSchemeFtp)
        {
            return;
        }
        FtpWebRequest reqFTP;
        reqFTP = (FtpWebRequest)WebRequest.Create(uri);                             
        reqFTP.Credentials = new NetworkCredential("myuser", "mypass");
        reqFTP.KeepAlive = false;
        reqFTP.Method = WebRequestMethods.Ftp.ListDirectoryDetails;                               
        reqFTP.UseBinary = true;
        reqFTP.Proxy = null;
        reqFTP.UsePassive = false;
        FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
Run Code Online (Sandbox Code Playgroud)

请帮忙 :(

c# ftpwebrequest request-timed-out ftpwebresponse

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

在实体框架中填写外键对象4

我第一次使用EntityFramework也许这个问题很简单......我已经使用了代码优先方法..我有一个类人员,看起来像这样:

public class Personnel
{

    public string Id { set; get; }
    public int Code { set; get; }
    public string Name { set; get; }
    public int Type { set; get; }

    public JobTitle Title { set; get; }
}
Run Code Online (Sandbox Code Playgroud)

和JobTitle类:

public class JobTitle
{
    public string Id { set; get; }
    public int Number { set; get; }
    public string Title { set; get; }

    public List<Personnel> Personnels { set; get; }

}
Run Code Online (Sandbox Code Playgroud)

其中Personnel Class中的最后一个属性当然是人员表中的外键.我的问题是当我想使用lambda表达式从DB检索所有人员(或人员)时...外键对象为空... lambda表达式如下:

Context.ContextInstance.Personnels.ToList();
Run Code Online (Sandbox Code Playgroud)

如果我将表达式更改为此,则外键对象不再为null. …

c# entity-framework-4

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

多个自定义验证器,其反应形式为角度2

我有两个自定义validator的reactive form,我叫下面的函数来创建组件构造函数形式:

private createForm(): void {
this.passwordUpdateForm = this.formBuilder.group({
    newpassword : [null, Validators.required],
    passwordconfirm: [null, Validators.required]
},
{
    validator: [PasswordValidation.PasswordMatch, PasswordValidation.PasswordRule] // validation method

});
Run Code Online (Sandbox Code Playgroud)

}

PasswordValidation是一个具有以下两个功能的类

    export class PasswordValidation {

     public  static PasswordMatch(control: AbstractControl) {
        let password = control.get('newpassword'); // to get value in input tag
        if(password){
            let confirmPassword = control.get('passwordconfirm').value; // to get value in input tag
            if (password.value !== confirmPassword) {
                control.get('passwordconfirm').setErrors({ ['passwordmatch'] : true});
            }else {
                return null;
            }
        }
    } …
Run Code Online (Sandbox Code Playgroud)

custom-validators angular-validation angular angular-reactive-forms angular-forms

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

将formControlName用于反应形式的自定义输入组件

有一个自定义的输入组件,它以反应形式用于验证:

@Component({
    moduleId: module.id.toString(),
    selector: 'custom-select',
    templateUrl: 'custom-select.component.html',
    styleUrls: ['custom-select.component.css']
})
export class CustomSelectComponent {
    @Input() public items: SelectModel[];
    public model: SelectModel;
    constructor(private customSelectService: CustomSelectService) {
        this.customSelectService.Selected.subscribe((data: SelectModel) => {
            this.model = data;
        });
    }
    public newSelect(select: SelectModel): void {
        this.customSelectService.updateSelected(select);
    }
}
Run Code Online (Sandbox Code Playgroud)

效果很好,我正在custom-select以反应形式使用,并希望按如下所示进行验证:

<custom-select id="country" [items]="selectItems" formControlName="country"></custom-select>
<div *ngIf=" myFrom.controls['country'].invalid && (myFrom.controls['country'].dirty 
             || myFrom.controls['country'].touched) " class="ha-control-alert">
    <div *ngIf="myFrom.controls['country'].hasError('required')">Country is required</div>
</div>
Run Code Online (Sandbox Code Playgroud)

这就是我在组件中声明表格的方式

this.myFrom = this.formBuilder.group({
    country: [null, Validators.required],
})
Run Code Online (Sandbox Code Playgroud)

但是当我添加formControlName验证时,会出现错误,提示名称为'country'的表单控件没有值访问器。我该如何处理?

angular-validation angular angular-reactive-forms angular-forms

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

如何根据登录用户角色显示aspx页面的某些部分

我有一个asp.net网站..每个页面都有一些内容,每个登录用户都有一些角色..我想隐藏和显示页面的内容基于登录用户角色..我可以这样做?谢谢.PS:我知道asp.net中的身份验证和授权表单...我的问题是关于页面的内容.

要么

我想知道是否有一些.ascx(用户控件),然后将它们添加到.aspx页面..然后根据可见性属性和用户角色隐藏并显示aspx页面的部分..这是最好的方法?谢谢.

asp.net user-roles

4
推荐指数
2
解决办法
6216
查看次数