我有这样的Typescript类:
class WordService implements IWordService {
wordCreatedById: number = 0;
wordModifiedById: number = 0;
static $inject = [
"$http",
"$q",
...
];
constructor(
public $http: ng.IHttpService,
public $q: ng.IQService,
...
) {
}
wordClear = (): void => {
this.word = null;
this.wordBase = null;
}
...
}
Run Code Online (Sandbox Code Playgroud)
我的类文件已经变得很长了,因为我定义了越来越多的函数,比如wordClear.
有什么方法可以将函数移动到另一个文件并导入到我的类中?
我有用于实体框架的此对象映射:
public WordDefinitionMap(string schema)
{
ToTable(schema + ".WordDefinition");
HasKey(x => x.WordDefinitionId);
Property(x => x.WordDefinitionId).HasColumnName(@"WordDefinitionId").IsRequired().HasColumnType("int").HasDatabaseGeneratedOption(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Identity);
Property(x => x.WordFormId).HasColumnName(@"WordFormId").IsRequired().IsUnicode(false).HasColumnType("varchar").HasMaxLength(20);
Property(x => x.Ascii).HasColumnName(@"Ascii").IsOptional().HasColumnType("int").HasDatabaseGeneratedOption(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Computed);
// Foreign keys
HasRequired(a => a.WordForm).WithMany(b => b.WordDefinitions).HasForeignKey(c => c.WordFormId); // FK_WordDefinitionWordForm
}
public class WordDefinition
{
public int WordDefinitionId { get; set; } // WordDefinitionId (Primary key)
public string WordFormId { get; set; } // WordFormId (length: 20)
public int? Ascii { get; set; } // Ascii
// Foreign keys
public virtual WordForm WordForm { get; set; } // …Run Code Online (Sandbox Code Playgroud) 我有一个包含单词列表和相关wordForms的表.表中的典型数据如下所示.请注意,WordForms的某些列结束,例如,有些只是以最后一个wordform字结束
Id Word WordForms
1 abandon abandoned, abandoning, abandonment, abandons
2 abstract abstraction, abstractions, abstractly, abstracts, e.g.
Run Code Online (Sandbox Code Playgroud)
这是源数据表的布局:
CREATE TABLE [dbo].[TempWords]
(
[Id] INT IDENTITY (1, 1) NOT NULL,
[Word] NVARCHAR (MAX) NOT NULL,
[WordForms] NVARCHAR (MAX) NULL,
)
Run Code Online (Sandbox Code Playgroud)
我想用这些数据来填充两个表.我知道使用SQL INSERT INTO,但我认为只能帮助我使用一个表.我想要做的是取第一个Word,将其放入Words表中,然后将现在用逗号分隔的字形分开,并将它们放入WordForms表中.
CREATE TABLE [dbo].[Words]
(
[WordId] INT IDENTITY (1, 1) NOT NULL,
[Word] NVARCHAR (MAX) NOT NULL
)
CREATE TABLE [dbo].[WordForms]
(
[Id] INT IDENTITY (1, 1) NOT NULL,
[WordId] INT NOT NULL,
[Text] NVARCHAR (MAX) NULL,
)
Run Code Online (Sandbox Code Playgroud)
谁能给我一些关于如何做到这一点的提示?
我的边框有这个代码:
border: 1px solid #CCC;
Run Code Online (Sandbox Code Playgroud)
是否有可能有一些类似的CSS,其中边框有宽度但不可见.换句话说,如果有蓝色背景,那么就会显示出边界?
我的CSS问题.我的屏幕上有一个区域,里面有按钮.按钮的数量是可变的.这些按钮包含在DIV(sbr_btn)内.像这样的东西:
Outer DIV Outer DIV Outer DIV
01 02 03 04 05
06 07 08 ...
71 72 73 74 75
Outer DIV Outer DIV Outer DIV
Run Code Online (Sandbox Code Playgroud)
问题是因为我的按钮有浮动:左边然后外面的DIV没有包围按钮.它只是忽略了所有按钮的高度,看起来不像上面那样.有什么办法可以让外面的DIV包围浮动按钮吗?
<div id="sbr_btn" >
<div><a href='xx'>01</a></div>
<div><a href='xx'>02</a></div>
<div><a href='xx'>03</a></div>
<div><a href='xx'>04</a></div>
<div><a href='xx'>05</a></div>
<div><a href='xx'>06</a></div>
many more
<div><a href='xx'>75</a></div>
</div>
#sbr_btn div {
float: left;
padding: 4px;
text-align: center;
}
#sbr_btn div a {
display: inline-block;
padding: 1px 4px;
border: 1px solid #CCCCCC;
border-radius: 4px 4px 4px 4px;
color: #111111;
}
Run Code Online (Sandbox Code Playgroud) 我使用了以下内容:
t.Description.Substring(0, 20)
Run Code Online (Sandbox Code Playgroud)
但是如果字符串中的字符少于20个则存在问题.是否有一种简单的方法(单个内联函数),当字符串少于20个字符时,我可以使用它来截断到最大值而不会出错?
我的模型中有以下类:
public class Notebook : TableServiceEntity
{
public string NotebookLinksJSON { get; set; }
public string NotebookLinksCount {
get {
var a = NotebookLinksJSON.FromJSONString<Notebook.Link>().Details;
var b = a.Count();
return NotebookLinksJSON.FromJSONString<Notebook.Link>().Details.Count();
}
}
public class Link
{
public Link() {
_details = new List<Detail>();
}
public IList<Detail> Details {
get { return _details; }
}
private List<Detail> _details = new List<Detail>();
public class Detail
{
public string L { get; set; }
public string R { get; set; }
}
} …Run Code Online (Sandbox Code Playgroud) 我从以下网页开始:
http://127.0.0.1:84/Administration/Accounts/Home
Run Code Online (Sandbox Code Playgroud)
然后我选择一个链接,它需要我:
http://127.0.0.1:84/Administration/Accounts/ShowSummary?ds=0001
Run Code Online (Sandbox Code Playgroud)
在ShowSummary剃刀页面的开头,我检查了
Request.Url http://127.0.0.1:86/Administration/Accounts/ShowSummary?ds=0001}
Request.Url.Authority "127.0.0.1:86"
Request.UrlReferrer - {http://127.0.0.1:84/Administration/Accounts/Home}
Run Code Online (Sandbox Code Playgroud)
每次我尝试这个时它总是报告端口86而不是端口84.这对我来说很重要,因为我存储了URL.有谁知道它为什么显示不同的端口?正确的端口应为84但Url和Url.Authority报告86
我最近看到一篇帖子询问是否有办法更改字符串,因此它以大写字母开头并且后面有小写字母.这看起来是最好的解决方案:
public static class StringHelper {
public static string ToTitleCase(string text) {
return StringHelper.ToTitleCase(text, CultureInfo.InvariantCulture);
}
public static string ToTitleCase(string text, CultureInfo cultureInfo) {
if (string.IsNullOrEmpty(text)) return string.Empty;
TextInfo textInfo = cultureInfo.TextInfo;
return textInfo.ToTitleCase(text.ToLower());
}
}
Run Code Online (Sandbox Code Playgroud)
我想要的是将这些转换为字符串扩展.有人可以建议我怎么做吗?
我看到了以下内容:
[RegularExpression(@"\b*[a-zA-Z0-9_]\b", ErrorMessage = "Enter a single work account name please")]
Run Code Online (Sandbox Code Playgroud)
但是当字符串包含多个字符时,似乎会出错.有人可以帮助检查字符串中是否有多个单词的正则表达式?
c# ×5
css ×2
angularjs ×1
asp.net ×1
asp.net-mvc ×1
azure ×1
html ×1
javascript ×1
regex ×1
sql-server ×1
typescript ×1