我正在使用 TypeScript 和 OpenTelemetry 构建一个可重用的遥测库。我正在尝试了解如何实现树摇动,以便消费者可以仅导入他们需要的模块而不是所有内容,这样他们就可以减少整体包的大小。项目结构如下所示,
lib
|
|__ trace
| |____ TraceClass.ts
| |____ index.ts
|
|__ metrics
| |____ MetricClass.ts
| |____ index.ts
|
|__ logs
| |____ LogClass.ts
| |____ index.ts
|
|__ index.ts
Run Code Online (Sandbox Code Playgroud)
我将三个主要模块“trace”、“log”和“metrics”作为单独的文件夹。正如您所看到的,每个模块都有自己的“index.ts”文件,并且有一个根“index.ts”文件。假设根“index.ts”文件是否导出子模块等所有内容。
根索引.ts
export * from './trace';
export * from './metrics';
export * from './logs';
Run Code Online (Sandbox Code Playgroud)
假设消费者TraceClass从根文件导入,如下所示,
import { TraceClass } from 'mytelemetrylib';
Run Code Online (Sandbox Code Playgroud)
上面的代码是否导入了其代码中的所有模块?
或者他们必须做这样的事情?
import { TraceClass } from 'mytelemetrylib/trace';
Run Code Online (Sandbox Code Playgroud) 我有 Quartz 调度程序使用 AdoDataStore 作为独立的 Windows 服务在端口 555 中运行。我有一个 asp.net 应用程序,可以为这个调度程序调度作业。我必须在 ASP.NET 端做哪些配置来安排作业?任何帮助是极大的赞赏。
这是服务配置,
<!-- Configure Thread Pool -->
<add key="quartz.threadPool.type" value="Quartz.Simpl.SimpleThreadPool, Quartz" />
<add key="quartz.threadPool.threadCount" value="10" />
<add key="quartz.threadPool.threadPriority" value="Normal" />
<!-- Configure Job Store -->
<add key="quartz.jobStore.misfireThreshold" value="60000" />
<add key="quartz.jobStore.type" value="Quartz.Impl.AdoJobStore.JobStoreTX, Quartz" />
<add key="quartz.jobStore.useProperties" value="true" />
<add key="quartz.jobStore.dataSource" value="default" />
<add key="quartz.jobStore.tablePrefix" value="QRTZ_" />
<add key="quartz.jobStore.driverDelegateType" value="Quartz.Impl.AdoJobStore.StdAdoDelegate, Quartz" />
<add key="quartz.jobStore.lockHandler.type" value="Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz" />
<add key="quartz.dataSource.default.connectionString" value="Server=server\MSSQLEXPRESS;Database=QuartzServerDB;Trusted_Connection=True;" />
<add key="quartz.dataSource.default.provider" value="SqlServer-20" />
<!--export this server to …Run Code Online (Sandbox Code Playgroud) 在我的ASP.NET MVC应用程序中,我试图弄清楚用户是否可以访问特定的控制器,受授权数据注释的限制如下
[Authorize(Roles = "user")]
Run Code Online (Sandbox Code Playgroud)
我试图覆盖OnAuthorization以检查: -
我的用户角色存储在我创建的SessionManager对象中 - SessionManager.ActiveUser.Roles
这就是我所拥有的伪代码形式,但如果有人能帮助我做到这一点,我真的很感激.
public class HomeBaseController : Controller
{
protected override void OnAuthorization(AuthorizationContext context)
{
if (context.HttpContext.User.Identity.IsAuthenticated)
{
// these values combined are our roleName
bool isAuthorised = context.HttpContext.User.IsInRole(context.RequestContext.HttpContext.User.Identity.);
if (!context.HttpContext.User.IsInRole(---the roles associated with the requested controller action (e.g. user)---))
{
var url = new UrlHelper(context.RequestContext);
var logonUrl = url.Action("LogOn", "SSO", new { reason = "youAreAuthorisedButNotAllowedToViewThisPage" });
context.Result = new RedirectResult(logonUrl);
return;
}
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用node.js和bower.我想在全球范围内安装凉亭.另外,我需要将它包含在package.json文件下devDependency.
所以我试过,
npm install -g bower --save-dev
Run Code Online (Sandbox Code Playgroud)
Bower已成功安装,但我没有看到package.json文件正在更新.这可能是什么问题?
我正在使用jqgrid 3.8.2并且网格有许多不可编辑的列但仍希望发布到服务器.我怎么能这样做?(如果我设置editable:false则该字段未被发布到服务器)
我有一个 web 应用程序和一个在不同地方运行的服务层,它们都有自己的业务实体,这意味着它们都有自己的类来表示员工、订单等(例如服务层中的 Emp 和 web 应用程序中的员工)。当 Web 应用程序调用服务层以获取员工列表时,我想将服务返回的员工列表转换为 Web 应用程序的员工类型列表。
我正在寻找一种方法来轻松做到这一点。任何想法都会很棒。顺便说一下,我正在使用 ASP.NET 和 WCF。
是否可以在ASP.NET Web API路由配置中添加允许处理看起来有点像文件名的URL的路由?
我尝试添加以下条目WebApiConfig.Register(),但这不起作用(使用URI api/foo/0de7ebfa-3a55-456a-bfb9-b658165df5f8/bar.group.json):
config.Routes.MapHttpRoute(
name: "ContextGroupFile",
routeTemplate: "api/foo/{id}/{filetag}.group.json",
defaults: new { controller = "foo", action = "getgroup"}
);
Run Code Online (Sandbox Code Playgroud)
以下确实有效(FooController.GetGroup(id,filetag)按预期调用)(使用URI api/foo/0de7ebfa-3a55-456a-bfb9-b658165df5f8/group/bar):
config.Routes.MapHttpRoute(
name: "ContextGroupFile",
routeTemplate: "api/foo/{id}/group/{filetag}",
defaults: new { controller = "foo", action = "getgroup"}
);
Run Code Online (Sandbox Code Playgroud)
失败的情况会返回一个IIS错误(404 - 找不到文件),看起来它是由我的应用程序之外的东西创建的.错误页面(由IIS Express生成)包含以下错误详细信息:
Module = IIS Web Core
Notification = MapRequestHandler
Handler = StaticFile
Error Code = 0x80070002
Run Code Online (Sandbox Code Playgroud)
我想这意味着一个名为"StaticFile Handler"的东西在它到达我的代码之前就已经得到了请求.最大的问题是:有没有办法防止这种情况发生?
我试图理解MVC 4应用程序中TDD的概念.我在网上找到的所有例子都没有解释我在MVC 4应用程序的情况下应该测试单元测试的概念.
因此,在编写单元测试时,您试图在控制器中测试的要点是什么?
如果可能请解释这个例子.
public class UsersIDentController : AuthorizedController
{
private readonly IUserDetailsService userDetailsService;
public UsersIDentController(IUserDetailsService userDetailsService,
IServiceLocator serviceLocator): base(serviceLocator)
{
}
//
// GET: /UsersIdentification/
[AllowAnonymous]
public ActionResult ShowDetails()
{
UsersIdentificationViewModel model = new UsersIdentificationViewModel();
return View(model);
}
}
Run Code Online (Sandbox Code Playgroud)
如果您要为该控制器编写单元测试(gettin用户数据),您将在单元测试中测试什么.
谢谢.
我正在为我的 ASP.NET MVC 应用程序实现自定义会话状态提供程序。我的要求是我必须将会话数据存储xml在 Sql 服务器中的自定义表中。
我可以使用现有的sql 会话状态提供程序(覆盖某些方法)还是我必须通过实现抽象类从头开始创建SessionStateStoreProviderBase?
嗯,这很奇怪.我正在做我在网上大量发现的一切,但仍然无效.我想上传一个文件,所以在View I中:
@using (Html.BeginForm("Import", "Home", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<input type="file" name="uploadFile" />
<input type="submit" value="Importa" />
}
Run Code Online (Sandbox Code Playgroud)
这是Home/Import:
[AcceptVerbs(HttpVerbs.Post)] // or [HttpPost], nothing changes
public ActionResult Import(HttpPostedFileBase uploadFile)
{
Debug.WriteLine("Inside Import");
if (uploadFile == null)
Debug.WriteLine("null");
// Verify that the user selected a file
if (uploadFile != null && uploadFile.ContentLength > 0)
{
Debug.WriteLine("Valid File");
...
}
}
Run Code Online (Sandbox Code Playgroud)
它总是打印Inside Import + null.所以我确定我调用了正确的Controller Action,但它总是收到一个null HttpPostedFileBase.
有没有人有建议或已经找到(并解决)这种问题?谢谢!
asp.net-mvc ×3
c# ×2
asp.net ×1
bower ×1
enctype ×1
jqgrid ×1
node.js ×1
npm ×1
quartz.net ×1
razor ×1
theory ×1
tree-shaking ×1
typescript ×1
unit-testing ×1
wcf ×1