public void Initialize()
 {
     Factory = new ComponentFactory();
     Factory.Register<ISomeComponent, SomeComponent>();
     Factory.Register<IComplexComponent, ConstructedComplexComponent>();
     Factory.Register<IAncillaryComponent, AncillaryComponent>();
 }
        public StringDisplayAppState(Size screenBounds)
        {
            var componentTuple = new ComponentFactory().CreateStringDisplayComponentRendererTupes(screenBounds).ToList();
            Components = componentTuple.Select(tuple => tuple.Item1).ToList();
            Renderers = componentTuple.Select(tuple => tuple.Item2).ToList();

            _particleComponent = (ParticleComponent)Components.Single(c => c.ComponentType == ComponentType.Particles);
        }
 public void SetRtbTextColor(ComponentFactory.Krypton.Toolkit.KryptonRichTextBox kryRTbx)
 {
     kryRTbx.SelectAll();
     kryRTbx.SelectionColor = Color.Black;
     SetRtbTextColor(kryRTbx, keywords, Color.Blue);
     //SetRtbTextColor(kryRTbx, functions, Color.Magenta);
     //SetRtbTextColor(kryRTbx, strings, Color.Red);
     //SetRtbTextColor(kryRTbx, whitespace, Color.Black);
 }
        /// <summary> 
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            Graphics.PreferredBackBufferWidth = 1280;
            Graphics.PreferredBackBufferHeight = 720;
            Graphics.ApplyChanges();
            
            Components.Add(new FrameRateCounter(this, "Content\\debugfont", 1f));
            Components.Add(new GameObjectInfoDisplay(this, 5, "Content\\debugfont", new Vector2(0f, 25f)));

            ComponentFactory componentFactory = new ComponentFactory();
            TiledGameObjectFactory gameObjectFactory = new TiledGameObjectFactory(this.Content);
            gameObjectFactory.PathToXML = "EntityDefinitions\\entity.xml";
            
            inputHandler = new InputHandler(false);
            playerManager = new PlayerManager();

            particleManager = new ParticleManager(Content, "ParticleEffects\\", "Textures\\");

            PhysicsManager physicsManager = new PhysicsManager();
            particleRenderer = new SpriteBatchRenderer();
            particleRenderer.GraphicsDeviceService = Graphics;

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            renderer = new Renderer(Graphics, spriteBatch);
            renderer.SetInternalResolution(1280, 720);
            renderer.SetScreenResolution(1280, 720, false);

            GameServiceManager.AddService(typeof(IGameObjectFactory), gameObjectFactory);
            GameServiceManager.AddService(typeof(IComponentFactory), componentFactory);
            GameServiceManager.AddService(typeof(RenderableFactory), new RenderableFactory(this.Content));
            GameServiceManager.AddService(typeof(IInputHandler), inputHandler);
            GameServiceManager.AddService(typeof(PlayerManager), playerManager);
            GameServiceManager.AddService(typeof(IScoreManager), new ScoreManager());
            GameServiceManager.AddService(typeof(IGameObjectManager), new GameObjectManager());
            GameServiceManager.AddService(typeof(IPhysicsManager), physicsManager);
            GameServiceManager.AddService(typeof(IBehaviorFactory), new BehaviorFactory());
            GameServiceManager.AddService(typeof(IActionFactory), new ActionFactory());
            GameServiceManager.AddService(typeof(IActionManager), new ActionManager());
            GameServiceManager.AddService(typeof(ILevelLogicManager), new LevelLogicManager(this.Content));
            GameServiceManager.AddService(typeof(IRandomGenerator), new RandomGenerator());
            GameServiceManager.AddService(typeof(IParticleManager), particleManager);
            GameServiceManager.AddService(typeof(IRenderer), renderer);

            debugView = new DebugViewXNA(GameServiceManager.GetService<IPhysicsManager>().PhysicsWorld);

            //Initialize the GameServices
            GameServiceManager.Initialize();
            
            CameraController.Initialize(this);
            CameraController.MoveCamera(new Vector2(GraphicsDevice.Viewport.Width / 2f, GraphicsDevice.Viewport.Height / 2f));
            
            base.Initialize();
        }
 public void SetRtbTextColor(ComponentFactory.Krypton.Toolkit.KryptonRichTextBox kryRTbx, List<string> words, Color color)
 {
     foreach (string word in words)
     {
         Regex r = new Regex(word);
         foreach (Match m in r.Matches(kryRTbx.Text))
         {
             kryRTbx.Select(m.Index, m.Length);
             kryRTbx.SelectionColor = color;
         }
     }
 }
 private void drawString(Graphics g, Control label, ComponentFactory.Krypton.Toolkit.KryptonTextBox textLabel)
 {
     Margins margins = printDocument.DefaultPageSettings.Margins;
     String text = label.Text;
     Font font = new Font(label.Font.FontFamily, label.Font.Size * x, label.Font.Style);
     RectangleF rect = new RectangleF(label.Location.X * x + margins.Left, label.Location.Y * y + margins.Top, g.MeasureString(text, font).Width * x, g.MeasureString(text, font).Height * y);
     g.DrawString(text, font, brush, rect, labelFormat);
     text = textLabel.Text;
     font = new Font(textLabel.StateCommon.Content.Font.FontFamily, textLabel.StateCommon.Content.Font.Size * x, textLabel.StateCommon.Content.Font.Style);
     rect = new RectangleF(textLabel.Location.X * x + margins.Left + textLabel.StateCommon.Content.Padding.All, textLabel.Location.Y * y + margins.Top, g.MeasureString(text, font).Width * x, g.MeasureString(text, font).Height * y);
     g.DrawString(text, font, brush, rect, textFormat);
 }
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            Graphics.PreferredBackBufferWidth = 1920;
            Graphics.PreferredBackBufferHeight = 1080;

            Graphics.SynchronizeWithVerticalRetrace = false;
            IsFixedTimeStep = false;

            Graphics.ApplyChanges();

            Components.Add(new FrameRateCounter(this, "Content\\Fonts\\fpsfont"));
            Components.Add(new GameObjectInfoDisplay(this, 5, "Content\\Fonts\\debugfont", new Vector2(0f, 25f)));


            ComponentFactory componentFactory = new ComponentFactory();
            GameObjectFactory gameObjectFactory = new GameObjectFactory(this.Content);
            gameObjectFactory.PathToXML = "EntityDefinitions\\entity.xml";

            InputHandler inputHandler = new InputHandler(false);
            PlayerManager playerManager = new PlayerManager();

            var collisionManager = new CollisionManager(new RectangleF(0f, 0f, Constants.INTERNAL_SCREEN_WIDTH, Constants.INTERNAL_SCREEN_HEIGHT));

            var particleManager = new ParticleManager(Content, "ParticleEffects\\", "Textures\\");

            GameServiceManager.AddService(typeof(IGameObjectFactory), gameObjectFactory);
            GameServiceManager.AddService(typeof(IComponentFactory), componentFactory);
            GameServiceManager.AddService(typeof(RenderableFactory), new RenderableFactory(this.Content));
            GameServiceManager.AddService(typeof(IInputHandler), inputHandler);
            GameServiceManager.AddService(typeof(PlayerManager), playerManager);
            GameServiceManager.AddService(typeof(IGameObjectManager), new GameObjectManager());
            GameServiceManager.AddService(typeof(ICollisionManager), collisionManager);
            GameServiceManager.AddService(typeof(IBehaviorFactory), new BehaviorFactory());
            GameServiceManager.AddService(typeof(IActionFactory), new ActionFactory());
            GameServiceManager.AddService(typeof(IRandomGenerator), new RandomGenerator());
            GameServiceManager.AddService(typeof(IParticleManager), particleManager);
            GameServiceManager.AddService(typeof(ILayerManager), new LayerManager("CollisionDefinitions\\layers.xml", this.Content));
            GameServiceManager.AddService(typeof(IActionManager), new ActionManager());

            //Initialize the GameServices););
            foreach (IGameService service in GameServiceManager.Services)
            {
                service.Initialize();
            }

            CameraController.Initialize(this);
            CameraController.MoveCamera(new Vector2(GraphicsDevice.Viewport.Width / 2f, GraphicsDevice.Viewport.Height / 2f));

            base.Initialize();
        }
        public void Init(Initializer init)
        {
            Factory = new ComponentFactory();

            InitializerHelper = init;

            RegisterServices();

            Engine = Factory.Instantiate<IEngine>();

            Engine.UniqueId = "1";

            AddTestSubscriptions();
        }
