protected override void Init(SystemComponent component, out float maxDistance)
    {
        GunComponent gun = (GunComponent)component;

        maxDistance = gun.distance;
        shotType    = gun.shipClass;
    }
Exemple #2
0
        public void shouldParseJsonFromFile()
        {
            SystemComponent sm = JsonParser <SystemComponent> .parseJson();

            Assert.NotNull(sm);
            Assert.IsType <SystemComponent>(sm);
        }
Exemple #3
0
        public void shouldCreateSystemComponentObject()
        {
            SystemRepository systemRepository = new SystemRepository();
            SystemBuilder    systemBuilder    = new SystemBuilder(systemRepository);
            SystemComponent  sm = systemRepository.Create();

            Assert.NotNull(sm);
            Assert.IsType <SystemComponent>(sm);
        }
Exemple #4
0
        /// <summary>
        /// This extension method intercepts the Component and checks if it implements an ISystem or IUpdateable interface (or both) before adding it to the root entity of the scene.
        /// This is useful to avoid having to search for System and Updateable components on scene initialization or on every frame update.
        /// </summary>
        /// <param name="scene">The scene that the component is being added to</param>
        /// <param name="systemComponent">The system component to add</param>
        /// <returns>
        /// TRUE if the component implements an ISystem or IUpdateable interface and is successfully added to the scene root.
        /// FALSE if the component could not be added to the scene root.
        /// Otherwise throws an Exception if the component could not be added as an ISystem or IUpdateable object.
        /// </returns>

        public static bool AddComponent(this Scene scene, SystemComponent systemComponent)
        {
            if (!scene.AddComponent(systemComponent as ISystem))
            {
                throw new Exception("Could not add System Component!");
            }

            if (!scene.AddComponent(systemComponent as IUpdateable))
            {
                throw new Exception("Could not add Updateable Component!");
            }

            // add the component to the Root Entity
            return(scene.Root.AddComponent(systemComponent));
        }
Exemple #5
0
 /// <summary>
 /// Register a new component into the system list.  If the component has
 /// autoEnable true, then it will try and enable the component as well.
 /// </summary>
 public void Register(SystemComponent component)
 {
     if (component.autoEnable)
     {
         _auto = AHArray.Added(_auto, component);
         if (component.Activate() != OperationResult.Status.OK)
         {
             ++_autoDisabled;
         }
     }
     else
     {
         _manual = AHArray.Added(_manual, component);
     }
 }
Exemple #6
0
    /// <summary>
    /// Try and remove the SystemModifier to the SystemComponent.
    /// </summary>
    /// <returns>
    /// - ModuleResult.Success if the modifier was remove
    /// - ModuleResult.InvalidSystem if the SystemComponent wasn't found.
    /// </returns>
    public ModuleResult Remove()
    {
        // Try and remove the modifier from the component.
        SystemComponent comp = GetComponent(_componentType) as SystemComponent;

        if (comp)
        {
            comp.RemoveModifier(modifier);
            return(ModuleResult.Success);
        }
        else
        {
            Debug.LogError("[ModifierComponent] Failed to enable, SystemComponent[" + component + "] not found.");
            return(ModuleResult.InvalidSystem);
        }
    }
Exemple #7
0
        public void ShouldCreateValidObject()
        {
            const string description = "Description of valid system weon";
            const string systemName  = "ValidSystem";

            var expectedSystem = new
            {
                Name        = systemName,
                Description = description
            };

            var system = new SystemComponent(systemName, description);

            Assert.Equal(expectedSystem.Name, system.Name);
            Assert.Equal(expectedSystem.Description, system.Description);
        }
Exemple #8
0
        public void checkCircularDependencyTest()
        {
            IList <Role> roles = new List <Role> {
                new Role {
                    Id = 1, Name = "System Admin", Parent = 0
                },
                new Role {
                    Id = 2, Name = "Location Manaer", Parent = 2
                }
            };

            sm = new SystemComponent();

            Assert.True(sm.checkCircularDependency(roles, new Role {
                Id = 2, Name = "Location Manaer", Parent = 2
            }));
        }
Exemple #9
0
    /// <summary>
    /// Try and apply the SystemModifier to the SystemComponent.
    /// </summary>
    /// <returns>
    /// - ModuleResult.Success if the modifier was applied
    /// - ModuleResult.InvalidSystem if the SystemComponent wasn't found.
    /// </returns>
    public ModuleResult Apply()
    {
        // Try and get the component we will be modifying and apply the
        // modifier to it.
        SystemComponent comp = GetComponentInParent(_componentType) as SystemComponent;

        if (comp)
        {
            comp.ReplaceModifier(modifier);
            return(ModuleResult.Success);
        }
        else
        {
            Debug.LogError("[ModifierComponent] Failed to enable, SystemComponent[" + component + "] not found.");
            return(ModuleResult.InvalidSystem);
        }
    }
