コード例 #1
0
 public ModuleActionInvoker(
     ActionContext actionContext,
     IReadOnlyList <IFilterProvider> filterProviders,
     IModuleFactory moduleFactory,
     ModuleActionDescriptor descriptor,
     IReadOnlyList <IInputFormatter> inputFormatters,
     IReadOnlyList <IOutputFormatter> outputFormatters,
     IReadOnlyList <IModelBinder> modelBinders,
     IReadOnlyList <IModelValidatorProvider> modelValidatorProviders,
     IReadOnlyList <IValueProviderFactory> valueProviderFactories,
     IActionBindingContextAccessor actionBindingContextAccessor,
     ILogger logger,
     DiagnosticSource diagnostic,
     int maxModelValidationErrors)
     : base(
         actionContext,
         filterProviders,
         inputFormatters,
         outputFormatters,
         modelBinders,
         modelValidatorProviders,
         valueProviderFactories,
         actionBindingContextAccessor,
         logger,
         diagnostic,
         maxModelValidationErrors)
 {
     _descriptor    = descriptor;
     _moduleFactory = moduleFactory;
 }
コード例 #2
0
 public ModuleActionInvokerProvider(
     IEnumerable<IFilterProvider> filterProviders,
     IModuleFactory moduleFactory)
 {
     _moduleFactory = moduleFactory;
     _filterProviders = filterProviders.OrderBy(p => p.Order).ToList();
 }
 public ModuleActionInvoker(
     ActionContext actionContext,
     IReadOnlyList<IFilterProvider> filterProviders,
     IModuleFactory moduleFactory,
     ModuleActionDescriptor descriptor,
     IReadOnlyList<IInputFormatter> inputFormatters,
     IReadOnlyList<IOutputFormatter> outputFormatters,
     IReadOnlyList<IModelBinder> modelBinders,
     IReadOnlyList<IModelValidatorProvider> modelValidatorProviders,
     IReadOnlyList<IValueProviderFactory> valueProviderFactories,
     IActionBindingContextAccessor actionBindingContextAccessor,
     ILogger logger,
     DiagnosticSource diagnostic,
     int maxModelValidationErrors)
     : base(
           actionContext,
           filterProviders,
           inputFormatters,
           outputFormatters,
           modelBinders,
           modelValidatorProviders,
           valueProviderFactories,
           actionBindingContextAccessor,
           logger,
           diagnostic,
           maxModelValidationErrors)
 {
     _descriptor = descriptor;
     _moduleFactory = moduleFactory;
 }
コード例 #4
0
 public ModuleActionInvokerProvider(
     IEnumerable <IFilterProvider> filterProviders,
     IModuleFactory moduleFactory)
 {
     _moduleFactory   = moduleFactory;
     _filterProviders = filterProviders.OrderBy(p => p.Order).ToList();
 }