Exemple #9
0
        private void button1_Click(object sender, ComponentFactory.Krypton.Toolkit.ContextPositionMenuArgs e)
        {
            ArrayList CollectInfoList = new ArrayList();
            GetCollectInfoId get = new GetCollectInfoId(CollectInfoList);
            //GetCollectID get = new GetCollectID(list, this.kryptonDropButton1.Text.Split(','));
            if (get.ShowDialog() == DialogResult.OK)
            {

                string CollectInfoListString = "";
                foreach (string CollectInfoId in CollectInfoList)
                    CollectInfoListString += CollectInfoId + ",";
                if (CollectInfoList.Count != 0)
                    CollectInfoListString = CollectInfoListString.Substring(0, CollectInfoListString.Length - 1);
                if (CollectInfoListString.Trim() != "")
                    this.kryptonDropButton1.Text = CollectInfoListString;
            }
        }
Exemple #10
0
        public override void SetParentTransform(GameObject gameObject, Transform parent)
        {
            if (gameObject == null)
            {
                throw new System.Exception("gameObject == null");
            }

            if (m_setting == null)
            {
                m_setting = ComponentFactory.GetComponent <T>(gameObject, IfNotExist.AddNew);
            }

            if (this.gameObject != null)
            {
                Name = this.gameObject.name;
            }

            if (transform != null)
            {
                transform.SetParent(parent);
            }
        }
Exemple #11
0
        public void Write(IBitWriter writer)
        {
            const ushort componentContainerVersion = 5;

            writer.WriteUInt16(componentContainerVersion);

            writer.PushFrameLength(24);

            writer.WriteUInt16((ushort)this._ComponentContainers.Count);
            foreach (var kv in this._ComponentContainers)
            {
                var componentContainer = kv.Value;

                writer.PushFrameLength(24);

                writer.WriteUInt32(kv.Key);
                writer.WriteBoolean(componentContainer != null);

                if (componentContainer != null)
                {
                    writer.WriteBoolean(componentContainer.Unknown1);
                    writer.WriteString(componentContainer.Unknown2);

                    writer.WriteUInt16((ushort)componentContainer.Components.Count);
                    foreach (var component in componentContainer.Components)
                    {
                        writer.PushFrameLength(24);
                        var componentNameHash = ComponentFactory.GetNameHash(component.ComponentName);
                        writer.WriteUInt32(componentNameHash);
                        component.Write(writer, componentContainerVersion);
                        writer.PopFrameLength();
                    }
                }

                writer.PopFrameLength();
            }

            writer.PopFrameLength();
        }
