使用Less我按如下方式定义字体系列:
@georgia: georgia, times, 'times new roman', 'nimbus roman no9 l', serif;
Run Code Online (Sandbox Code Playgroud)
然后我有更少的mixin:
.font(@family: arial, @size: 1.0em, @lineheight: 1.0, @weight: normal, @style: normal, @variant: normal) {
font: @style @variant @weight @size~"/"@lineheight @family;
} // font
Run Code Online (Sandbox Code Playgroud)
最后我像这样使用它:
p {
.font(@georgia, 1.0em, 1.5)
}
Run Code Online (Sandbox Code Playgroud)
但我还想用自定义字体定义字体系列:
@something: 'custom-font', arial, ...;
Run Code Online (Sandbox Code Playgroud)
但首先我需要注册自定义字体:
@font-face {
font-family: 'custom-font';
src:url('fonts/custom-font.eot');
src:url('fonts/custom-font.eot?#iefix') format('embedded-opentype'),
url('fonts/custom-font.woff') format('woff'),
url('fonts/custom-font.ttf') format('truetype'),
url('fonts/custom-font.svg#icon') format('svg');
font-weight: normal;
font-style: normal;
}
Run Code Online (Sandbox Code Playgroud)
是否可以创建一个LESS mixin,@font-face
因此我可以传递字体名称和路径并注册字体而不重复所有这些代码?
我不知道如何将其与我的字体混合...
或者,如果有更好的方法来做到这一点......
谢谢你,米格尔
我现在的文化如下:
var culture = Thread.CurrentThread.CurrentCulture.DisplayName;
Run Code Online (Sandbox Code Playgroud)
问题是我总是用英文命名:
如何以该特定语言获取文化的DisplayName?
谢谢你,米格尔
我的上下文中有一个实体"POST",以下内容:
String[] keywords = new String[] { "Car", "Yellow" };
Run Code Online (Sandbox Code Playgroud)
如何搜索所有包含2个单词的标题?
注意:关键字可以包含1到4个单词.
邮政实体如下:
public class Post {
public Int32 Id { get; set; }
public DateTime Created { get; set; }
public String Text { get; set; }
public String Title { get; set; }
public DateTime Updated { get; set; }
} // Post
Run Code Online (Sandbox Code Playgroud)
这是我的SQL:
create table dbo.Posts
(
Id int identity not null
constraint PK_Posts_Id primary key clustered (Id),
Created datetime not null,
[Text] nvarchar (max) not null, …
Run Code Online (Sandbox Code Playgroud) 我有以下EntityFramework上下文:
public class Context : DbContext, IDbContext {
}
Run Code Online (Sandbox Code Playgroud)
其中IDbContext如下:
public interface IDbContext {
DbEntityEntry Entry(Object entity);
IEnumerable<DbEntityValidationResult> GetValidationErrors();
Int32 SaveChanges();
Task<Int32> SaveChangesAsync();
Task<Int32> SaveChangesAsync(CancellationToken cancellationToken);
DbSet Set(Type entityType);
DbSet<TEntity> Set<TEntity>() where TEntity : class;
} // IDbContext
Run Code Online (Sandbox Code Playgroud)
使用Autofac配置DbContext注入的正确方法是什么?
使用StructureMap,我有以下内容:
For<IDbContext>().Use(x => new Context());
Run Code Online (Sandbox Code Playgroud) 我正在使用ASP.NET Core RC2,当我运行dotnet run
我的应用程序时总是在"生产"中运行.我无法将其更改为"开发".
我有以下launchSettings.json
文件:
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:26088/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"MVCCoreRc2App": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我不确定为什么dotnet
在设置时在"生产"中运行应用程序"ASPNETCORE_ENVIRONMENT": "Development"
.
这在ASP.NET Core RC1中有效.我错过了什么?
如何在Razor视图中获取当前身份验证用户的类型声明?
我尝试了一些选项,例如以下内容,但没有成功:
(ClaimsPrincipal)User.Identity).FindFirst(ClaimTypes.NameIdentifier); }
Run Code Online (Sandbox Code Playgroud)
谢谢你,米格尔
在ASP.NET应用程序上,我有一个标志枚举如下:
[Flags]
enum Target : int {
None = 0,
Group = 1,
Student = 2,
Professor = 4,
All = Group | Student | Professor
}
Run Code Online (Sandbox Code Playgroud)
我可以使用Entity Framework 6在SQL数据库表中保存包含多个项目的值吗?
怎么会得救?
谢谢你,米格尔
我有以下ENUM:
[Flags]
public enum DataFiat {
[Description("Público")]
Public = 1,
[Description("Filiado")]
Listed = 2,
[Description("Cliente")]
Client = 4
} // DataFiat
Run Code Online (Sandbox Code Playgroud)
我创建了一个扩展来获取Enum属性:
public static T GetAttribute<T>(this Enum value) where T : Attribute {
T attribute;
MemberInfo info = value.GetType().GetMember(value.ToString()).FirstOrDefault();
if (info != null) {
attribute = (T)info.GetCustomAttributes(typeof(T), false).FirstOrDefault();
return attribute;
}
return null;
}
Run Code Online (Sandbox Code Playgroud)
这适用于非Flags Enums ...但是当我有:
var x = DataFiat.Public | DataFiat.Listed;
var y = x.GetAttribute<Description>();
Run Code Online (Sandbox Code Playgroud)
y的值为null ...
我想得到"Público,Filiado,Cliente"......就像ToString()一样.
如何更改我的扩展程序才能使其正常工作?
谢谢
在ASP.NET MVC 5上,我使用了具有一些属性的基本ViewPage:
public String PageTitle { get; set; }
public String PageDescription { get; set; }
public String[] BodyCssClasses { get; set; }
Run Code Online (Sandbox Code Playgroud)
然后在每个视图上我会:
@{
PageTitle = "Title ..."
PageDescription" = "Description ..."
BodyCssClasses = new String[] { "main", "home" }
}
Run Code Online (Sandbox Code Playgroud)
在母版页上,我只想使用如下内容:
<title>@Title</title>
Run Code Online (Sandbox Code Playgroud)
通过这种方法,我能够使用强类型页面属性...
是否可以在ASP.NET MVC 6中使用基本视图页面?
既然没有Web.Config怎么办呢?
欢迎任何有关更好的选项来定义页面头信息的建议.
UPDATE
我按照建议我正在使用:
public abstract class ViewPageBase<TModel> : RazorPage<TModel> {
public String Title { get; set; }
} // ViewPageBase
Run Code Online (Sandbox Code Playgroud)
然后在_ViewImports我有:
@inherits ViewPageBase<TModel>
Run Code Online (Sandbox Code Playgroud)
在_Layout.cshtml上我有:
<title>@Title</title>
Run Code Online (Sandbox Code Playgroud)
最后在一个使用该布局的视图中:
@{
Title = "Page …
Run Code Online (Sandbox Code Playgroud) 在ASP.NET Core项目中,我有以下操作:
public async Task<IActionResult> Get(ProductModel model) {
}
public class ProductModel {
public Filter<Double> Price { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我有一个Filter基类和一个RangeFilter,如下所示:
public class Filter<T> { }
public class RangeFilter<T> : Filter<T> {
public abstract Boolean TryParse(String value, out Filter<T> filter);
}
Run Code Online (Sandbox Code Playgroud)
我将String("[3.34;18.75]"
)传递给Action as Price.
我需要创建一个ModelBinder
我使用该TryParse
方法的地方,尝试将其String
转换RangeFilter<Double>
为定义ProductModel.Price
属性.
如果TryParse
失败,例如,返回false
则ProductModel.Price
属性变为null.
如何才能做到这一点?
c# ×4
asp.net-core ×2
asp.net-mvc ×2
.net ×1
asp.net ×1
autofac ×1
css ×1
enums ×1
less ×1
project.json ×1
sql ×1