コード例 #5
0
 public ModuleActionInvokerProvider(
     IModuleFactory moduleFactory,
     IEnumerable <IFilterProvider> filterProviders,
     IReadOnlyList <IInputFormatter> inputFormatters,
     IReadOnlyList <IOutputFormatter> outputFormatters,
     IReadOnlyList <IModelBinder> modelBinders,
     IReadOnlyList <IModelValidatorProvider> modelValidatorProviders,
     IReadOnlyList <IValueProviderFactory> valueProviderFactories,
     IActionBindingContextAccessor actionBindingContextAccessor,
     IOptions <MvcOptions> optionsAccessor,
     ILogger logger,
     DiagnosticSource diagnostic,
     IServiceProvider serviceProvider)
 {
     _moduleFactory                = moduleFactory;
     _filterProviders              = filterProviders.OrderBy(p => p.Order).ToList();
     _inputFormatters              = inputFormatters;
     _outputFormatters             = outputFormatters;
     _modelBinders                 = modelBinders;
     _modelValidatorProviders      = modelValidatorProviders;
     _valueProviderFactories       = valueProviderFactories;
     _actionBindingContextAccessor = actionBindingContextAccessor;
     _optionsAccessor              = optionsAccessor;
     _logger          = logger;
     _diagnostic      = diagnostic;
     _serviceProvider = serviceProvider;
 }
 public ModuleActionInvokerProvider(
     IModuleFactory moduleFactory,
     IEnumerable<IFilterProvider> filterProviders,
     IReadOnlyList<IInputFormatter> inputFormatters,
     IReadOnlyList<IOutputFormatter> outputFormatters,
     IReadOnlyList<IModelBinder> modelBinders,
     IReadOnlyList<IModelValidatorProvider> modelValidatorProviders,
     IReadOnlyList<IValueProviderFactory> valueProviderFactories,
     IActionBindingContextAccessor actionBindingContextAccessor,
     IOptions<MvcOptions> optionsAccessor,
     ILogger logger,
     DiagnosticSource diagnostic,
     IServiceProvider serviceProvider)
 {
     _moduleFactory = moduleFactory;
     _filterProviders = filterProviders.OrderBy(p => p.Order).ToList();
     _inputFormatters = inputFormatters;
     _outputFormatters = outputFormatters;
     _modelBinders = modelBinders;
     _modelValidatorProviders = modelValidatorProviders;
     _valueProviderFactories = valueProviderFactories;
     _actionBindingContextAccessor = actionBindingContextAccessor;
     _optionsAccessor = optionsAccessor;
     _logger = logger;
     _diagnostic = diagnostic;
     _serviceProvider = serviceProvider;
 }
コード例 #7
0
        public static void RegisterAllModules(this IModuleFactory moduleFactory, Assembly assembly)
        {
            var foundTypes = assembly
                             .GetTypes()
                             .Where(t => t.GetCustomAttribute <ModuleAttribute>() != null)
                             .ToList();

            foreach (var type in foundTypes)
            {
                ModuleAttribute attribute   = type.GetCustomAttribute <ModuleAttribute>();
                var             description = FillDescriptionFromAttribute(type, attribute);
                moduleFactory.Register(description.ModuleType, description, (runtime, s) => (IModule)s.GetInstance(type), type);
            }

            var typeAliases = assembly
                              .GetTypes()
                              .Where(t => t.GetCustomAttribute <ModuleTypeAliasAttribute>() != null)
                              .ToList();

            foreach (var type in typeAliases)
            {
                ModuleAttribute          moduleAttribute = type.GetCustomAttribute <ModuleAttribute>();
                ModuleTypeAliasAttribute aliasAttribute  = type.GetCustomAttribute <ModuleTypeAliasAttribute>();
                if (moduleAttribute == null || aliasAttribute == null)
                {
                    continue;
                }

                moduleFactory.RegisterAlias(aliasAttribute.AliasType, moduleAttribute.ModuleType, aliasAttribute.IncludeInCatalog);
            }
        }
コード例 #8
0
ファイル: JSONParser.cs プロジェクト: pedroyebenes/sauron2
        public List <Module> GetModules(IModuleFactory moduleFactory)
        {
            List <Module> ml = new List <Module>();

            if (JSONFile.TryGetValue("topology_file", out JsonValue topologyFile))
            {
                JSONParser jSONParser = new JSONParser(JSONParser.ReadJSONFile((string)topologyFile));
                ml.AddRange(jSONParser.GetModules(moduleFactory));
            }
            if (JSONFile.TryGetValue(ModuleKey, out JsonValue jsonModules))
            {
                foreach (JsonValue jm in jsonModules)
                {
                    JsonObject jo     = (JsonObject)JsonValue.Parse(jm.ToString());
                    int        number = jo.TryGetValue(ModuleNumber, out JsonValue value) ? (int)value : 1;
                    for (int i = 0; i < number; i++)
                    {
                        ml.Add(CreateModule(jm.ToString(), moduleFactory));
                    }
                }
            }

            if (ml.Count == 0)
            {
                throw new Exceptions.JSONnotValidException("JSON file does not contain any modules");
            }

            return(ml);
        }
