小编Der*_*rek的帖子

字符串查找和替换方法

我需要找到一个字符串值的特定部分,如下所示,我需要将"会议ID"更改为特定的数字.

这个数字来自多个数字的下拉列表,所以我不能简单地使用find和replace.因为在用户满意之前,文本可能会更改为多个数字之一.

字符串的"0783"部分永远不会改变,"会议ID"后面总是跟着",".

所以我需要进入"0783,INSERT TEXT ",然后在Index Changed事件中插入新号码.

这是一个例子: -

商务邀请,开始时间,M问题,518-06-xxx,9999 999 0783,会议ID,xxx ??

找到此字符串并每次更换测试的最佳方法是什么?

我希望这个有意义吗?

c# string

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

ASP.NET 5 MVC6自定义CSS和Javascript放置约定

所以我正在玩MVC6,我已经添加了bower.json和grunt.json,我已经创建了我的grunt任务,用于生成我的jQuery和bootstrap.css,它们都像我预期的那样坐在wwwroot文件夹中.

但是像我的site.css和我的main.js文件那样,我将为项目添加的文件随着时间的推移.

人们在为这些东西选择目录时使用了哪些约定?

我们要添加一个Content文件夹并将其删除吗?

有什么我想念的,我还应该使用Grunt/bower吗?

asp.net asp.net-core-mvc

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

Identity Server 4 撤销 Db 的访问令牌

我构建了一个 UI,用于管理 Identity Server 4 的用户存储中的用户。

用户可以锁定他们的帐户,此时我想撤销该用户数据库中保留的任何令牌。

据我了解,要做到这一点,我需要删除数据库中该用户的持久授权。

我在客户端应用程序中使用引用令牌,因此通过删除数据库中的令牌,它将自动取消对客户端应用程序中的用户的授权,因为对令牌的引用将无效。

这是解决这个问题的正确方法吗?

access-token openid-connect identityserver4

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

React Material UI BottomNavigation组件路由问题

我正在尝试从Material UI实现BottomNavigation组件,当用户使用浏览器的后退和前进按钮时,我遇到了问题.

问题是,BottomNavigation组件配置为在按下导航项按钮时更改布局中的页面.但是,当浏览器用于返回上一页时,它不会更改BottomNavigation项的选定索引.

我剩下的是一个不一致的状态.

当使用浏览器按钮时,如何更改导航组件的选定索引?

以下是UI的外观: -

