我正在尝试在我的泛型类中创建一个类型参数的新对象.在我的类中View,我有2个作为类型参数传递的泛型类型的对象列表,但是当我尝试制作时new TGridView(),TypeScript说:
找不到符号'TGridView
这是代码:
module AppFW {
// Represents a view
export class View<TFormView extends FormView, TGridView extends GridView> {
// The list of forms
public Forms: { [idForm: string]: TFormView; } = {};
// The list of grids
public Grids: { [idForm: string]: TGridView; } = {};
public AddForm(formElement: HTMLFormElement, dataModel: any, submitFunction?: (e: SubmitFormViewEvent) => boolean): FormView {
var newForm: TFormView = new TFormView(formElement, dataModel, submitFunction);
this.Forms[formElement.id] = newForm;
return newForm;
}
public AddGrid(element: …Run Code Online (Sandbox Code Playgroud) 如何使用DecorateAllWithDynamicProxy进行装饰所有实例都实现了一个接口?
例如:
public class ApplicationServiceInterceptor : IInterceptor
{
public void Intercept(IInvocation invocation)
{
// ...
invocation.Proceed();
// ...
}
}
public class ApplicationServiceConvention : IRegistrationConvention
{
public void Process(Type type, Registry registry)
{
if (type.CanBeCastTo<IApplicationService>() && type.IsInterface)
{
var proxyGenerator = new ProxyGenerator();
// ??? how to use proxyGenerator??
// ???
registry.For(type).DecorateAllWith(???); // How to use DecorateAllWith DynamicProxy ...??
}
}
}
Run Code Online (Sandbox Code Playgroud)
我可以使用(例如)装饰一些具体类型的接口:
var proxyGenerator = new ProxyGenerator();
registry.For<IApplicationService>().Use<BaseAppService>().DecorateWith(service => proxyGenerator.CreateInterfaceProxyWithTargetInterface(....))
Run Code Online (Sandbox Code Playgroud)
但是无法使用DecorateAll来做到这一点.
要打电话registry.For<>().Use<>().DecorateWith()我必须这样做:
if (type.CanBeCastTo<IApplicationService>() && …Run Code Online (Sandbox Code Playgroud) 我有一个带有几个"text/ng-template"脚本标签的html文件,如下所示(templates.html):
<script type="text/ng-template" id="template1">
ng-template 1
</script>
<script type="text/ng-template" id="template2">
ng-template 2
</script>
<script type="text/ng-template" id="template3">
ng-template 3
</script>
Run Code Online (Sandbox Code Playgroud)
我想要包含"templates.html"中的一个模板,但不是全部,我希望找到类似的内容:
<ng-include src="'templates.html#template1'"></div>
Run Code Online (Sandbox Code Playgroud)
这是可能的?是否存在任何其他第三方指令?
PD:我知道我可以在一个单独的文件(template1.html,template2.html,...)上提取每个ng-template并使用ng-include加载每个模板,但我有很多模板,我需要对它进行分组.
我正在使用 TypeScript 开发一个在 webbrowser 中使用的库。
我正在使用“system”作为--module编写单独的打字稿文件作为模块,例如这是主文件:
/// <reference path="../typings/tsd.d.ts" />
/// <reference path="./typings/simple-html-tokenizer/simple-html-tokenizer" />
export * from "./Decorators/Component";
export * from "./Decorators/Directive";
export * from "./Decorators/Inject";
export * from "./Decorators/Injectable";
export * from "./Events/EventEmitter";
export * from "./Core/Bootstrap";
export * from "./Decorators/Output";
export * from "./Decorators/Input";
export {OnChanges, OnInit, OnDestroy} from "./Core/LifeCycle/LifeCycleHooks";
Run Code Online (Sandbox Code Playgroud)
这是第一个模块:
import {serviceNormalize} from "../Utils/AngularHelpers";
export interface IComponentMetadata {
template?: string;
templateUrl?: string;
selector?: string;
directives?: Function[];
outputs?: string[];
inputs?: string[];
styles?: string[];
providers?: (Function|string)[];
}
/**
* …Run Code Online (Sandbox Code Playgroud) 我想在我的类上启用LinQ查询语法.我认为查询语法被转换为方法语法,例如:
var query = from p in new Class1<Product>()
where p.Id == "1000"
select p
Run Code Online (Sandbox Code Playgroud)
被翻译成:
var query = new Class1<Product>().Where(p => p.Id == "1000").Select(p => p);
Run Code Online (Sandbox Code Playgroud)
然后我实现了我Class1的:
public class Class1<T>
{
public Class1<T> Where(Expression<Func<T, bool>> expression)
{
return this;
}
public Class1<T> Select<TResult>(Func<T, TResult> expression)
{
return this;
}
}
Run Code Online (Sandbox Code Playgroud)
我用这段代码测试了它:
static void Main(string[] args)
{
var query = from p in new Class1<Product>()
where p.Id == "1000"
select p;
}
Run Code Online (Sandbox Code Playgroud)
然后我注意到Select没有调用该方法,但是如果我where从LinQ中删除clausule Select …
我正在尝试在我的MVC4应用程序中使用TypeScript.
我将TypeScript文件添加到我的应用程序的Scripts文件夹中,但Visual Studio 2012不生成.js和.map文件.似乎忽略了这个文件.
使用以前版本的WebEssentials和TypeScript时,我保存了.ts文件,以及自动生成的.js和.map文件时编译了我的TypeScript文件.
现在使用最新版本的WebEssentials和TypeScript我不能这样做.
什么是新的?我需要做些什么来使它工作?
typescript ×3
angularjs ×1
asp.net-mvc ×1
c# ×1
generics ×1
gulp ×1
javascript ×1
linq ×1
node.js ×1
structuremap ×1
tsify ×1