コード例 #9
0
        /// <summary>
        /// Given a scene find the module factory in that scene. Useful for finding modules when there a are multiples of the same type, but only one per scene.
        /// </summary>
        /// <param name="scene">The scene we expect to find the module in.</param>
        /// <param name="sceneFactory">The found factory, if found. else null.</param>
        /// <returns>True if a factory was found in the scene. Else false and sceneFactory will be null.</returns>
        public static bool TryFindFactoryInScene(Scene scene, out IModuleFactory sceneFactory)
        {
            //if asset bundle scene check against scene path
            if (scene.buildIndex == -1)
            {
                foreach (DefaultModuleFactory factory in _all)
                {
                    if (factory._scenePath == scene.path)
                    {
                        sceneFactory = factory;
                        return(true);
                    }
                }
            }
            else             //if scene included in build check against scene id
            {
                foreach (DefaultModuleFactory factory in _all)
                {
                    if (factory._sceneIndex == scene.buildIndex)
                    {
                        sceneFactory = factory;
                        return(true);
                    }
                }
            }

            sceneFactory = null;
            return(false);
        }
コード例 #10
0
 public static void RegisterAll(IModuleFactory factory)
 {
     foreach (var op in operations)
     {
         op.Register(factory);
     }
 }
コード例 #11
0
        public static void ClassInit(TestContext context)
        {
            if (_MODULE_FACTORY == null)
                _MODULE_FACTORY = ModuleFactory.GetFactory();

            if (_DECK_BUILDER == null)
                _DECK_BUILDER = Deck.GetBuilder();
        }
コード例 #12
0
 public ReactorManager()
 {
     moduleFactory  = new ModuleFactory();
     reactorFactory = new ReactorFactory();
     this.currentId = Constants.StartingId;
     this.reactors  = new Dictionary <int, IReactor>();
     this.modules   = new Dictionary <int, IModule>();
 }
コード例 #13
0
 public void RegisterModuleFactory(IModuleFactory factory)
 {
     if (_RegisteredFactories.ContainsKey(factory.ModuleTypeName))
     {
         throw new Exception($"Factory for control: {factory.ModuleTypeName} is already registered!");
     }
     _RegisteredFactories.Add(factory.ModuleTypeName, factory);
 }
コード例 #14
0
 public static void AddModule( IModuleFactory factory )
 {
     foreach( ModulePreset preset in factory.Presets ) {
         Presets.Add( preset.Name, preset );
     }
     FactoriesByType.Add( factory.ModuleType, factory );
     FactoriesById.Add( factory.ID, factory );
 }
コード例 #15
0
        public ModuleSourceTestBase()
        {
            root = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            Directory.CreateDirectory(root);

            application = StubApplication();
            moduleFactory = StubModuleFactory();
        }
コード例 #16
0
 public ReactorManager(IReactorFactory reactorFactory, IModuleFactory moduleFactory)
 {
     this.identifiableObjects = new Dictionary <int, IIdentifiable>();
     this.reactors            = new Dictionary <int, IReactor>();
     this.modules             = new Dictionary <int, IModule>();
     currentId           = Constants.StartingId;
     this.reactorFactory = reactorFactory;
     this.moduleFactory  = moduleFactory;
 }
コード例 #17
0
ファイル: JSONParser.cs プロジェクト: pedroyebenes/sauron2
        Module CreateModule(string jsonString, IModuleFactory moduleFactory)
        {
            JsonObject jo = (JsonObject)JsonValue.Parse(jsonString);

            string type  = GetValueFromObjectOrDie(jo, ModuleType);
            int    gates = GetValueFromObjectOrDie(jo, ModuleGates);

            return(moduleFactory.CreateModule(type, jsonString));
        }
