コード例 #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);
                    //    }
                }
            }
        }
コード例 #2
0
 public void resetModule()
 {
     if (Module != null)
     {
         Module.destroySelf();
     }
     Module = null;
 }
コード例 #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);
            //}
        }
コード例 #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);
                }
            }
        }
コード例 #5
0
        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);
                        }
                    }
                }
            }
        }
コード例 #6
0
        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);
                        }
                    }
                }
            }
        }
コード例 #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);
    }
コード例 #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);
        }
コード例 #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);
			}
		}
コード例 #10
0
        public IDictionary <string, object> GetExpando(iModule module)
        {
            var t = (IDictionary <string, object>)(module as Module).GetExpando();

            return(t);
        }
コード例 #11
0
		public void AssociateSerial(SerialSettings settings, int port, iModule dev)
		{
		}
コード例 #12
0
		public void AssociateIP(string IP, int port, iModule dev)
		{
		}
コード例 #13
0
 /// <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;
 }
コード例 #14
0
 /// <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));
 }
コード例 #15
0
//	public virtual override GameObject getGameObject(){
//		return base.getGameObject ();
//	}
    public virtual void registerModule(iModule module)
    {
        Module = module;
    }