Exemple #12
0
        private void Application_Start(object sender, EventArgs eventArgs)
        {
            Logger.InfoFormat("Application Starting ({0})", Globals.ElapsedSinceAppStart); // just to start the timer

            var name = Config.GetSetting("ServerName");

            Globals.ServerName = String.IsNullOrEmpty(name) ? Dns.GetHostName() : name;

            ComponentFactory.Container = new SimpleContainer();

            ComponentFactory.InstallComponents(new ProviderInstaller("data", typeof(DataProvider), typeof(SqlDataProvider)));
            ComponentFactory.InstallComponents(new ProviderInstaller("caching", typeof(CachingProvider), typeof(FBCachingProvider)));
            ComponentFactory.InstallComponents(new ProviderInstaller("logging", typeof(LoggingProvider), typeof(DBLoggingProvider)));
            ComponentFactory.InstallComponents(new ProviderInstaller("scheduling", typeof(SchedulingProvider), typeof(DNNScheduler)));
            ComponentFactory.InstallComponents(new ProviderInstaller("searchIndex", typeof(IndexingProvider), typeof(ModuleIndexer)));
            #pragma warning disable 0618
            ComponentFactory.InstallComponents(new ProviderInstaller("searchDataStore", typeof(SearchDataStoreProvider), typeof(SearchDataStore)));
            #pragma warning restore 0618
            ComponentFactory.InstallComponents(new ProviderInstaller("members", typeof(MembershipProvider), typeof(AspNetMembershipProvider)));
            ComponentFactory.InstallComponents(new ProviderInstaller("roles", typeof(RoleProvider), typeof(DNNRoleProvider)));
            ComponentFactory.InstallComponents(new ProviderInstaller("profiles", typeof(ProfileProvider), typeof(DNNProfileProvider)));
            ComponentFactory.InstallComponents(new ProviderInstaller("permissions", typeof(PermissionProvider), typeof(CorePermissionProvider)));
            ComponentFactory.InstallComponents(new ProviderInstaller("outputCaching", typeof(OutputCachingProvider)));
            ComponentFactory.InstallComponents(new ProviderInstaller("moduleCaching", typeof(ModuleCachingProvider)));
            ComponentFactory.InstallComponents(new ProviderInstaller("sitemap", typeof(SitemapProvider), typeof(CoreSitemapProvider)));

            ComponentFactory.InstallComponents(new ProviderInstaller("friendlyUrl", typeof(FriendlyUrlProvider)));
            ComponentFactory.InstallComponents(new ProviderInstaller("folder", typeof(FolderProvider)));
            RegisterIfNotAlreadyRegistered <FolderProvider, StandardFolderProvider>("StandardFolderProvider");
            RegisterIfNotAlreadyRegistered <FolderProvider, SecureFolderProvider>("SecureFolderProvider");
            RegisterIfNotAlreadyRegistered <FolderProvider, DatabaseFolderProvider>("DatabaseFolderProvider");
            RegisterIfNotAlreadyRegistered <PermissionProvider>();
            ComponentFactory.InstallComponents(new ProviderInstaller("htmlEditor", typeof(HtmlEditorProvider), ComponentLifeStyleType.Transient));
            ComponentFactory.InstallComponents(new ProviderInstaller("navigationControl", typeof(NavigationProvider), ComponentLifeStyleType.Transient));
            ComponentFactory.InstallComponents(new ProviderInstaller("clientcapability", typeof(ClientCapabilityProvider)));
            ComponentFactory.InstallComponents(new ProviderInstaller("cryptography", typeof(CryptographyProvider), typeof(CoreCryptographyProvider)));

            Logger.InfoFormat("Application Started ({0})", Globals.ElapsedSinceAppStart); // just to start the timer
        }
        private static void LoadProviders()
        {
            // Avoid claiming lock if providers are already loaded
            if (_providers == null)
            {
                lock (_lock)
                {
                    _providers = new List <SitemapProvider>();


                    foreach (KeyValuePair <string, SitemapProvider> comp in ComponentFactory.GetComponents <SitemapProvider>())
                    {
                        comp.Value.Name        = comp.Key;
                        comp.Value.Description = comp.Value.Description;
                        _providers.Add(comp.Value);
                    }


                    //'ProvidersHelper.InstantiateProviders(section.Providers, _providers, GetType(SiteMapProvider))
                }
            }
        }
Exemple #14
0
    void Start()
    {
        Player player = EntityFactory.Create <Player, string>("model");

        Game.Scene.AddChild(player);
        InputComponent input = ComponentFactory.CreateWithEntity <InputComponent, string, string>(Game.Scene, "GameInputControl", "KeyBordControl");

        input.onStarted += (ctx) =>
        {
            player.GetComponent <Live2dComponent>().PlayAnimation("Walk");
        };

        input.onPerformed += (ctx) =>
        {
            player.GetComponent <Live2dComponent>().PlayAnimation("Run");
        };

        input.onCanceled += (ctx) =>
        {
            player.GetComponent <Live2dComponent>().PlayAnimation("Idle");
        };
    }
Exemple #15
0
    public void InstantiateComponent_AssignsPropertiesWithInjectAttributeOnBaseType()
    {
        // Arrange
        var componentType = typeof(DerivedComponent);
        var factory       = new ComponentFactory(new CustomComponentActivator <DerivedComponent>());

        // Act
        var instance = factory.InstantiateComponent(GetServiceProvider(), componentType);

        // Assert
        Assert.NotNull(instance);
        var component = Assert.IsType <DerivedComponent>(instance);

        Assert.NotNull(component.Property1);
        Assert.NotNull(component.GetProperty2());
        Assert.NotNull(component.Property3);

        // Property on derived type without [Inject] should not be assigned
        Assert.Null(component.Property4);
        // Property on the base type with the [Inject] attribute should
        Assert.NotNull(((ComponentWithInjectProperties)component).Property4);
    }
Exemple #16
0
        private static Mock <TMock> RegisterMockController <TMock>(Mock <TMock> mock) where TMock : class
        {
            if (ComponentFactory.Container == null)
            {
                //Create a Container
                ComponentFactory.Container = new SimpleContainer();
            }

            //Try and get mock
            var getMock = ComponentFactory.GetComponent <Mock <TMock> >();

            if (getMock == null)
            {
                // Create the mock
                getMock = mock;

                // Add both mock and mock.Object to Container
                ComponentFactory.RegisterComponentInstance <Mock <TMock> >(getMock);
                ComponentFactory.RegisterComponentInstance <TMock>(getMock.Object);
            }
            return(getMock);
        }
Exemple #17
0
        public override void Init(
            InitDelegate onInitComplete,
            string appId,
            bool cookie,
            bool logging,
            bool status,
            bool xfbml,
            string channelUrl,
            string authResponse,
            bool frictionlessRequests,
            HideUnityDelegate hideUnityDelegate)
        {
            if (onInitComplete != null)
            {
                onInitComplete();
            }

            var editorFB = ComponentFactory.GetComponent <EditorFacebookGameObject>();

            editorFB.OnInitComplete("");
            editorFB.edFb = this;
        }