コード例 #18
0
 public static void AddModule(IModuleFactory factory)
 {
     foreach (ModulePreset preset in factory.Presets)
     {
         Presets.Add(preset.Name, preset);
     }
     FactoriesByType.Add(factory.ModuleType, factory);
     FactoriesById.Add(factory.ID, factory);
 }
コード例 #19
0
        public ModuleActionInvoker(
            IReadOnlyList <IFilterProvider> filterProviders,
            IModuleFactory moduleFactory,
            ActionContext actionContext)
        {
            _filterProviders = filterProviders;
            _moduleFactory   = moduleFactory;

            Context = new ModuleContext(actionContext);
        }
コード例 #20
0
        public void TestInitialize()
        {
            // Reset the static singleton inside the module factory:
            Type      type = typeof(ModuleFactory);
            FieldInfo info = type.GetField("moduleFactory", BindingFlags.NonPublic | BindingFlags.Static);

            info.SetValue(null, null);

            this.factoryUnderTest = ModuleFactory.ModuleFactorySingleton;
        }
コード例 #21
0
        public VkApi(IModuleFactory moduleFactory)
        {
            ModuleFactory = moduleFactory;

            LazyAccount  = new Lazy <IAccount>(() => ModuleFactory.Get <Account>(Environment));
            LazyAds      = new Lazy <IAds>(() => ModuleFactory.Get <Ads>(Environment));
            LazyApps     = new Lazy <IApps>(() => ModuleFactory.Get <Apps>(Environment));
            LazyBoard    = new Lazy <IBoard>(() => ModuleFactory.Get <Board>(Environment));
            LazyDatabase = new Lazy <IDatabase>(() => ModuleFactory.Get <Database>(Environment));
        }
コード例 #22
0
        public SimulationEnvironment(string configFilename, IModuleFactory moduleFactory, IUserInterface userInterface)
        {
            EventQueue = new EventQueue();
            DictModules = new Dictionary<string, List<Module>>();
            UI = userInterface;
            ModuleFactory = moduleFactory;

            Time = 0;
            ConfigurationFileName = configFilename;
        }
コード例 #23
0
ファイル: Device.cs プロジェクト: DarkGraf/CapdEmulator
        public Device(IModuleFactory moduleFactory)
        {
            this.moduleFactory = moduleFactory;

              Handle = new Random().Next();
              Version = 3;
              Description = "Эмулятор CAPD v1.0.0.0";
              Modules = new List<IModule>();
              active = false;
              quantumsQueue = new ConcurrentQueue<IQuantumDevice>();

              moduleFactory.TryCreate(ModuleType.Null, quantumsQueue, out nullModule);
        }
コード例 #24
0
ファイル: XrcService.cs プロジェクト: davideicardi/xrc
        public XrcService(IPageProviderService pageProvider,
					IViewFactory viewFactory,
					IModuleFactory moduleFactory,
					IPageScriptService scriptService,
					Configuration.IHostingConfig hostingConfig,
					Configuration.IEnvironmentConfig environmentConfig)
        {
            _hostingConfig = hostingConfig;
            _environmentConfig = environmentConfig;
            _pageProvider = pageProvider;
            _viewFactory = viewFactory;
            _moduleFactory = moduleFactory;
            _scriptService = scriptService;
        }
コード例 #25
0
 public void RegisterModule <Tinterface>(IModuleFactory <Tinterface> moduleFactory) where Tinterface : ICodeFirstEntityModule
 {
     FreezeCheck(false);
     if (_modules.ContainsKey(typeof(Tinterface)))
     {
         throw new CodeFirstResolverException(typeof(Tinterface).Name + " already has a registered factory");
     }
     if (moduleFactory.GetPrerequisites().Except(_order).Any())
     {
         throw new CodeFirstResolverException(typeof(Tinterface).Name + " has dependencies which are not satisfied.");
     }
     _modules.TryAdd(typeof(Tinterface), moduleFactory);
     _order.Add(typeof(Tinterface));
     _pristine = false;
 }