Exemple #10
0
        private void initializeSystem()
        {
            IList <User> user = new List <User> {
                new User {
                    Id = 1, Name = "Adam Admin", Role = 1
                },
                new User {
                    Id = 2, Name = "EmilyEmployee Admin", Role = 2
                }
            };
            IList <Role> roles = new List <Role> {
                new Role {
                    Id = 1, Name = "System Admin", Parent = 0
                },
                new Role {
                    Id = 2, Name = "Location Manaer", Parent = 1
                }
            };

            sm = new SystemComponent(roles, user);
        }
 public void BuildSystem()
 {
     systemComponent = systemRepository.Create();
 }
 protected abstract void Init(SystemComponent component, out float maxDistance);
 protected override void OnSetLink(SystemComponent component)
 {
     Init(component, out maxDistance);
     maxDistance *= maxDistance;
 }
Exemple #14
0
 protected override void Init(SystemComponent component, out float maxDistance)
 {
     maxDistance = ((RocketGunComponent)component).distance;
 }
Exemple #15
0
 protected virtual void OnSetLink(SystemComponent component)
 {
 }
Exemple #16
0
 protected override void OnSetLink(SystemComponent component)
 {
     type = component.shipClass;
 }
Exemple #17
0
        public SystemStatusModel GetSystemStatus()
        {
            var model = new SystemStatusModel();

            MefConfig.Container.SatisfyImportsOnce(model);

            // Database
            var dbStatus = new SystemComponent()
            {
                Name = "Colectica Curation Database"
            };

            model.Components.Add(dbStatus);

            try
            {
                using (var db = ApplicationDbContext.Create())
                {
                    var testUser = db.Users.FirstOrDefault();
                    dbStatus.IsWorking = true;
                }
            }
            catch (Exception ex)
            {
                dbStatus.IsWorking = false;
                dbStatus.Message   = string.Join(". ", ex.FlattenHierarchy().Select(x => x.Message));
            }

            // Curation service
            var serviceStatus = new SystemComponent()
            {
                Name = "Colectica Curation Service"
            };

            model.Components.Add(serviceStatus);

            try
            {
                var curatorService = new ServiceController("Colectica Curation Service");
                serviceStatus.IsWorking = curatorService.Status == ServiceControllerStatus.Running;
                serviceStatus.Message   = curatorService.Status.ToString();
            }
            catch (Exception ex)
            {
                serviceStatus.IsWorking = false;
                serviceStatus.Message   = ex.Message;
            }

#if ISPRO
            // Repository
            var repoStatus = new SystemComponent()
            {
                Name = "Colectica Repository"
            };
            model.Components.Add(repoStatus);

            try
            {
                var connectionInfo = new RepositoryConnectionInfo()
                {
                    Url = "localhost",
                    AuthenticationMethod = RepositoryAuthenticationMethod.Windows,
                    TransportMethod      = RepositoryTransportMethod.NetTcp
                };
                var client   = RepositoryHelper.GetClient();
                var testInfo = client.GetRepositoryInfo();
                repoStatus.IsWorking = true;
            }
            catch (Exception ex)
            {
                repoStatus.IsWorking = false;
                repoStatus.Message   = ex.Message;
            }
#endif

            // Clam Antivirus
            var clamStatus = new SystemComponent()
            {
                Name = "Clam Antivirus"
            };
            model.Components.Add(clamStatus);

            try
            {
                var clamService = new ServiceController("ClamD");
                clamStatus.IsWorking = clamService.Status == ServiceControllerStatus.Running;
                clamStatus.Message   = clamService.Status.ToString();
            }
            catch (Exception ex)
            {
                clamStatus.IsWorking = false;
                clamStatus.Message   = ex.Message;
            }

            // Stata
            //var stataStatus = new SystemComponent() { Name = "Stata" };
            //model.Components.Add(stataStatus);

            // R
            var rStatus = new SystemComponent()
            {
                Name = "R"
            };
            model.Components.Add(rStatus);

            try
            {
                //string rMessage = string.Empty;
                //var rImporter = new RDataImporter();
                //rStatus.IsWorking = rImporter.AreSystemRequirementsSatisfied(out rMessage);
            }
            catch (Exception ex)
            {
                rStatus.IsWorking = false;
                rStatus.Message   = ex.Message;
            }

            return(model);
        }
Exemple #18
0
 protected override void Init(SystemComponent component, out float maxDistance)
 {
     maxDistance = ((FreezeRayComponent)component).distance;
 }