[材质UI布局[1]

这是根组件: -

import React from 'react'
import {browserHistory, withRouter} from 'react-router';
import {PropTypes} from 'prop-types'
import {connect} from 'react-redux'
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'
import AppBar from 'material-ui/AppBar'
import Paper from 'material-ui/Paper'
import MyBottomNavigation from '../material-ui/MyBottomNavigation'

const style = {
    padding: 10,
    height: '85vh'

  }

class Root extends React.Component {
    constructor(props) {
        super(props)   

        this.state  = {
            bottomNavItemIndex : 0
        }
    }


    render() {
        return (
            <MuiThemeProvider>
                <div>
                    <AppBar title="Pluralsight Admin" 
                        iconClassNameRight="muidocs-icon-navigation-expand-more"
                        showMenuIconButton={false}
                        zDepth={1} …
Run Code Online (Sandbox Code Playgroud)

reactjs react-router material-ui

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

带OFT模板的Outlook邮件项目

我需要使用现有的办公室模板来创建新的Outlook邮件项目。这可以正常工作,但是我的问题是何时需要在模板正文中添加文本。当我尝试这样做时,它会覆盖模板主体。

当前的模板主体是否包含具有三行的表,并且我需要将用户输入添加到中间行?

我按照MSDN示例创建项目,但不确定如何执行下一部分。

是否可以将文本添加到常用模板中而不在其顶部覆盖?

private void button1_Click(object sender, EventArgs e)
{
    Outlook.Application application = new Outlook.Application();


    Outlook.Folder f = 
        application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDrafts) 
            as Outlook.Folder;

    Outlook.MailItem mail =
        application.CreateItemFromTemplate(@"C:\Documents and Settings\riversd\Desktop\DataBase\Notification.oft", f)
        as Outlook.MailItem;

    mail.BodyFormat = Outlook.OlBodyFormat.olFormatHTML;
    mail.Body = "<p>TEST</p>";
    mail.Save();
Run Code Online (Sandbox Code Playgroud)

c# outlook html-email

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

C#委托教程工作

我之前没有使用过代表,我正试图按照我的书中的教程来解决这些问题.

到目前为止,我已经发现委托可以与类的方法一起使用,该类返回相同类型的对象,并且与调用委托的代理重载(如果我错了,请纠正我).

在我正在研究的教程中,以下代码被添加到Car Class:

public delegate void CarEngineHandler(string msgForCaller);

private CarEngineHandler listOfHandlers;

public void RegisterWithCarEngine(CarEngineHandler methodToCall)
{
   listOfHandlers = methodToCall;
}
Run Code Online (Sandbox Code Playgroud)

Main控制台应用程序中,调用以下代码:

static void Main(string[] args)
{
    Car c1 = new Car("Slugbug", 100, 10);

    c1.RegisterWithCarEngine(new Car.CarEngineHandler(OnCarEngineEvent));

    Console.WriteLine("**** Speeding Up ******");
    for (int i = 0; i < 6; i++)
        c1.Accelerate(20);
    Console.ReadLine();
}

public static void OnCarEngineEvent(string msg)
{
    Console.WriteLine("\n***** Message From Car Object *****");
    Console.WriteLine("=> {0}", msg);
    Console.WriteLine("*************************************\n");
}
Run Code Online (Sandbox Code Playgroud)

这是Accelerate方法:

public void Accelerate(int delta)
{
    if …
Run Code Online (Sandbox Code Playgroud)

c# delegates

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

CSS-设置Div的大小以填充剩余空间

我是CSS和im tryig的新手,可以创建模板的准系统结构。

我有一个div用于页眉,主要内容和页脚。我的页脚和页眉很好,但是我需要在主要内容div中“填充”页眉和页脚之间的剩余空间。我尝试将padding-bottom属性的高度设置为与页脚相同的高度,但它并未缩小与页脚的间距,只是将div的高度设置为padding-bottom值。

我的HTML

<!DOCTYPE html>
<HTML>
    <HEAD>

        <LINK type="text/css" rel="stylesheet" href="main.css"/> 
        <TITLE>Template</TITLE>

    </HEAD>
    <BODY>
        <div id="container">

            <div class="header"></div>

            <div class="main-content"></div>

            <div class="footer"></div>

        </div>
    </BODY>
</HTML>
Run Code Online (Sandbox Code Playgroud)

和层叠样式表。

#container{

    min-height:100%;
    position:relative;

}

.header{

    border:2px dashed blue;
    height:150px;
    border-radius:5px;
    padding:10px;
}


.main-content{


    border:2px dashed blue;
    border-radius:5px;
    padding:10px;
    padding-bottom:100px;



}

.footer{
    position:absolute;
    bottom:0;
    width:100%;
    height:100px;
    border:2px dashed blue;
    border-radius:5px;




}

html, body{
   margin:0;
   padding:1px;
   height:100%;
}
Run Code Online (Sandbox Code Playgroud)

html css

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

ASP.NET WEB API 2 - ModelBinding每个请求触发两次

我有一个自定义验证属性,当我通过POST向服务器发出请求时,会在属性上触发两次IsValid方法.

它导致返回的错误消息被复制.

我已经使用Fiddler检查过请求只被触发一次,因此情况是1请求模型绑定触发两次.

[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public class MinimumAgeAttribute : ValidationAttribute
{
    private readonly int _minimumAge;

    public MinimumAgeAttribute(int minimumAge)
    {
        _minimumAge = minimumAge;
    }

    protected override ValidationResult IsValid(object value, ValidationContext validationContext)
    {
        DateTime date;

        if (DateTime.TryParse(value.ToString(), out date))
        {
            if (date.AddYears(_minimumAge) < DateTime.Now)
            {
                return ValidationResult.Success;
            }
        }

        return new ValidationResult("Invalid Age, Clients must be 18 years or over");
    }
}
Run Code Online (Sandbox Code Playgroud)

c# asp.net model-validation validationattribute asp.net-web-api2

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

.Net Core App - 命令行格式异常

我正在按照本指南: - https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/windows-service?tabs=aspnetcore2x

当我尝试使用--console命令行参数运行.exe文件时收到以下错误消息: -

未处理的异常:System.FormatException:缺少switch'--console'的值.

这是我的Program类的Main方法.

 public static void Main(string[] args)
        {
            Log.Logger = new LoggerConfiguration()
                .MinimumLevel.Information()
                .WriteTo.Console()
                .CreateLogger();

            var isService = !(Debugger.IsAttached || args.Contains("--console"));

            var pathToContentRoot = Directory.GetCurrentDirectory();
            if (isService)
            {
                var pathToExe = Process.GetCurrentProcess().MainModule.FileName;
                pathToContentRoot = Path.GetDirectoryName(pathToExe);
            }

            var host = WebHost.CreateDefaultBuilder(args)
                .UseContentRoot(pathToContentRoot)
                .UseStartup<Startup>()
                .Build();

            if (isService)
            {
                host.RunAsCustomService();
            }
            else
            {
                host.Run();
            }
        }
Run Code Online (Sandbox Code Playgroud)

我已经确保我从文件夹路径运行命令行参数.

.net asp.net command-line .net-core

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

LINQ to Entities - 实体框架

我希望得到我们何时应该使用更好的理解IEnumerableIQueryable与LINQ到实体.

通过对数据库的真正基本调用,IQueryable速度更快,但是我什么时候需要考虑使用IEnumerable它?

哪个是IEnumerable最优的IQueryable

c# linq-to-entities entity-framework-5

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