コード例 #26
0
        public static IModule ReadModule(Stream stream)
        {
            BinaryReader reader         = new BinaryReader(stream);
            string       moduleID       = reader.ReadString();
            int          settingsLength = reader.ReadInt32();

            if (FactoriesById.ContainsKey(moduleID))
            {
                IModuleFactory factory = GetFactoryByID(moduleID);
                IModule        module  = factory.GetInstance();
                //module.ReadSettings( reader, settingsLength );
                return(module);
            }
            else
            {
                stream.Seek(settingsLength, SeekOrigin.Current);
                return(null);
            }
        }
コード例 #27
0
 public ModuleActionInvokerProvider(
     IModuleFactory moduleFactory,
     IEnumerable<IFilterProvider> filterProviders,
     IInputFormattersProvider inputFormattersProvider,
     IModelBinderProvider modelBinderProvider,
     IModelValidatorProviderProvider modelValidatorProviderProvider,
     IValueProviderFactoryProvider valueProviderFactoryProvider,
     IScopedInstance<ActionBindingContext> actionBindingContextAccessor,
     IServiceProvider serviceProvider)
 {
     _moduleFactory = moduleFactory;
     _filterProviders = filterProviders.OrderBy(p => p.Order).ToList();
     _inputFormattersProvider = inputFormattersProvider;
     _modelBinderProvider = modelBinderProvider;
     _modelValidatorProviderProvider = modelValidatorProviderProvider;
     _valueProviderFactoryProvider = valueProviderFactoryProvider;
     _actionBindingContextAccessor = actionBindingContextAccessor;
     _serviceProvider = serviceProvider;
 }
コード例 #28
0
        public static IModule ReadModule(NBTag tag)
        {
            string moduleID = tag["ID"].GetString();

            if (!FactoriesById.ContainsKey(moduleID))
            {
                return(null);
            }
            IModuleFactory factory = GetFactoryByID(moduleID);
            IModule        module  = factory.GetInstance();

            if (tag.Contains("Properties"))
            {
            }

            module.ReadSettings(tag["Settings"]);

            return(module);
        }
コード例 #29
0
        public static NBTag WriteModule(string tagName, IModule module)
        {
            NBTCompound    root    = new NBTCompound(tagName);
            IModuleFactory factory = GetFactoryByType(module.GetType());

            root.Append("ID", factory.ID);

            bool auto =
                !factory.ModuleType.GetCustomAttributes(typeof(DisableAutoSerializationAttribute), true).Any();

            if (auto)
            {
                root.Append(WriteModuleProperties(module));
            }
            NBTag customSettings = new NBTCompound("Settings");

            module.WriteSettings(customSettings);
            root.Append(customSettings);
            return(root);
        }
コード例 #30
0
        public static ModuleUserControl GetControlFromModuleData(Domain.Modules module)
        {
            var moduleType = (ModuleType)module.ModuleType;

            IModuleFactory <ModuleUserControl> factory = null;

            switch (moduleType)
            {
            case ModuleType.Text:
                factory = new TextFactory();
                break;

            case ModuleType.Heading:
                factory = new HeadingFactory();
                break;

            case ModuleType.Image:
                factory = new ImageFactory();
                break;

            case ModuleType.Login:
                factory = new LoginFactory();
                break;

            case ModuleType.Register:
                factory = new RegisterFactory();
                break;

            case ModuleType.Logout:
                factory = new DefaultModuleFactory("~/Module/Login/Logout.ascx");
                break;

            default:
                throw new Exception("Unkown module type!");
            }

            return(factory?.GetControl(module));
        }
コード例 #31
0
 public static void ClassInit(TestContext context)
 {
     if (_MODULE_FACTORY == null)
         _MODULE_FACTORY = ModuleFactory
                             .GetFactory();
 }
