public void TheFactoryReturnsTheMessage() { var sut = new Factory(new FakeMessageTypeProvider(), new ObjectCreatorActivator()); var message = sut.GetMessage(1); Assert.IsType<SimpleMessage>(message); }
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"); }
protected override void ClassProperties(Factory factory) { factory.RegisterInt("number", "Number"); factory.RegisterString("flag", "Flag"); base.ClassProperties(factory); }
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()); }
protected override void ClassProperties(Factory factory) { factory.RegisterInt("number", "Number"); factory.RegisterInt("subtractrollnumber", "SubtractRollNumber"); base.ClassProperties(factory); }
/// <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; } }
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; }
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"); }
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()); }
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(); }
public void FactoryPropertiesAreInitializedWhenFactryIsCreated() { var factory = new Factory(); Assert.IsNotNull(factory.CommandLineParser); Assert.IsNotNull(factory.FileSystem); Assert.IsNotNull(factory.ConsoleService); }
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; }
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 }; }
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 }; } }
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"); }
public void CreateNew_ShouldInvokePassedCallbackWithNewEntity() { var factory = new Factory(); var entity = factory.Create<TestEntity>(e => e.Name = "Explicit Value"); Assert.Equal("Explicit Value", entity.Name); }
public static void Initialize( out Factory dxgiFactory, out SlimDX.Direct3D11.Device d3d11Device ) { dxgiFactory = new Factory(); Adapter adapter = null; long videoMemory = 0; for ( var i = 0; i < dxgiFactory.GetAdapterCount(); i++ ) { var tmpAdapter = dxgiFactory.GetAdapter( i ); if ( tmpAdapter.Description.DedicatedVideoMemory > videoMemory ) { adapter = tmpAdapter; videoMemory = tmpAdapter.Description.DedicatedVideoMemory; } } d3d11Device = null; try { d3d11Device = Constants.DEBUG_D3D11_DEVICE ? new SlimDX.Direct3D11.Device( adapter, DeviceCreationFlags.Debug, new[] { FeatureLevel.Level_11_0, FeatureLevel.Level_10_1, FeatureLevel.Level_10_0 } ) : new SlimDX.Direct3D11.Device( adapter, DeviceCreationFlags.None, new[] { FeatureLevel.Level_11_0, FeatureLevel.Level_10_1, FeatureLevel.Level_10_0 } ); } catch ( Exception e ) { Console.WriteLine( "\nError: Couldn't create Direct3D 11 device (exception: " + e.Source + ", " + e.Message + ").\n" ); } }
/// <summary> /// Initializes a new instance of the <see cref="DeviceContext10"/> class. /// </summary> /// <param name="handle">The window handle to associate with the device.</param> /// <param name="settings">The settings used to configure the device.</param> internal DeviceContext10(IntPtr handle, DeviceSettings10 settings) { if (handle == IntPtr.Zero) throw new ArgumentException("Value must be a valid window handle.", "handle"); if (settings == null) throw new ArgumentNullException("settings"); this.settings = settings; factory = new Factory(); device = new Direct3D10.Device(factory.GetAdapter(settings.AdapterOrdinal), Direct3D10.DriverType.Hardware, settings.CreationFlags); swapChain = new SwapChain(factory, device, new SwapChainDescription { BufferCount = 1, Flags = SwapChainFlags.None, IsWindowed = true, ModeDescription = new ModeDescription(settings.Width, settings.Height, new Rational(60, 1), Format.R8G8B8A8_UNorm), OutputHandle = handle, SampleDescription = new SampleDescription(1, 0), SwapEffect = SwapEffect.Discard, Usage = Usage.RenderTargetOutput }); factory.SetWindowAssociation(handle, WindowAssociationFlags.IgnoreAll | WindowAssociationFlags.IgnoreAltEnter); }
public Form1() { InitializeComponent(); f = new Factory(); f.toCompile = "C:\\lavoro-temp\\p.exe"; f.CompilerPath = DodoPseudoCompiler.Properties.Resources.NetPath; }
void ILoader.loadDico(LanguageDictionary dico, Factory factory) { // chargement du dico à partir d'une base SQLite // -- chargement des mots --------------------------------------- List<Dictionary<string, object>> words = this.db.select("words", new string[] { "word", "type", "attributs", "definition" }); for (int i = 0; i < words.Count; i++) { string w = (string)words[i]["word"]; string t = (string)words[i]["type"]; string a = (string)words[i]["attributs"]; string d = (string)words[i]["definition"]; if (a == null) a = ""; if (d == null) d = ""; Word word = factory.create(w, t, a.Split(new char[] {','}, StringSplitOptions.RemoveEmptyEntries), d); if (word.IsTypeOf(typeof(VerbType))) { //charger la table de conjugaison Word[] verbsConjugated = this.getConjugatedVerbsFor(word.word, factory); ConjugationTable table = new ConjugationTable(word); table.AddRange(verbsConjugated); // ajout des verbes à la table de conjugaison dico.conjugaisonTables.Add(table); // ajout de la table de conjugaison au dictionnaire dico.AddRange(verbsConjugated); // ajout des verbes au dictionnaire } dico.Add(word); } }
/// <summary> /// Initializes a new instance of the <see cref="ConfigurationItemFactory"/> class. /// </summary> /// <param name="assemblies">The assemblies to scan for named items.</param> public ConfigurationItemFactory(params Assembly[] assemblies) { this.CreateInstance = FactoryHelper.CreateInstance; this.targets = new Factory<Target, TargetAttribute>(this); this.filters = new Factory<Filter, FilterAttribute>(this); this.layoutRenderers = new Factory<LayoutRenderer, LayoutRendererAttribute>(this); this.layouts = new Factory<Layout, LayoutAttribute>(this); this.conditionMethods = new MethodFactory<ConditionMethodsAttribute, ConditionMethodAttribute>(); this.ambientProperties = new Factory<LayoutRenderer, AmbientPropertyAttribute>(this); this.timeSources = new Factory<TimeSource, TimeSourceAttribute>(this); this.allFactories = new List<object> { this.targets, this.filters, this.layoutRenderers, this.layouts, this.conditionMethods, this.ambientProperties, this.timeSources, }; foreach (var asm in assemblies) { this.RegisterItemsFromAssembly(asm); } }
public void CreateStandardMLANetwork(int iil, int oil, int nc, int nl) { PexAssume.InRange(iil, 1, 41); PexAssume.InRange(oil, 1, 41); PexAssume.InRange(nc, 1, 41); PexAssume.InRange(nl, 2, 41); var nodeF = new Factory<NeuralNode>(() => new ActivationNeuron(new SigmoidActivationFunction(1.05))); var connF = new Factory<NeuralConnection>(() => new Synapse()); var layers = new NeuralLayerDefinition[nl]; for (int i = 0; i < nl; i++) { if (i < (nl - 1)) { layers[i] = new NeuralLayerDefinition(nodeF, nc); } else { layers[i] = new NeuralLayerDefinition(nodeF, oil); } } var a = new StandardMultilayerArchitecture(new NeuralConnectionDefinition(connF, false), iil, layers); var net = a.CreateNetwork(); net.Iteration(); }
public void Init(Factory factory) { renderers = new List<IMeshRenderer>(); mesh = new Mesh(); mesh.name = "LWF/" + factory.data.name; mesh.MarkDynamic(); meshFilter = gameObject.AddComponent<MeshFilter>(); meshFilter.sharedMesh = mesh; meshRenderer = gameObject.AddComponent<UnityEngine.MeshRenderer>(); #if UNITY_4_6 meshRenderer.castShadows = false; #else meshRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; #endif meshRenderer.receiveShadows = false; UpdateSortingLayerAndOrder(factory); UpdateLayer(factory); if (factory.useAdditionalColor) { additionalColor = UnityEngine.Color.clear; property = new MaterialPropertyBlock(); additionalColorId = Shader.PropertyToID("_AdditionalColor"); } buffer = new CombinedMeshBuffer(); }
public Direct3D11Base(Form form, SwapChainDescription swapDesc, Adapter adapter = null, DriverType type = DriverType.Hardware, DeviceCreationFlags flags = DeviceCreationFlags.None, FeatureLevel[] levels = null) { IsDisposed = false; try { _isInitializing = true; _form = form; _isComposited = DwmApi.IsCompositionEnabled; if (_isComposited) { DwmApi.EnableMMCSS(true); DwmPresentParameters present = new DwmPresentParameters() { IsQueued = true, BufferCount = 2, RefreshesPerFrame = 1, }; DwmApi.SetPresentParameters(form.Handle, ref present); } if (swapDesc.OutputHandle != IntPtr.Zero) { throw new ArgumentException("Output handle must not be set."); } if (swapDesc.Usage != Usage.RenderTargetOutput) { throw new ArgumentException("Usage must be RenderTargetOutput."); } swapDesc.OutputHandle = _form.Handle; bool setFullscreen = !swapDesc.IsWindowed; swapDesc.IsWindowed = true; Device.CreateWithSwapChain(adapter, type, DeviceCreationFlags.None, levels, swapDesc, out _device, out _swapChain); _swapChain.ResizeTarget(swapDesc.ModeDescription); _factory = _swapChain.GetParent<Factory>(); _factory.SetWindowAssociation(_form.Handle, WindowAssociationFlags.IgnoreAll); _form.SizeChanged += SizeChanged_Handler; _form.ResizeBegin += ResizeBegin_Handler; _form.Resize += Resize_Handler; _form.ResizeEnd += ResizeEnd_Handler; _form.KeyDown += KeyDown_Handler; if (setFullscreen) { ChangeMode(true); } _isInitializing = false; } catch { Dispose(); throw; } }
public void CreateNew_ShouldCreateInstanceOfTypeParameter() { var factory = new Factory(); var entity = factory.Create<SimpleTestEntity>(); Assert.NotNull(entity); Assert.IsAssignableFrom<SimpleTestEntity>(entity); }
public UnityResolver(Factory factory) { if (factory == null) { throw new ArgumentNullException("factory"); } this._factory = factory; }
/// <summary> /// Initializes a new instance of the <see cref="WordRibbonFactory"/> class. /// </summary> /// <param name="viewModelFactory">A view model factory</param> /// <param name="customTaskPaneCollection">A delayed resolution instance of the custom task pane collection of your addin 'new Lazy(()=>CustomTaskPaneCollection)'</param> /// <param name="vstoFactory">The VSTO factory (Globals.Factory)</param> /// <param name="assemblies">Assemblies to scan for view models</param> public WordRibbonFactory( IViewModelFactory viewModelFactory, Func<object> customTaskPaneCollection, Factory vstoFactory, params Assembly[] assemblies) : base(new RibbonFactoryController<WordRibbonType>(assemblies, new WordViewContextProvider(), viewModelFactory, customTaskPaneCollection, vstoFactory)) { }
public void TemplateNotFoundThrowsException() { string dir = Path.Combine(DATA_PATH, "enigma.xml"); Factory factory = new Factory(dir); factory.CreateFromTemplate("invalidTemplateId"); }
public Blog(string title, string description, Factory.IPosting postBuilder) { this.title = title; this.description = description; this.postBuilder = postBuilder; posts = new List<Interfaces.IPosting>(); }
public void CreateNew_ShouldStillUseRegisteredFactoryFunction_WhenTypeDoesNotHaveADefaultCtor() { var factory = new Factory(); factory.Entities.RegisterFactoryFunction(() => new SimpleTestEntityNoDefaultCtor("a")); var entity = factory.Create<SimpleTestEntityNoDefaultCtor>(); Assert.NotNull(entity); }