Exemple #18
0
        public async void Process_GetCorrectOutput(char inputLetter, char expectedLetter, bool step, bool expectedStep, int position, int expectedPosition,
                                                   RotorType type = RotorType.I, RotorSlot slot = RotorSlot.One)
        {
            // Arrange
            var utilityFactory   = new UtilityFactory();
            var componentFactory = new ComponentFactory(utilityFactory);
            var rotor            = componentFactory.CreateRotor(type, slot, position);
            var inputValue       = CommonHelper.LetterToNumber(inputLetter);
            var signal           = await utilityFactory.CreateSignal(inputValue, step, SignalDirection.In);

            // Act
            var resultSignal = await rotor.Process(signal);

            var resultValue  = resultSignal.Value;
            var resultLetter = CommonHelper.NumberToLetter(resultValue);
            var resultStep   = resultSignal.Step;

            // Assert
            Assert.Equal(expectedLetter, resultLetter);
            Assert.Equal(expectedStep, resultStep);
            Assert.Equal(expectedPosition, rotor.PositionShift);
        }
Exemple #19
0
        protected override async void Run(Session session, C2G_AddDealOrder message, Action <G2C_AddDealOrder> reply)
        {
            G2C_AddDealOrder response = new G2C_AddDealOrder();

            try
            {
                DBProxyComponent dBProxyComponent = Game.Scene.GetComponent <DBProxyComponent>();

                DealOrder DealOrder = ComponentFactory.Create <DealOrder>();
                DealOrder._InvAccountID        = message.InvAccountID;
                DealOrder._ByInvAccountID      = message.ByInvAccountID;
                DealOrder._ProductID           = message.ProductID;
                DealOrder._InvItemList         = RepeatedFieldAndListChangeTool.RepeatedFieldToList(message.InvItemList);
                DealOrder._InvProductPoint     = message.InvProductPoint;
                DealOrder._InvProductDiamond   = message.InvProductDiamond;
                DealOrder._InvItemList         = RepeatedFieldAndListChangeTool.RepeatedFieldToList(message.ByInvItemList);
                DealOrder._ByInvProductPoint   = message.ByInvProductPoint;
                DealOrder._ByInvProductDiamond = message.ByInvProductDiamond;
                DealOrder._InvItemList         = RepeatedFieldAndListChangeTool.RepeatedFieldToList(message.MessageList);
                DealOrder._CreateDate          = message.CreateDate;
                DealOrder._DealDate            = message.DealDate;
                DealOrder._InvIP   = message.InvIP;
                DealOrder._ByInvIP = message.ByInvIP;
                DealOrder._State   = message.State;

                await dBProxyComponent.Save(DealOrder);

                await dBProxyComponent.SaveLog(DealOrder);

                reply(response);
            }
            catch (Exception e)
            {
                response.IsOk    = false;
                response.Message = "数据库异常";
                ReplyError(response, e, reply);
            }
        }
Exemple #20
0
        void ListBoxDragDropTarget_ItemDragCompleted(object sender, ItemDragEventArgs e)
        {
            //当拖拽发生后,把横向quicklink中的所有的item的status都更新成"Y"
            for (int i = 0; i < MainListBox.Items.Count; i++)
            {
                (MainListBox.Items[i] as QuickLinksModel).ViewStatus = "Y";
                if (i == 0)
                {
                    (MainListBox.Items[i] as QuickLinksModel).IsVisibable = false;
                }
                else
                {
                    (MainListBox.Items[i] as QuickLinksModel).IsVisibable = true;
                }
            }
            //当拖拽发生后,把纵向quicklink中的所有的item的status都更新成"N"
            for (int i = 0; i < PopupListBox.Items.Count; i++)
            {
                (PopupListBox.Items[i] as QuickLinksModel).ViewStatus = "N";
            }

            ResetOrderIndexforLinks();

            ComponentFactory.GetComponent <IUserProfile>().Set(UserProfileKey.Key_QuickLink, ListItems, true);

            LoadListBox();

            OnSizeChangeArrangeLine();

            //如果下拉列表是显示的,在拖拽完成后则恢复用于其点击消失的隐藏层。
            if (RichContentPopup.IsOpen == true)
            {
                if (!((Panel)((UserControl)Application.Current.RootVisual).Content).Children.Contains(m_PopupCloseHelpGrid))
                {
                    ((Panel)((UserControl)Application.Current.RootVisual).Content).Children.Add(m_PopupCloseHelpGrid);
                }
            }
        }
Exemple #21
0
        static void Main(string[] args)
        {
            /*SCConfig config = new SCConfig();
             *
             * ServiceDef sd = new ServiceDef()
             * {
             *  ID = 1,
             *  Name = "Test Service",
             *  Host = "localhost",
             *  Port = 5000,
             *  // Host = "http://depechemode345.com",
             *  // Host = "http://localhost:5000/",
             *  PollPeriod = 10
             * };
             *
             * config.Services = new ServiceDef[1] { sd };*/


            ServiceCheckerConfig config = ServiceCheckerFactory.CreateConfigMaster().LoadFromYaml("../config/config.yaml");

            runner = ServiceCheckerFactory.CreateRunner(ComponentFactory.CreateTimeMaster(), ComponentFactory.CreateOutput(config.Output), config.Services, false);

            // Fire and forget
            Task.Run(() =>
            {
                runner.Start();
            });

            Console.CancelKeyPress += OnCancel;

            while (true)
            {
                if (stopped.WaitOne(1000))
                {
                    break;
                }
            }
        }
Exemple #22
0
        private void Create()
        {
            m_items = new List <ScrollItem>();

            m_maxItemCount = m_pattern.ViewCount * 3;

            for (int i = 0; i < m_maxItemCount; i++)
            {
                GameObject instanceObj =
                    GameObject.Instantiate(m_reousrce, Vector3.zero, Quaternion.identity, m_rect.content) as GameObject;
                ScrollItem item = ComponentFactory.GetComponent <ScrollItem>(instanceObj, IfNotExist.AddNew);

                if (item != null)
                {
                    item.SetAlive(false);
                    item.UpdateOwner();

                    m_items.Add(item);
                }
            }

            m_initFlag = true;
        }
