我正在寻找一个很好的教程,在 WinForm 应用程序中使用 NHibernate 配置 AUTOFAC,在创建表单时注入 ISession 并在表单关闭时处置 ISession。
我发现了很多 MVC 和 ASP.NET 示例,但没有一个使用 WinForm。
你能为我指出正确的方向吗?
我在WinForm应用程序中使用Windsor Castle和log4net时出现此错误.
错误:
Could not convert from 'Castle.Services.Logging.Log4netIntegration.Log4netFactory,Castle.Services.Logging.Log4netIntegration,Version=2.5.1.0, Culture=neutral,PublicKeyToken=407dd0808d44fbdc' to System.Type - Maybe type could not be found
Run Code Online (Sandbox Code Playgroud)
堆:
in Castle.MicroKernel.SubSystems.Conversion.TypeNameConverter.PerformConversion(String value, Type targetType) in e:\OSS.Code\Castle.Windsor\src\Castle.Windsor\MicroKernel\SubSystems\Conversion\TypeNameConverter.cs:riga 91
in Castle.MicroKernel.SubSystems.Conversion.DefaultConversionManager.PerformConversion(String value, Type targetType) in e:\OSS.Code\Castle.Windsor\src\Castle.Windsor\MicroKernel\SubSystems\Conversion\DefaultConversionManager.cs:riga 134
in Castle.MicroKernel.SubSystems.Conversion.DefaultConversionManager.PerformConversion[TTarget](String value) in e:\OSS.Code\Castle.Windsor\src\Castle.Windsor\MicroKernel\SubSystems\Conversion\DefaultConversionManager.cs:riga 162
in Castle.Facilities.Logging.LoggingFacility.GetLoggingFactoryType(LoggerImplementation loggerApi)
in Castle.Facilities.Logging.LoggingFacility.CreateProperLoggerFactory(LoggerImplementation loggerApi)
in Castle.Facilities.Logging.LoggingFacility.ReadConfigurationAndCreateLoggerFactory()
in Castle.Facilities.Logging.LoggingFacility.Init()
in Castle.MicroKernel.Facilities.AbstractFacility.Castle.MicroKernel.IFacility.Init(IKernel kernel, IConfiguration facilityConfig) in e:\OSS.Code\Castle.Windsor\src\Castle.Windsor\MicroKernel\Facilities\AbstractFacility.cs:riga 85
in Castle.MicroKernel.DefaultKernel.AddFacility(String key, IFacility facility) in e:\OSS.Code\Castle.Windsor\src\Castle.Windsor\MicroKernel\DefaultKernel.cs:riga 320
in Castle.MicroKernel.DefaultKernel.AddFacility[T](Func`2 onCreate) in e:\OSS.Code\Castle.Windsor\src\Castle.Windsor\MicroKernel\DefaultKernel.cs:riga 377
in Castle.Windsor.WindsorContainer.AddFacility[T](Func`2 onCreate) in e:\OSS.Code\Castle.Windsor\src\Castle.Windsor\Windsor\WindsorContainer.cs:riga 629
in …Run Code Online (Sandbox Code Playgroud) 我想用ITextSharp创建以下PDF布局:

我使用以下代码生成我的表:
Document document = new Document(PageSize.A4);
MemoryStream memoryStream = new MemoryStream();
PdfWriter writer = PdfWriter.GetInstance(document, memoryStream);
document.Open();
PdfPCell cell;
PdfPTable table = new PdfPTable(2);
table.SetWidths(new float[] { 450, 100 });
table.WidthPercentage = 100;
cell = new PdfPCell(new Phrase("Item cod werwerwer"));
table.AddCell(cell);
cell = new PdfPCell(new Phrase("100"));
table.AddCell(cell);
cell = new PdfPCell(new Phrase(string.Empty));
table.AddCell(cell);
cell = new PdfPCell(new Phrase("100"));
table.AddCell(cell);
document.Add(table);
writer.CloseStream = false;
document.Close();
memoryStream.Position = 0;
return memoryStream.ToArray();
Run Code Online (Sandbox Code Playgroud)
如何在不使用固定高度值的情况下强制表格覆盖整页高度?
我在NHibernate中有类似这样的映射情况:
ClassA
mapping.Id(x => x.Id).Column("rowid").GeneratedBy.Identity().Unique();
ClassB
mapping.Id(x => x.Id).Column("rowid").GeneratedBy.Identity().Unique();
mapping.References<ClassA>(x => x.ClassA).Nullable();
Run Code Online (Sandbox Code Playgroud)
当NHibernate生成数据库模式时,即使我在映射声明中指定了"Nullable"属性,它也会在这些表之间创建一个外键.很明显,如果我尝试保存我的对象,我会得到一个外键约束错误,如果我从数据库中手动删除外键,它就像一个魅力.
如何告诉NHibernate不要在这种情况下创建外键脚本?
我Identity Server 4在我的Angular 5应用程序中使用。
我以这种方式配置了身份服务器:
public static IEnumerable<Client> GetClients()
{
return new List<Client>
{
new Client
{
ClientId = "client",
AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,
AllowAccessTokensViaBrowser = true,
RequireClientSecret = false,
AllowedScopes = {
"api1"
},
AllowedCorsOrigins = new List<string>
{
"http://localhost:4200"
}
}
};
}
public void ConfigureServices(IServiceCollection services)
{
var cors = new DefaultCorsPolicyService(_loggerFactory.CreateLogger<DefaultCorsPolicyService>())
{
AllowedOrigins = { "http://localhost:4200" }
};
services.AddSingleton<ICorsPolicyService>(cors);
services.AddIdentityServer()
.AddDeveloperSigningCredential()
.AddInMemoryApiResources(Config.GetApiResources())
.AddInMemoryClients(Config.GetClients());
}
Run Code Online (Sandbox Code Playgroud)
这是我的 Angular 配置:
export const oAuthDevelopmentConfig: AuthConfig = { …Run Code Online (Sandbox Code Playgroud) 我有这个使用ControlValueAccessor. 该组件有自己的内部表单,我找不到在哪里设置表单控件的初始值。
有人可以指出我正确的方向吗?
import {
Component, ChangeDetectorRef, forwardRef,
NgModule, OnInit} from '@angular/core';
import { FormGroup, FormControl, FormBuilder } from '@angular/forms';
import { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms';
import { CommonModule } from '@angular/common';
import { debounceTime } from 'rxjs/operators';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
export const ADDRESS_VALUE_ACCESSOR: any = {
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => AddressFormComponent),
multi: true
};
@Component({
selector: 'app-address-form',
templateUrl: 'address-form.component.html',
providers: [ADDRESS_VALUE_ACCESSOR],
})
export class AddressFormComponent implements OnInit, ControlValueAccessor {
addressForm: FormGroup; …Run Code Online (Sandbox Code Playgroud) 我使用这个javascript调整大小,最大为800px,页面上的大(5Mb)图像:
<script type="text/javascript">
$(document).ready(function () {
$('.detailImg').each(function () {
var maxWidth = 800; // Max width for the image
var maxHeight = 800; // Max height for the image
var ratio = 0; // Used for aspect ratio
var width = $(this).width(); // Current image width
var height = $(this).height(); // Current image height
// Check if the current width is larger than the max
if (width > maxWidth) {
ratio = maxWidth / width; // get ratio for scaling …Run Code Online (Sandbox Code Playgroud) 我使用 scrollTop JQuery 函数有一种奇怪的行为。我有一个包含复杂文本的 div,它分为不同的部分,如下所示:
<div id="wrapper" ... >
<div id="section1">
<h1>Section 1</h1>
Lorem ipsum dolor sit amet, consectetuer...
...
</div>
<div id="section2">
<h1>Section 2</h1>
Lorem ipsum dolor sit amet, consectetuer...
...
</div>
<div id="section3">
<h1>Section 3</h1>
Lorem ipsum dolor sit amet, consectetuer...
...
</div>
...
Run Code Online (Sandbox Code Playgroud)
第二个 DIV 包含一个简单的部分列表,当用户单击每个部分时,我希望包装器滚动到右侧部分:
<li>
<a href="#" onclick="customScrollTo('section1')">section1</a>
</li>
<li>
<a href="#" onclick="customScrollTo('section2')">section2</a>
...
Run Code Online (Sandbox Code Playgroud)
这是简单的 JS 函数:
function customScrollTo (section) {
$('#wrapper').animate({
scrollTop: $("#wrapper div[id='" + section + "']").offset().top
}, 200);
};
Run Code Online (Sandbox Code Playgroud)
现在,如果您尝试在此 JSfiddle 中对其进行测试: …
c# ×4
angular ×2
javascript ×2
jquery ×2
nhibernate ×2
winforms ×2
.net ×1
autofac ×1
itextsharp ×1
log4net ×1