コード例 #32
0
ファイル: Game.cs プロジェクト: thebuchanan3/Blackjack
 public GameBuilder(IModuleFactory moduleFactory, ILogicBuilder logicBuilder, IDealerBuilder dealerBuilder, IDeckBuilder deckBuilder, ITableBuilder tableBuilder, IPlayerBuilder playerBuilder)
 {
     _moduleFactory = moduleFactory;
     _logicBuilder = logicBuilder;
     _dealerBuilder = dealerBuilder;
     _deckBuilder = deckBuilder;
     _tableBuilder = tableBuilder;
     _playerBuilder = playerBuilder;
 }
コード例 #33
0
 public ModuleContainer(IModuleCache cache, IModuleFactory factory)
 {
     moduleCache   = cache;
     moduleFactory = factory;
 }
コード例 #34
0
 public static void ClassCleanup()
 {
     _MODULE_FACTORY = null;
 }
コード例 #35
0
ファイル: XsltView.cs プロジェクト: davideicardi/xrc
 public XsltView(IModuleFactory moduleFactory, IModuleCatalogService moduleCatalog, IResourceProviderService resourceProvider)
 {
     _moduleFactory = moduleFactory;
     _moduleCatalog = moduleCatalog;
     _resourceProvider = resourceProvider;
 }
コード例 #36
0
ファイル: Program.cs プロジェクト: brainlara/wf2owfn
        private static void RunProgram()
        {
            // Scanner
            Scanner scan = null;

            try
            {
                scan = new Scanner(inputFile);
                scan.Scan();
            }
            catch (IOException)
            {
                Console.WriteLine("The specified input file {0} was not found.", inputFile);
                return;
            }
            catch (XmlException e)
            {
                Console.WriteLine("The specified input file is not well-formed Xaml.");
                Console.WriteLine();

                if (debugMode)
                {
                    Console.WriteLine("Debug: {0}", e.Message);
                    Console.WriteLine();
                }
                return;
            }

            // Parser
            IActivity ast = null;

            try
            {
                Parser pars = new Parser(scan.Token());
                // ModuleFactory
                IModuleFactory modules = ModuleFactory.Instance;
                pars.ModuleFactory = modules;
                ast = pars.Parse();
            }
            catch (DirectoryNotFoundException e)
            {
                Console.WriteLine("Error: {0}", e.Message);
                return;
            }
            catch (ParseException e)
            {
                Console.WriteLine("Error while parsing the Xaml:");
                Console.WriteLine(e.Message);
                if (debugMode)
                {
                    Console.WriteLine("Debug: activity '{0}', queue element near or at '{1}', ", e.Activity, e.ElementNumber);
                    Console.WriteLine();
                }
                return;
            }

            // Generation
            try
            {
                Generation gen = new Generation(ast);
                gen.Compile();

                // Format
                string format = formatFile.ToString();

                if (Path.GetFileNameWithoutExtension(outputFile).Equals(String.Empty))
                {
                    gen.WriteOutput(Path.ChangeExtension(inputFile, format), format);
                    if (File.Exists(Path.ChangeExtension(inputFile, format)))
                    {
                        Console.WriteLine("Output file '{0}' sucessfully written", Path.GetFileNameWithoutExtension(inputFile) + "." + format);
                    }
                }
                else
                {
                    gen.WriteOutput(Path.ChangeExtension(outputFile, format), format);
                    if (File.Exists(Path.ChangeExtension(outputFile, format)))
                    {
                        Console.WriteLine("Output file '{0}' sucessfully written", Path.GetFileNameWithoutExtension(outputFile) + "." + format);
                    }
                }
            }
            catch (SecurityException e)
            {
                Console.WriteLine(e.Message);
            }
            catch (Win32Exception e)
            {
                Console.WriteLine(e.Message);
            }
            catch (IOException e)
            {
                Console.WriteLine(e.Message);
            }
        }