Exemple #23
0
    protected bool CreateManager <T1, T2>(ref T1 manager) where T1 : ManagerBase, new() where T2 : ManagerSettingBase
    {
        if (manager != null)
        {
            // error message
            return(false);
        }

        T2 setting = ComponentFactory.GetChildComponent <T2>(GameObject, IfNotExist.ReturnNull);

        if (setting == null)
        {
            setting = ComponentFactory.GetComponent <T2>(GameObject, IfNotExist.AddNew);
            if (Application.isPlaying)
            {
                LogWarning(StringUtil.Format("{0} component is automatically created", typeof(T2).ToString()));
            }
        }

        manager = new T1();
        manager.OnAppStart(setting);
        return((manager != null) ? true : false);
    }
Exemple #24
0
        public void SetUp()
        {
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddTransient <IApplicationStatusInfo>(container => Mock.Of <IApplicationStatusInfo>());
            serviceCollection.AddTransient <INavigationManager>(container => Mock.Of <INavigationManager>());
            serviceCollection.AddTransient <IHostSettingsService, HostController>();
            Globals.DependencyProvider = serviceCollection.BuildServiceProvider();

            ComponentFactory.RegisterComponentInstance <TokenProvider>(new CoreTokenProvider());
            this.mockCache          = MockComponentProvider.CreateDataCacheProvider();
            this.mockHostController = new Mock <IHostController>();
            this.portalController   = new Mock <IPortalController>();
            this.moduleController   = new Mock <IModuleController>();
            this.userController     = new Mock <IUserController>();
            PortalController.SetTestableInstance(this.portalController.Object);
            ModuleController.SetTestableInstance(this.moduleController.Object);
            UserController.SetTestableInstance(this.userController.Object);
            HostController.RegisterInstance(this.mockHostController.Object);
            this.SetupPortalSettings();
            this.SetupModuleInfo();
            this.SetupUserInfo();
        }
Exemple #25
0
        private void TextBlockButtonFavorite_Loaded(object sender, RoutedEventArgs e)
        {
            var currentObj = (TextBlock)sender;

            if (currentObj.Tag == null)
            {
                currentObj.Tag = false;
            }
            else
            {
                return;
            }

            ItemData lastFvtItemData = ComponentFactory.GetComponent <IUserProfile>().Get <ItemData>(UserProfileKey.Key_FavoriteStatus);

            if (lastFvtItemData != null && ((ItemData)currentObj.DataContext).Id == lastFvtItemData.Id)
            {
                currentObj.TextDecorations = TextDecorations.Underline;
                currentObj.Foreground      = new SolidColorBrush(Color.FromArgb(255, 39, 83, 156));
                currentObj.Tag             = true;
                LastSubMenuItemInFvt       = currentObj;
            }
        }
Exemple #26
0
        public MiniToolBar()
        {
            InitializeComponent();

            m_HistoryCloseHelpGrid.SetValue(Canvas.ZIndexProperty, 50);

            MiniButtonHome.Click    += new RoutedEventHandler(MiniButtonHome_Click);
            MiniButtonRefresh.Click += new RoutedEventHandler(MiniButtonRefresh_Click);
            MiniButtonRevoked.Click += new RoutedEventHandler(MiniButtonRevoked_Click);
            MiniButtonHistory.Click += new RoutedEventHandler(MiniButtonHistory_Click);
            MiniButtonRequest.Click += new RoutedEventHandler(MiniButtonRequest_Click);

            PopupHistory.Opened += new EventHandler(PopupHistory_Opened);
            PopupHistory.Closed += new EventHandler(PopupHistory_Closed);

            ListBoxHistory.SelectionChanged          += new SelectionChangedEventHandler(ListBoxHistory_SelectionChanged);
            m_HistoryCloseHelpGrid.MouseLeftButtonUp += new MouseButtonEventHandler(m_HistoryCloseHelpGrid_MouseLeftButtonUp);

            if (ComponentFactory.GetComponent <IConfiguration>().GetConfigValue("Framework", "RequestPanelConfig") == null)
            {
                MiniButtonRequest.Visibility = System.Windows.Visibility.Collapsed;
            }
        }
Exemple #27
0
        public string GetEffectiveCacheMethod()
        {
            string effectiveCacheMethod;

            if (!string.IsNullOrEmpty(CacheMethod))
            {
                effectiveCacheMethod = CacheMethod;
            }
            else if (!string.IsNullOrEmpty(Host.Host.ModuleCachingMethod))
            {
                effectiveCacheMethod = Host.Host.ModuleCachingMethod;
            }
            else
            {
                var defaultModuleCache = ComponentFactory.GetComponent <ModuleCachingProvider>();
                effectiveCacheMethod = (from provider in ModuleCachingProvider.GetProviderList() where provider.Value.Equals(defaultModuleCache) select provider.Key).SingleOrDefault();
            }
            if (string.IsNullOrEmpty(effectiveCacheMethod))
            {
                throw new InvalidOperationException(Localization.GetString("EXCEPTION_ModuleCacheMissing"));
            }
            return(effectiveCacheMethod);
        }
        protected override void Given()
        {
            Dependency <IComponentNameResolver>()
            .Stub(s => s.ResolveName <TestEntity, string>(null))
            .IgnoreArguments()
            .Return("thename");

            Dependency <IComponentIdResolver>()
            .Stub(s => s.ResolveId <TestEntity, string>(null, null))
            .IgnoreArguments()
            .Return("theid");

            Dependency <IComponentLabelResolver>()
            .Stub(s => s.ResolveLabel <TestEntity, string>(null))
            .IgnoreArguments()
            .Return("thelabel");

            this.configuration = Dependency <IFormConfiguration>();

            this.entity = new TestEntity();

            factory = Subject <ComponentFactory <TestEntity> >();
        }
        public void ContentController_AddContentItem_Sets_CreatedByUserId_And_LastModifiedUserId()
        {
            // Arrange
            Mock <IDataService> mockDataService = new Mock <IDataService>();

            mockDataService.Setup(ds => ds.AddContentItem(It.IsAny <ContentItem>(), It.IsAny <int>())).Returns(Constants.CONTENT_AddContentItemId);
            ContentController controller = new ContentController(mockDataService.Object);

            ComponentFactory.RegisterComponentInstance <IContentController>(controller);

            ContentItem content = ContentTestHelper.CreateValidContentItem();

            content.ContentItemId   = Constants.CONTENT_ValidContentItemId;
            content.CreatedByUserID = 1;

            // Act
            int contentId = controller.AddContentItem(content);

            // Assert
            mockDataService.Verify(
                service =>
                service.AddContentItem(It.IsAny <ContentItem>(), content.CreatedByUserID), Times.Once);
        }
