Esempio n. 1
0
        public static void CreateProperty(string ModuleName, string PropertyName, string PropertyType, object PropertyValue)
        {
            if (ModuleRepository != null)
            {
                module = ModuleRepository.GetModuleByName(ModuleName);

                if (module != null)
                {
                    if (!ModuleRepository.ContainsProprty(ModuleName, PropertyName))
                    {
                        if (PropertyType == "string")
                        {
                            var expando = (module as Module).GetExpando();

                            if (expando != null)
                            {
                                dynamicHelper.AddProperty(expando, PropertyName, PropertyValue);
                            }
                        }
                    }
                    //    Property = new ModuleProperty() { PropertyName = PropertyName, PropertyType = PropertyType, ProprtyValue = PropertyValue };

                    //    if (!module.Properties.ContainsKey(PropertyName))
                    //    {
                    //        module.Properties.Add(PropertyName, Property);
                    //    }
                }
            }
        }
Esempio n. 2
0
 public void resetModule()
 {
     if (Module != null)
     {
         Module.destroySelf();
     }
     Module = null;
 }
Esempio n. 3
0
        public static void CreateProperty(iModule Module, string PropertyName, string PropertyType)
        {
            //Property = new ModuleProperty() { PropertyName = PropertyName, PropertyType = PropertyType, ProprtyValue = null };

            //if (!module.Properties.ContainsKey(PropertyName))
            //{
            //    module.Properties.Add(PropertyName, Property);
            //}
        }
Esempio n. 4
0
        public static void CreateModule(string ModuleName)
        {
            if (ModuleRepository != null)
            {
                Module = new Module()
                {
                    ModuleName = ModuleName
                };

                if (!ModuleRepository.Modules.ContainsKey(ModuleName))
                {
                    ModuleRepository.Modules.Add(ModuleName, Module);
                }
            }
        }
        public static void CreateMethod(iModule module, Func <int> method, string methodname, string type)
        {
            if (module != null)
            {
                if (ModuleRepository != null)
                {
                    if (!ModuleRepository.ContainsMethod(module, methodname, type))
                    {
                        var t = (IDictionary <string, object>)(module as Module).GetExpando();

                        if (t != null)
                        {
                            dynamicHelper.AddMethod(t, method, methodname);
                        }
                    }
                }
            }
        }
        public static void CreateAction(iModule module, Action <string> Action, string methodname)
        {
            if (module != null)
            {
                if (ModuleRepository != null)
                {
                    if (!ModuleRepository.ContainsAction(module.ModuleName, methodname))
                    {
                        var t = (IDictionary <string, object>)(module as Module).GetExpando();

                        if (t != null)
                        {
                            dynamicHelper.AddAction(t, Action, methodname);
                        }
                    }
                }
            }
        }
Esempio n. 7
0
    private iModule createMod()
    {
        iModule newmod = null;

        switch (modType)
        {
        case ModulationType.ModTiller:
            newmod = (Instantiate(TillerPrefab, transform.position.snap(), Quaternion.identity) as Transform).GetComponent <iModule>();
            break;

        case ModulationType.ModPlanter:
            newmod = (Instantiate(PlanterPrefab, transform.position.snap(), Quaternion.identity) as Transform).GetComponent <iModule>();
            break;

        default:
            newmod = null;
            break;
        }
        return(newmod);
    }
Esempio n. 8
0
        public bool ContainsMethod(iModule module, string methodname, string type)
        {
            if (Modules != null)
            {
                var Module = GetModuleByName(module.ModuleName);


                if (Module != null)
                {
                    var t = (IDictionary <string, object>)(Module as Module).GetExpando();

                    if (t != null)
                    {
                        var contians = dynamicHelper.ContainsMethod(t, methodname, type);

                        return(contians);
                    }
                }
            }
            return(false);
        }
Esempio n. 9
0
		protected void loadModule(ref String module, List<String> requiredFiles, SettingsProvider.ServerSettings SS, out iModule instance, out Type type)
		{
			type = null;
			instance = null;
			
		
			//
			// We have to locate the device type, download from server if not avaliable
			//
			if (!checkFile(ref module, SS, ".dll"))
				throw new FileNotFoundException("Module could not be loaded", module);


			//
			// We've already loaded this device type however this instance has not been created
			//
			int index;
			index = moduleList.IndexOf(module);
			if (index != -1)
			{
				type = typeList.ElementAt(index);
				instance = (iModule)Activator.CreateInstance(type);
			}
			
			//
			// Device type not loaded
			//
			else
			{
				String temp = Path.Combine(Path.GetDirectoryName(baseFolder), module);	//Full path here (not relative as in settings files)
				Assembly assembly = Assembly.LoadFrom(temp);

				foreach (Type mtype in assembly.GetTypes())
				{
					if (!mtype.IsClass || mtype.IsNotPublic)
						continue;
					
					Type[] interfaces = mtype.GetInterfaces();
					if (((IList<Type>)interfaces).Contains(typeof(iModule)))
					{
						instance = (iModule)Activator.CreateInstance(mtype);
						type = mtype;
						typeList.Add(mtype);
						moduleList.Add(module);
						break;
					}
				}
			}

			if (instance != null)
			{
				//
				// Check if there are any related files, if they exist and if not download them from the server
				//
				for (int j = 0; j < requiredFiles.Count; j++)
				{
					String file = requiredFiles.ElementAt(j);
					if (checkFile(ref file, SS))
						requiredFiles[j] = file;
					else
					{
						Program.LogError(new FileNotFoundException("Required file not found", requiredFiles.ElementAt(j)));
						requiredFiles.RemoveAt(j);
						j--;
					}
				}

				//
				// Initialise module
				//
				instance.relatedFiles(requiredFiles);
			}
		}
Esempio n. 10
0
        public IDictionary <string, object> GetExpando(iModule module)
        {
            var t = (IDictionary <string, object>)(module as Module).GetExpando();

            return(t);
        }
Esempio n. 11
0
		public void AssociateSerial(SerialSettings settings, int port, iModule dev)
		{
		}
Esempio n. 12
0
		public void AssociateIP(string IP, int port, iModule dev)
		{
		}
 /// <summary>
 /// Initializes a new instance of the <see cref="LS_NETSIM.LS_CommandRegistry.PacketHandler"/> struct.
 /// </summary>
 /// <param name='commandID'>
 /// Id assigned to the command
 /// </param>
 /// <param name='serialize'>
 /// Serializer method
 /// </param>
 /// <param name='deserialize'>
 /// Deserializer method
 /// </param>
 public ModuleHandler(iModule module, short moduleID, System.Func <Networking.PacketHandling.Packet, bool> processCommand)
 {
     Module         = module;
     ModuleID       = moduleID;
     ProcessCommand = processCommand;
 }
 /// <summary>
 /// Registers the command.
 /// </summary>
 /// <param name='name'>
 /// Name of the command, user friendly way to determine what it is
 /// </param>
 /// <param name='priority'>
 /// Priority of the command, lower number is processed first
 /// </param>
 /// <param name='serializer'>
 /// Serializer for the command
 /// </param>
 /// <param name='deserializer'>
 /// Deserializer for the command
 /// </param>
 public void RegisterModule(iModule module)
 {
     _moduleHandlers.Add(module.ModuleName, new ModuleHandler(module, (short)_moduleHandlers.Count, module.ProcessCommand));
 }
Esempio n. 15
0
//	public virtual override GameObject getGameObject(){
//		return base.getGameObject ();
//	}
    public virtual void registerModule(iModule module)
    {
        Module = module;
    }