コード例 #37
0
ファイル: Device.cs プロジェクト: DarkGraf/CapdEmulator
        public Device(IDeviceApi deviceApi, IModuleFactory moduleFactory, int handle, byte version, string description)
        {
            this.deviceApi = deviceApi;
              this.moduleFactory = moduleFactory;

              Handle = handle;
              Version = version;
              Description = description;

              Active = false;

              Modules = new ObservableCollection<IModule>();
              modulesDictionary = new Dictionary<byte, IModule>();
        }
コード例 #38
0
 public ModulePreset(string name, ModuleInstanceCallback _callback, IModuleFactory factory)
 {
     Name     = name;
     callback = _callback;
     Factory  = factory;
 }
コード例 #39
0
ファイル: Game.cs プロジェクト: thebuchanan3/Blackjack
 public IGameBuilder ModuleFactoryIs(IModuleFactory factory)
 {
     _moduleFactory = factory;
     return this;
 }
コード例 #40
0
ファイル: DefaultIrcClient.cs プロジェクト: pjmagee/Nircbot
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultIrcClient"/> class.
 /// </summary>
 /// <param name="userService">
 /// The user service.
 /// </param>
 /// <param name="moduleFactory">
 /// The module factory.
 /// </param>
 public DefaultIrcClient(IUserService userService, IModuleFactory moduleFactory)
     : base(moduleFactory)
 {
     this.userService = userService;
     this.ircClient = new IrcClient();
     this.ctcpClient = new CtcpClient(this.ircClient);
 }
コード例 #41
0
        public static NBTag WriteModuleProperties(IModule module)
        {
            IModuleFactory factory = GetFactoryByType(module.GetType());
            NBTag          root    = new NBTCompound("Properties");

            foreach (PropertyInfo p in factory.ModuleType.GetProperties())
            {
                object val = p.GetValue(module, null);
                if (p.PropertyType == typeof(byte))
                {
                    root.Append(p.Name, (byte)val);
                }
                else if (p.PropertyType == typeof(short))
                {
                    root.Append(p.Name, (short)val);
                }
                else if (p.PropertyType == typeof(int))
                {
                    root.Append(p.Name, (int)val);
                }
                else if (p.PropertyType == typeof(long))
                {
                    root.Append(p.Name, (long)val);
                }
                else if (p.PropertyType == typeof(float))
                {
                    root.Append(p.Name, (float)val);
                }
                else if (p.PropertyType == typeof(double))
                {
                    root.Append(p.Name, (double)val);
                }
                else if (p.PropertyType == typeof(byte[]))
                {
                    root.Append(p.Name, (byte[])val);
                }
                else if (p.PropertyType == typeof(string))
                {
                    root.Append(p.Name, (string)val);
                }
                else if (p.PropertyType == typeof(bool))
                {
                    root.Append(p.Name, (bool)val);
                }
                else if (p.PropertyType == typeof(Color))
                {
                    root.Append(p.Name, (Color)val);
                }
                else if (p.PropertyType == typeof(Point))
                {
                    root.Append(p.Name, (Point)val);
                }
                else if (p.PropertyType == typeof(PointF))
                {
                    root.Append(p.Name, (PointF)val);
                }
                else
                {
                    throw new NotSupportedException("Unknown property type.");
                }
            }
            return(root);
        }
コード例 #42
0
ファイル: IModule.cs プロジェクト: fragmer/SuperImageEvolver
 public ModulePreset( string name, ModuleInstanceCallback _callback, IModuleFactory factory )
 {
     Name = name;
     callback = _callback;
     Factory = factory;
 }