Exemple #30
0
        //Open Mail Page
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            var count = 0;

            var mail = new MailMessage();

            mail.From      = "*****@*****.**";
            mail.To        = "*****@*****.**";
            mail.ReplyName = "";
            mail.Subject   = "test subject";
            mail.Body      = "test.body";
            mail.Priority  = MailPriority.Low;
            mail.BodyType  = MailBodyType.Html;

            ComponentFactory.GetComponent <IMail>().OpenMailPage(mail, new MailPageSetting
            {
                IsAllowAttachment = true
            }, args =>
            {
                count++;
                CPApplication.Current.Browser.Alert(args.IsSuccess.ToString());
            });
        }
        public static Mock <CachingProvider> CreateMockProvider()
        {
            if (ComponentFactory.Container == null)
            {
                //Create a Container
                ComponentFactory.Container = new SimpleContainer();
            }

            //Try and get mock
            var mockCache = ComponentFactory.GetComponent <Mock <CachingProvider> >();

            if (mockCache == null)
            {
                // Create the mock CachingProvider
                mockCache = new Mock <CachingProvider>();

                // Add both mock and mock.Object to Container
                ComponentFactory.RegisterComponentInstance <Mock <CachingProvider> >(mockCache);
                ComponentFactory.RegisterComponentInstance <CachingProvider>(mockCache.Object);
            }

            return(mockCache);
        }
		protected override void Given()
		{
			Dependency<IComponentNameResolver>()
				.Stub(s => s.ResolveName<TestEntity, string>(null))
				.IgnoreArguments()
				.Return("thename");

			Dependency<IComponentIdResolver>()
				.Stub(s => s.ResolveId<TestEntity, string>(null, null))
				.IgnoreArguments()
				.Return("theid");

			Dependency<IComponentLabelResolver>()
				.Stub(s => s.ResolveLabel<TestEntity, string>(null))
				.IgnoreArguments()
				.Return("thelabel");

			this.configuration = Dependency<IFormConfiguration>();

			this.entity = new TestEntity();

			factory = Subject<ComponentFactory<TestEntity>>();
		}
        public void SetUp()
        {
            Globals.SetStatus(Globals.UpgradeStatus.None);

            ComponentFactory.Container = new SimpleContainer();
            ComponentFactory.InstallComponents(new ProviderInstaller("data", typeof(DataProvider), typeof(SqlDataProvider)));
            ComponentFactory.InstallComponents(new ProviderInstaller("caching", typeof(CachingProvider), typeof(FBCachingProvider)));
            ComponentFactory.InstallComponents(new ProviderInstaller("logging", typeof(LoggingProvider), typeof(DBLoggingProvider)));
            ComponentFactory.InstallComponents(new ProviderInstaller("members", typeof(MembershipProvider), typeof(AspNetMembershipProvider)));
            ComponentFactory.InstallComponents(new ProviderInstaller("roles", typeof(RoleProvider), typeof(DNNRoleProvider)));
            ComponentFactory.InstallComponents(new ProviderInstaller("profiles", typeof(ProfileProvider), typeof(DNNProfileProvider)));
            ComponentFactory.RegisterComponent <IPortalSettingsController, PortalSettingsController>();

            PortalController.ClearInstance();
            UserController.ClearInstance();
            RoleController.ClearInstance();

            var roleController    = RoleController.Instance;
            var roleProviderField = roleController.GetType().GetField("provider", BindingFlags.NonPublic | BindingFlags.Static);

            if (roleProviderField != null)
            {
                roleProviderField.SetValue(roleController, RoleProvider.Instance());
            }

            var membershipType = typeof(System.Web.Security.Membership);
            var initializedDefaultProviderField = membershipType.GetField("s_InitializedDefaultProvider", BindingFlags.NonPublic | BindingFlags.Static);
            var defaultProviderField            = membershipType.GetField("s_Provider", BindingFlags.NonPublic | BindingFlags.Static);

            if (initializedDefaultProviderField != null &&
                defaultProviderField != null &&
                (bool)initializedDefaultProviderField.GetValue(null) == false)
            {
                initializedDefaultProviderField.SetValue(null, true);
                defaultProviderField.SetValue(null, System.Web.Security.Membership.Providers["AspNetSqlMembershipProvider"]);
            }
        }
Exemple #34
0
        protected override void LoadContent()
        {
            base.LoadContent();
            ComponentFactory factory = new ComponentFactory(Content);

            /*
             * graphics.PreferredBackBufferWidth = 1920;  // set this value to the desired width of your window
             * graphics.PreferredBackBufferHeight = 1080;   // set this value to the desired height of your window
             * graphics.ApplyChanges();
             *
             * TextureRegion orangeRegion = new TextureRegion(Content.Load<Texture2D>("Test/orangeSquare"), 0, 0, 32, 32);
             *
             * HitboxLoader hitboxLoader = new HitboxLoader(stage);
             * BoxSpawn boxSpawn = new BoxSpawn(factory.playerTex, stage);
             * PlayerSpawnLocations playerSpawn = new PlayerSpawnLocations(factory.playerTex, stage);
             * GunSpawn gunSpawn = new GunSpawn(factory.gunRegions, stage);
             *
             * Physic.Instance.collisionRules.Add(new MultiKey<int>(1, 2), false);
             *
             * Actor tiledBaseActor = stage.CreateActor(0);
             * TiledBase tiledBase = tiledBaseActor.AddComponent<TiledBase>();
             * tiledBase.Set(Content);
             * tiledBase.OnCollisionHitboxLoaded += hitboxLoader.OnCollisionHitboxLoaded;
             * tiledBase.OnObjectLoaded += boxSpawn.OnObjectLoaded;
             * tiledBase.OnObjectLoaded += playerSpawn.OnObjectLoaded;
             * tiledBase.OnObjectLoaded += gunSpawn.OnObjectLoaded;
             *
             * TiledMapComponent[] components = tiledBase.AddMap(stage, "maps/level1", true, true);
             *
             * playerSpawn.LoadOnePlayer();
             *
             * //float width = components[0].Width * components[0].TileWidth * 0.5f;
             * //float height = components[0].Height * components[0].TileHeight * 0.5f;
             *
             * //components[0].Actor.GetComponent<SharedPositionTransform2>().WorldPosition = new Vector2(-width, -height);
             */
        }
