Exemplo n.º 1
0
        public void TheFactoryReturnsTheMessage()
        {
            var sut = new Factory(new FakeMessageTypeProvider(), new ObjectCreatorActivator());
            var message = sut.GetMessage(1);

            Assert.IsType<SimpleMessage>(message);
        }
Exemplo n.º 2
0
        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");
        }
Exemplo n.º 3
0
        protected override void ClassProperties(Factory factory)
        {
            factory.RegisterInt("number", "Number");
            factory.RegisterString("flag", "Flag");

            base.ClassProperties(factory);
        }
Exemplo n.º 4
0
 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);
        }
Exemplo n.º 6
0
        /// <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;
            }
        }
Exemplo n.º 7
0
        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;
        }
Exemplo n.º 8
0
            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());
		}
Exemplo n.º 10
0
		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);
 }
Exemplo n.º 12
0
        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;
        }
Exemplo n.º 13
0
		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
			};	
			
		}
Exemplo n.º 14
0
         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
                };
            }
        }
Exemplo n.º 15
0
			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");

			

			}
Exemplo n.º 16
0
        public void CreateNew_ShouldInvokePassedCallbackWithNewEntity()
        {
            var factory = new Factory();
            var entity = factory.Create<TestEntity>(e => e.Name = "Explicit Value");

            Assert.Equal("Explicit Value", entity.Name);
        }
Exemplo n.º 17
0
Arquivo: D3D11.cs Projeto: Rhoana/Mojo
        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" );
            }
        }
Exemplo n.º 18
0
        /// <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);
        }
Exemplo n.º 19
0
 public Form1()
 {
     InitializeComponent();
     f = new Factory();
     f.toCompile = "C:\\lavoro-temp\\p.exe";
     f.CompilerPath = DodoPseudoCompiler.Properties.Resources.NetPath;
 }
Exemplo n.º 20
0
        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);
            }
        }
Exemplo n.º 21
0
        /// <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);
            }
        }
Exemplo n.º 22
0
        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();
        }
Exemplo n.º 23
0
	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();
	}
Exemplo n.º 24
0
        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;
            }
        }
Exemplo n.º 25
0
        public void CreateNew_ShouldCreateInstanceOfTypeParameter()
        {
            var factory = new Factory();
            var entity = factory.Create<SimpleTestEntity>();

            Assert.NotNull(entity);
            Assert.IsAssignableFrom<SimpleTestEntity>(entity);
        }
Exemplo n.º 26
0
 public UnityResolver(Factory factory)
 {
     if (factory == null)
     {
         throw new ArgumentNullException("factory");
     }
     this._factory = factory;
 }
Exemplo n.º 27
0
 /// <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))
 {
 }
Exemplo n.º 28
0
        public void TemplateNotFoundThrowsException()
        {
            string dir = Path.Combine(DATA_PATH, "enigma.xml");

            Factory factory = new Factory(dir);

            factory.CreateFromTemplate("invalidTemplateId");
        }
Exemplo n.º 29
0
        public Blog(string title, string description, Factory.IPosting postBuilder)
        {
            this.title = title;
            this.description = description;
            this.postBuilder = postBuilder;

            posts = new List<Interfaces.IPosting>();
        }
Exemplo n.º 30
0
        public void CreateNew_ShouldStillUseRegisteredFactoryFunction_WhenTypeDoesNotHaveADefaultCtor()
        {
            var factory = new Factory();
            factory.Entities.RegisterFactoryFunction(() => new SimpleTestEntityNoDefaultCtor("a"));

            var entity = factory.Create<SimpleTestEntityNoDefaultCtor>();
            Assert.NotNull(entity);
        }