本文整理汇总了C#中System.Factory类的典型用法代码示例。如果您正苦于以下问题:C# Factory类的具体用法?C# Factory怎么用?C# Factory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Factory类属于System命名空间,在下文中一共展示了Factory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TheFactoryReturnsTheMessage
public void TheFactoryReturnsTheMessage()
{
var sut = new Factory(new FakeMessageTypeProvider(), new ObjectCreatorActivator());
var message = sut.GetMessage(1);
Assert.IsType<SimpleMessage>(message);
}
示例2: Initialize
public override void Initialize()
{
using (var fac = new Factory())
{
using (var tmpDevice = new Device(fac.GetAdapter(0), DriverType.Hardware, DeviceCreationFlags.None))
{
using (var rf = new RenderForm())
{
var desc = new SwapChainDescription
{
BufferCount = 1,
Flags = SwapChainFlags.None,
IsWindowed = true,
ModeDescription = new ModeDescription(100, 100, new Rational(60, 1), Format.R8G8B8A8_UNorm),
OutputHandle = rf.Handle,
SampleDescription = new SampleDescription(1, 0),
SwapEffect = SwapEffect.Discard,
Usage = Usage.RenderTargetOutput
};
using (var sc = new SwapChain(fac, tmpDevice, desc))
{
PresentPointer = Pulse.Magic.GetObjectVtableFunction(sc.ComPointer, VMT_PRESENT);
ResetTargetPointer = Pulse.Magic.GetObjectVtableFunction(sc.ComPointer, VMT_RESIZETARGET);
}
}
}
}
_presentDelegate = Pulse.Magic.RegisterDelegate<Direct3D10Present>(PresentPointer);
_presentHook = Pulse.Magic.Detours.CreateAndApply(_presentDelegate, new Direct3D10Present(Callback), "D10Present");
}
示例3: ClassProperties
protected override void ClassProperties(Factory factory)
{
factory.RegisterInt("number", "Number");
factory.RegisterString("flag", "Flag");
base.ClassProperties(factory);
}
示例4: MeshCompiler
public MeshCompiler()
{
ImporterFactory = new Factory<string, IMeshImporter>();
ImporterFactory.Add(".xml", () => new Meshes.Converters.OgreXmlConverter());
ImporterFactory.Add(".dae", () => new Meshes.Converters.AssimpConverter());
ImporterFactory.Add(".fbx", () => new Meshes.Converters.AssimpConverter());
}
示例5: ClassProperties
protected override void ClassProperties(Factory factory)
{
factory.RegisterInt("number", "Number");
factory.RegisterInt("subtractrollnumber", "SubtractRollNumber");
base.ClassProperties(factory);
}
示例6: GetBestAdapter
/// <summary>
///
/// </summary>
/// <returns></returns>
private static Adapter GetBestAdapter()
{
using (var f = new Factory())
{
Adapter bestAdapter = null;
long bestVideoMemory = 0;
long bestSystemMemory = 0;
foreach (var item in f.Adapters)
{
var level = global::SharpDX.Direct3D11.Device.GetSupportedFeatureLevel(item);
if (level < DefaultEffectsManager.MinimumFeatureLevel)
{
continue;
}
long videoMemory = item.Description.DedicatedVideoMemory;
long systemMemory = item.Description.DedicatedSystemMemory;
if ((bestAdapter == null) || (videoMemory > bestVideoMemory) || ((videoMemory == bestVideoMemory) && (systemMemory > bestSystemMemory)))
{
bestAdapter = item;
bestVideoMemory = videoMemory;
bestSystemMemory = systemMemory;
}
}
return bestAdapter;
}
}
示例7: D3D11RenderingPane
public D3D11RenderingPane( Factory dxgiFactory, SlimDX.Direct3D11.Device d3D11Device, DeviceContext d3D11DeviceContext, D3D11HwndDescription d3D11HwndDescription )
{
mDxgiFactory = dxgiFactory;
mD3D11Device = d3D11Device;
mD3D11DeviceContext = d3D11DeviceContext;
var swapChainDescription = new SwapChainDescription
{
BufferCount = 1,
ModeDescription =
new ModeDescription( d3D11HwndDescription.Width,
d3D11HwndDescription.Height,
new Rational( 60, 1 ),
Format.R8G8B8A8_UNorm ),
IsWindowed = true,
OutputHandle = d3D11HwndDescription.Handle,
SampleDescription = new SampleDescription( 1, 0 ),
SwapEffect = SwapEffect.Discard,
Usage = Usage.RenderTargetOutput
};
mSwapChain = new SwapChain( mDxgiFactory, mD3D11Device, swapChainDescription );
mDxgiFactory.SetWindowAssociation( d3D11HwndDescription.Handle, WindowAssociationFlags.IgnoreAll );
CreateD3D11Resources( d3D11HwndDescription.Width, d3D11HwndDescription.Height );
PauseRendering = false;
}
示例8: TopToRight
public TopToRight()
{
var f = new Factory(KnownAssets.Path.Pipe.TopToRight, this.Container);
this.Outline = f.ToImage("outline");
this.Brown = f.ToImage("brown");
this.Brown.Visibility = Visibility.Hidden;
this.Green = f.ToImage("green");
this.Green.Visibility = Visibility.Hidden;
this.Yellow = f.ToImage("yellow");
this.Water = f.ToWaterImages(
"0_8",
"8_16",
"16_24",
"24_32",
"32_40",
"40_48",
"48_56",
"56_64"
);
this.OverlayBlack = f.ToImage("black");
this.OverlayBlack.Visibility = Visibility.Hidden;
this.Glow = f.ToImage("glow");
}
示例9: CollapsesPreviousWhiteSpace
public void CollapsesPreviousWhiteSpace()
{
var factory = new Factory();
// "Hello {{~test}}"
var document = factory.Document(
factory.Text("Hello"),
factory.WhiteSpace(1),
factory.Expression(
factory.MetaCode("{{", T.OpenTag),
factory.MetaCode("~", T.Tilde),
factory.Span(SpanKind.Expression, factory.Symbol("this", T.Identifier)),
factory.MetaCode("}}", T.CloseTag)));
factory = new Factory();
// "Hello{{~test}}"
var expected = factory.Document(
factory.Text("Hello"),
factory.WhiteSpace(1, collapsed: true),
factory.Expression(
factory.MetaCode("{{", T.OpenTag),
factory.MetaCode("~", T.Tilde),
factory.Span(SpanKind.Expression, factory.Symbol("this", T.Identifier)),
factory.MetaCode("}}", T.CloseTag)));
var visitor = new WhiteSpaceCollapsingParserVisitor();
visitor.VisitBlock(document);
var builder = new StringBuilder();
var comparer = new EquivalanceComparer(builder, 0);
Assert.True(comparer.Equals(expected, document), builder.ToString());
}
示例10: VTSListPresenter
public VTSListPresenter (Factory factory, ILocalizeService localaize)
{
_vtsListViewModel = factory.Get<VTSViewModel> ();
_vtsListViewModel.Server = ConfigurationManager.SERVER;
Label header = new Label {
Text = localaize.Data.vacations,// "Vacations",
Font = Font.SystemFontOfSize (30),
TextColor = Color.FromHex ("#000"),
HorizontalOptions = LayoutOptions.Center
};
_listView = new ListView {
ItemsSource = null,
ItemTemplate = new DataTemplate (typeof(VTSListViewTemplate))
};
this.Padding = new Thickness (10, Device.OnPlatform (20, 0, 0), 10, 5);
this.Content = new StackLayout {
BackgroundColor = Color.FromHex ("#FFF"),
Children = {
header,
_listView
}
};
changeListView();
}
示例11: FactoryPropertiesAreInitializedWhenFactryIsCreated
public void FactoryPropertiesAreInitializedWhenFactryIsCreated()
{
var factory = new Factory();
Assert.IsNotNull(factory.CommandLineParser);
Assert.IsNotNull(factory.FileSystem);
Assert.IsNotNull(factory.ConsoleService);
}
示例12: Load
public Order Load(int id)
{
var record = _context.Orders.Include(p => p.Lines)
.Include(p => p.BillingContact)
.Include(p => p.ShippingContact)
.Include(p => p.ShippingMethod)
.FirstOrDefault(o => o.OrderID == id);
if (record == null)
return null;
var shippingMethodRepository = new ShippingMethodRepository(_context);
var factory = new Factory(shippingMethodRepository);
var shippingMethods = shippingMethodRepository.LoadAll().Select(sm => {
var shippingMethod = sm.MapTo<ShippingMethod>();
shippingMethod.SetPrivatePropertyValue("ShippingZone", sm.ShippingZone.MapTo<ShippingZone>());
return shippingMethod;
});
var entity = record.MapTo<Order>(factory, shippingMethods);
var lines = record.Lines.Select(l => {
var line = l.MapTo<OrderLine>(factory);
line.SetPrivatePropertyValue("ProductOption", l.ProductOption.MapTo<ProductOption>());
return line;
});
entity.SetPrivateFieldValue("_lines", lines.ToList());
return entity;
}
示例13: Post
public static Response<Infante> Post(this Infante request, Factory factory,IHttpRequest httpRequest)
{
request.CheckId(Operaciones.Create);
factory.Execute(proxy=>{
if(request.IdTerceroFactura.HasValue && request.IdTerceroFactura.Value!=default(int))
{
var tercero= proxy.FirstOrDefault<Tercero>(q=>q.Id==request.IdTerceroFactura.Value);
tercero.AssertExists(request.IdTerceroFactura.Value);
request.NombreTercero=tercero.Nombre;
request.DocumentoTercero=tercero.Documento;
request.DVTercero=tercero.DigitoVerificacion;
request.TelefonoTercero= tercero.Telefono;
request.MailTercero= tercero.Mail;
}
proxy.Create<Infante>(request);
});
List<Infante> data = new List<Infante>();
data.Add(request);
return new Response<Infante>(){
Data=data
};
}
示例14: Get
public static Response<PedidoItem> Get(this PedidoItem request,Factory factory,
IAuthSession authSession)
{
try{
var data = factory.Execute(proxy=>{
var visitor = ReadExtensions.CreateExpression<PedidoItem>();
visitor.Where(r=>r.IdPedido==request.IdPedido);
return proxy.Get(visitor);
});
return new Response<PedidoItem>(){
Data=data
};
}
catch(Exception e){
ResponseStatus rs = new ResponseStatus(){
Message= e.Message,
StackTrace=e.StackTrace,
ErrorCode= e.ToString()
};
return new Response<PedidoItem>(){
ResponseStatus=rs
};
}
}
示例15: LeftToRight
public LeftToRight()
{
var f = new Factory(KnownAssets.Path.Pipe.LeftToRight, this.Container);
this.Outline = f.ToImage("outline");
this.Brown = f.ToImage("brown");
this.Brown.Visibility = Visibility.Hidden;
this.Green = f.ToImage("green");
this.Green.Visibility = Visibility.Hidden;
this.Yellow = f.ToImage("yellow");
this.Water = f.ToWaterImages(
"water",
"water"
);
this.OverlayBlack = f.ToImage("black");
this.OverlayBlack.Visibility = Visibility.Hidden;
this.Glow = f.ToImage("glow");
}