Exemple #35
0
        public async void Encrypt_ShouldReturnCharacter(char input, char expected)
        {
            // Arrange
            var eventAggregator  = new EventAggregator();
            var utilityFactory   = new UtilityFactory();
            var componentFactory = new ComponentFactory(utilityFactory);
            var settings         = new EnigmaSettingsStub(eventAggregator, componentFactory);
            var savedSettings    = new EnigmaSettings.SavedSettings()
            {
                ReflectorType        = ReflectorType.B,
                PlugboardConnections = new Dictionary <char, char>(),
                Slot1 = new EnigmaSettings.SavedSettings.Slot()
                {
                    Position  = 6,
                    RotorType = RotorType.II,
                },
                Slot2 = new EnigmaSettings.SavedSettings.Slot()
                {
                    Position  = 11,
                    RotorType = RotorType.I,
                },
                Slot3 = new EnigmaSettings.SavedSettings.Slot()
                {
                    Position  = 5,
                    RotorType = RotorType.III,
                },
            };

            settings.LoadSettings(savedSettings);
            var enigma = new Enigma(settings, utilityFactory);

            // Act
            var result = await enigma.Encrypt(input);

            // Assert
            Assert.Equal(expected, result);
        }
Exemple #36
0
 static CommonUtils()
 {
     CommandExecutionEvents = (CommandExecutionEventEnum[])System.Enum.GetValues(typeof(CommandExecutionEventEnum));
     CommandExecutionEventEnum[] enumArray = new CommandExecutionEventEnum[6];
     enumArray[1] = CommandExecutionEventEnum.Failed;
     enumArray[2] = CommandExecutionEventEnum.Timeout;
     enumArray[3] = CommandExecutionEventEnum.ShortCircuited;
     enumArray[4] = CommandExecutionEventEnum.Rejected;
     enumArray[5] = CommandExecutionEventEnum.BadRequest;
     CoreCommandExecutionEvents = enumArray;
     CommandExecutionEventEnum[] enumArray2 = new CommandExecutionEventEnum[4];
     enumArray2[1] = CommandExecutionEventEnum.Failed;
     enumArray2[2] = CommandExecutionEventEnum.Timeout;
     enumArray2[3] = CommandExecutionEventEnum.ShortCircuited;
     ValuableCommandExecutionEvents   = enumArray2;
     CoreFailedCommandExecutionEvents = new CommandExecutionEventEnum[] { CommandExecutionEventEnum.Failed, CommandExecutionEventEnum.Timeout, CommandExecutionEventEnum.ShortCircuited, CommandExecutionEventEnum.Rejected, CommandExecutionEventEnum.BadRequest };
     AppId = ConfigurationManager.AppSettings["AppId"];
     if (string.IsNullOrWhiteSpace(AppId))
     {
         AppId = null;
     }
     else
     {
         AppId = AppId.Trim();
     }
     Log = ComponentFactory.CreateLog(typeof(CommonUtils));
     try
     {
         HostIP = (from c in Dns.GetHostAddresses(Dns.GetHostName())
                   where c.AddressFamily == AddressFamily.InterNetwork
                   select c.ToString()).FirstOrDefault <string>();
     }
     catch (Exception exception)
     {
         Log.Log(LogLevelEnum.Fatal, "Failed to get host IP.", exception);
     }
 }
        public static Mock <T> CreateNew <T>(string name) where T : class
        {
            if (ComponentFactory.Container == null)
            {
                ResetContainer();
            }

            //Try and get mock
            var mockComp = ComponentFactory.GetComponent <Mock <T> >();
            var objComp  = ComponentFactory.GetComponent <T>(name);

            if (mockComp == null)
            {
                mockComp = new Mock <T>();
                ComponentFactory.RegisterComponentInstance <Mock <T> >(mockComp);
            }

            if (objComp == null)
            {
                ComponentFactory.RegisterComponentInstance <T>(name, mockComp.Object);
            }

            return(mockComp);
        }
Exemple #38
0
        private static void LoadProviders()
        {
            if (ComponentFactory.GetComponents <UrlRuleProvider>().Count == 0)
            {
                ComponentFactory.InstallComponents(new DotNetNuke.ComponentModel.ProviderInstaller("urlRule", typeof(UrlRuleProvider)));
            }
            // Avoid claiming lock if providers are already loaded
            if (_providers == null)
            {
                lock (_lock)
                {
                    _providers = new List <UrlRuleProvider>();


                    foreach (KeyValuePair <string, UrlRuleProvider> comp in ComponentFactory.GetComponents <UrlRuleProvider>())
                    {
                        //comp.Value.Name = comp.Key;
                        //comp.Value.Description = comp.Value.Description;
                        _providers.Add(comp.Value);
                    }
                    //'ProvidersHelper.InstantiateProviders(section.Providers, _providers, GetType(SiteMapProvider))
                }
            }
        }