コード例 #43
0
        public static void ReadModuleProperties(IModule module, NBTag tag)
        {
            IModuleFactory factory = GetFactoryByType(module.GetType());

            foreach (PropertyInfo p in factory.ModuleType.GetProperties())
            {
                if (!tag.Contains(p.Name))
                {
                    continue;
                }
                if (p.PropertyType == typeof(byte))
                {
                    p.SetValue(module, tag.GetByte(), null);
                }
                else if (p.PropertyType == typeof(short))
                {
                    p.SetValue(module, tag.GetShort(), null);
                }
                else if (p.PropertyType == typeof(int))
                {
                    p.SetValue(module, tag.GetInt(), null);
                }
                else if (p.PropertyType == typeof(long))
                {
                    p.SetValue(module, tag.GetLong(), null);
                }
                else if (p.PropertyType == typeof(float))
                {
                    p.SetValue(module, tag.GetFloat(), null);
                }
                else if (p.PropertyType == typeof(double))
                {
                    p.SetValue(module, tag.GetDouble(), null);
                }
                else if (p.PropertyType == typeof(byte[]))
                {
                    p.SetValue(module, tag.GetBytes(), null);
                }
                else if (p.PropertyType == typeof(string))
                {
                    p.SetValue(module, tag.GetString(), null);
                }
                else if (p.PropertyType == typeof(bool))
                {
                    p.SetValue(module, tag.GetBool(), null);
                }
                else if (p.PropertyType == typeof(Color))
                {
                    p.SetValue(module, tag.GetColor(), null);
                }
                else if (p.PropertyType == typeof(Point))
                {
                    p.SetValue(module, tag.GetBool(), null);
                }
                else if (p.PropertyType == typeof(PointF))
                {
                    p.SetValue(module, tag.GetPointF(), null);
                }
                else
                {
                    throw new NotSupportedException("Unknown property type.");
                }
            }
        }
コード例 #44
0
 /// <summary>
 /// Creates a new instance of <see cref="ModuleConfigurer" />
 /// </summary>
 /// <param name="options">The current command app options.</param>
 /// <param name="moduleCache">The module cache to save the added modules.</param>
 /// <param name="moduleFactory">The factory to create modules.</param>
 public ModuleConfigurer(IOptions <MariCommandsOptions> options, IModuleCache moduleCache, IModuleFactory moduleFactory)
 {
     Options        = options.Value;
     _moduleCache   = moduleCache;
     _moduleFactory = moduleFactory;
 }
コード例 #45
0
 public static void ClassCleanup()
 {
     _MODULE_FACTORY = null;
     _DECK_BUILDER = null;
 }
コード例 #46
0
 public DevicesManager(IDeviceSearchApi api, IDeviceApi deviceApi, IModuleFactory moduleFactory)
 {
     this.api = api;
       this.deviceApi = deviceApi;
       this.moduleFactory = moduleFactory;
 }
コード例 #47
0
 public abstract void Register(IModuleFactory factory);
コード例 #48
0
 public override void Register(IModuleFactory factory)
 {
     factory.Register(moduleType, new ModuleDescription {
         ModuleType = moduleType, HelpText = description
     }, (runtime, s) => (IModule) new BinaryOperation(runtime, moduleType, operation, resultPinId, operand1PinId, operand2PinId), null);
 }
コード例 #49
0
 public TypedMessageHandlerFacade(IHandlerTypeResolver resolver, IModuleFactory moduleFactory)
 {
     _resolver      = resolver;
     _moduleFactory = moduleFactory;
 }
コード例 #50
0
ファイル: FakeIrcClient.cs プロジェクト: pjmagee/Nircbot
 /// <summary>
 /// Initializes a new instance of the <see cref="FakeIrcClient"/> class.
 /// </summary>
 /// <param name="moduleFactory">
 /// The module factory.
 /// </param>
 public FakeIrcClient(IModuleFactory moduleFactory)
     : base(moduleFactory)
 {
     Console.WriteLine("{0} : {1}", this.GetType().Name, this.GetHashCode());
 }
コード例 #51
0
ファイル: AbstractIrcClient.cs プロジェクト: pjmagee/Nircbot
 /// <summary>
 /// Initializes a new instance of the <see cref="AbstractIrcClient"/> class.
 /// </summary>
 /// <param name="moduleFactory">
 /// The module factory.
 /// </param>
 protected AbstractIrcClient(IModuleFactory moduleFactory)
 {
     this.modules = moduleFactory.Create(this);
 }