Exemple #39
0
        private static void OnAutoWireViewModelChanged(BindableObject bindable, object oldValue, object newValue)
        {
            var view = bindable as Element;

            if (view == null)
            {
                return;
            }

            var viewType         = view.GetType();
            var viewName         = viewType.FullName?.Replace(".Views.", ".ViewModels.");
            var viewAssemblyName = viewType.GetTypeInfo().Assembly.FullName;
            var viewModelName    = string.Format(CultureInfo.InvariantCulture, $"{viewName}Model, {viewAssemblyName}");

            var viewModelType = Type.GetType(viewModelName);

            if (viewModelType == null)
            {
                return;
            }
            var viewModel = ComponentFactory.Resolve(viewModelType);

            view.BindingContext = viewModel;
        }
Exemple #40
0
        private Application()
        {
            AgentController             = ComponentFactory.CreateAgentController();
            this.ParticipantService     = new ParticipantServices();
            this.ParticipantService.Url = SettingManager.Default.ParticipantServiceUrl;
            this.SecurityService        = new SecurityServices();
            this.SecurityService.Url    = SettingManager.Default.SecurityServiceUrl;
            this.StateServer            = new StateServerService();
            this.StateServer.Url        = SettingManager.Default.StateServerUrl;
            this.StateServerReadyCheck(this.StateServer);
            this.MarketDepthManager = new MarketDepthManager();
            int tickDataReturnCount = Convert.ToInt32(ConfigurationManager.AppSettings["TickDataReturnCount"]);

            this.TradingConsoleServer        = new TradingConsoleServer(SettingManager.Default.ConnectionString, tickDataReturnCount);
            this.AsyncResultManager          = new AsyncResultManager(TimeSpan.FromMinutes(30));
            this.AssistantOfCreateChartData2 = new AssistantOfCreateChartData2();
            this.SessionMonitor   = new SessionMonitor(SettingManager.Default.SessionExpiredTimeSpan);
            this._TradeDayChecker = new TradeDayChecker();
            //todo: store/build mobile settings in somewhere
            var mobileSettings = new Dictionary <string, string>();

            mobileSettings.Add("ConnectionString", SettingManager.Default.ConnectionString);
            Mobile.Manager.Initialize(this.StateServer, mobileSettings, this.MobileSendingCallback);
        }
Exemple #41
0
 private void calculateTax(ComponentFactory.Krypton.Toolkit.KryptonCheckBox checkbox)
 {
     lblVat.Tag = (checkbox.Checked) ? checkbox.Tag.ToString() : (0.00m).ToString();
     lblVat.Text = calculateProcentAmount().ToString();
 }
 private void kryptonDropButton1_DropDown(object sender, ComponentFactory.Krypton.Toolkit.ContextPositionMenuArgs e)
 {
     this.ChoseCollect();
 }
Exemple #43
0
 //Functions
 private void ChangeState(ComponentFactory.Krypton.Toolkit.KryptonCheckButton CurrentButton, ComponentFactory.Krypton.Toolkit.KryptonCheckButton NextButton)
 {
     if(MainState!=null)
         PrevMainState = MainState;
     MainState = CurrentButton;
     NextMainState = NextButton;
 }
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            Graphics.PreferredBackBufferWidth = Constants.InternalResolutionWidth;
            Graphics.PreferredBackBufferHeight = Constants.InternalResolutionHeight;

            Graphics.SynchronizeWithVerticalRetrace = false;
            IsFixedTimeStep = false;

            Graphics.ApplyChanges();

            //Components.Add(new FrameRateCounter(this, "Content\\Fonts\\fpsfont", 1f));
            Components.Add(new GameObjectInfoDisplay(this, 0.5f, "Content\\Fonts\\debugfont", new Vector2(0f, 25f)));


            var componentFactory = new ComponentFactory();
            var gameObjectFactory = new GameObjectFactory(this.Content);
            gameObjectFactory.PathToXML = "EntityDefinitions\\entity.xml";

            var inputHandler = new InputHandler(false);
            var playerManager = new PlayerManager();

            var collisionManager = new CollisionManager(new RectangleF(0f, 0f, Constants.InternalResolutionWidth, Constants.InternalResolutionHeight));

            particleManager = new ParticleManager(Content, "ParticleEffects\\", "Textures\\");

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            renderer = new Renderer(Graphics, spriteBatch);
            renderer.SpriteSortMode = SpriteSortMode.FrontToBack;
            renderer.SetInternalResolution(Constants.InternalResolutionWidth, Constants.InternalResolutionHeight);
            renderer.SetScreenResolution(1920, 1080, false);

            particleRenderer = new SpriteBatchRenderer();
            particleRenderer.GraphicsDeviceService = Graphics;

            cameraService =  new CameraManager();

            var camera = new BasicCamera2D(GraphicsDevice, "main");

            cameraService.AddCamera(camera);

            GameServiceManager.AddService(typeof(IGameObjectFactory), gameObjectFactory);
            GameServiceManager.AddService(typeof(IComponentFactory), componentFactory);
            GameServiceManager.AddService(typeof(RenderableFactory), new RenderableFactory(Content));
            GameServiceManager.AddService(typeof(IInputHandler), inputHandler);
            GameServiceManager.AddService(typeof(PlayerManager), playerManager);
            GameServiceManager.AddService(typeof(IGameObjectManager), new GameObjectManager());
            GameServiceManager.AddService(typeof(ICollisionManager), collisionManager);
            GameServiceManager.AddService(typeof(IBehaviorFactory), new BehaviorFactory());
            GameServiceManager.AddService(typeof(IActionFactory), new ActionFactory());
            GameServiceManager.AddService(typeof(IRandomGenerator), new RandomGenerator());
            GameServiceManager.AddService(typeof(IParticleManager), particleManager);
            GameServiceManager.AddService(typeof(IProjectileManager), new ProjectileManager());
            GameServiceManager.AddService(typeof(IActionManager), new ActionManager());
            GameServiceManager.AddService(typeof(ILayerManager), new LayerManager("layers.xml", Content));
            GameServiceManager.AddService(typeof(IRenderer), renderer);
            GameServiceManager.AddService(typeof(ICameraService), cameraService);
            GameServiceManager.AddService(typeof(ILevelLogicManager), new LevelLogicManager());

            //Initialize the GameServices););
            foreach (var service in GameServiceManager.Services)
            {
                service.Initialize();
            }

            base.Initialize();
        }