public DefaultModuleManager(IIocManager iocManager, IModuleFinder moduleFinder, IConfigurationManager configurationManager)
 {
     _modules = new ModuleCollection();
     _iocManager = iocManager;
     _moduleFinder = moduleFinder;
     _configurationManager = configurationManager;
 }
 public ServiceBusConfiguration()
 {
     WorkerAvailabilityManager = new WorkerAvailabilityManager();
     Modules = new ModuleCollection();
     TransactionScope = new TransactionScopeConfiguration();
     QueueManager = Core.QueueManager.Default();
 }
Exemple #3
0
 public TCPServer()
 {
     _ThreadPool   = UThreadPool.DefaultPool;
     Clients       = new NetworkConnectionList();
     Modules       = new ModuleCollection();
     DefaultModule = null;
 }
Exemple #4
0
        public async Task Initilize(int parallelTasks)
        {
            _collection = new ModuleCollection();

            ModelsRegistration.RegisterModules(_collection);
            PostModelsRegistration.RegisterModules(_collection);
            _collection.RegisterModule <EsentInstanceProvider, IEsentInstanceProvider>(new EsentInstanceProvider(true));
            _collection.RegisterModule <PostModelStore, IBoardPostStore>(new PostModelStore("makaba", parallelTasks));
            _collection.RegisterModule <MakabaBoardReferenceDtoParsers, INetworkDtoParsers>();
            _collection.RegisterModule <MakabaBoardReferenceDtoParsers, INetworkDtoParsers>();
            _collection.RegisterModule <YoutubeIdService, IYoutubeIdService>();
            _collection.RegisterModule <MakabaLinkParser, IEngineLinkParser>();
            _collection.RegisterModule <AgilityHtmlDocumentFactory, IHtmlDocumentFactory>();
            _collection.RegisterModule <MakabaHtmlParser, IHtmlParser>();
            _collection.RegisterModule <MakabaPostDtoParsers, INetworkDtoParsers>();
            MakabaModelsRegistration.RegisterModules(_collection);

            TableVersionStatusForTests.ClearInstance();
            await _collection.Seal();

            _provider = _collection.GetModuleProvider();
            var module = _provider.QueryModule(typeof(IBoardPostStore), "makaba") ?? throw new ModuleNotFoundException();

            _store = module.QueryView <IBoardPostStore>() ?? throw new ModuleNotFoundException();
        }
Exemple #5
0
 public ModuleManager(IocManager iocManager, ModuleFinder moduleFinder)
 {
    _modules = new ModuleCollection();
     _iocManager = iocManager;
     _moduleFinder = moduleFinder;
     //Logger = NullLogger.Instance;
 }
Exemple #6
0
        public async Task Cleanup()
        {
            await _collection.Dispose();

            _modules    = null;
            _collection = null;
        }
        public void SetPackageTest()
        {
            ModuleCollection mc;
            Package          package;
            Module           m;


            //
            // Setup the test.
            //
            package = new Package();
            mc      = new ModuleCollection(null);
            m       = new Module();
            mc.Add(m);

            //
            // Run the test.
            //
            mc.Owner = package;

            //
            // Verify the test.
            //
            Assert.AreSame(package, m.Package);
        }
Exemple #8
0
        public List <Guid> Authorized(string objectTypeName, params Guid[] objectId)
        {
            List <Guid> result = new List <Guid>();

            if (objectId.IsEmpty())
            {
                return(result);
            }
            int objectTypeCode = ModuleCollection.GetIdentity(objectTypeName);
            var resourceOwner  = _resourceOwnerService.FindByName(objectTypeName);

            if (resourceOwner == null || resourceOwner.StateCode == Core.RecordState.Disabled)
            {
                return(result);
            }
            var userInRole = _appContext.GetFeature <ICurrentUser>().Roles.Select(f => f.RoleId).ToArray();

            if (userInRole.NotEmpty())
            {
                var roaList = _roleObjectAccessRepository.Query(x => x.RoleId.In(userInRole) && x.ObjectTypeCode == objectTypeCode && x.ObjectId.In(objectId));
                result = objectId.ToList();
                result.RemoveAll(x => !roaList.Exists(r => r.ObjectId == x));
                return(result);
            }
            return(result);
        }
        public void RemoveItemTest()
        {
            ModuleCollection mc;
            Package          package;
            Module           m;


            //
            // Setup the test.
            //
            package = new Package();
            mc      = new ModuleCollection(package);
            m       = new Module();
            mc.Add(m);

            //
            // Run the test.
            //
            mc.Remove(m);

            //
            // Verify the test.
            //
            Assert.AreEqual(null, m.Package);
            Assert.AreEqual(0, mc.Count);
        }
        private void ClassifySubDirectory(DirectoryInfo subDirectory)
        {
            if (!subDirectory.Name.Contains(","))
            {
                return;
            }

            var stringSplit = subDirectory.Name.Split(',').ToList();

            var vsModule = new VsModule
            {
                Name     = stringSplit.FirstOrDefault(),
                Version  = stringSplit[1],
                FullPath = subDirectory.FullName
            };

            stringSplit.Remove(vsModule.Name);
            stringSplit.Remove(vsModule.Version);

            if (stringSplit.Any())
            {
                foreach (var item in stringSplit)
                {
                    vsModule.Name = $"{vsModule.Name},{item}";
                }
            }

            ModuleCollection.Add(vsModule);
        }
Exemple #11
0
        /// <summary>
        /// Creates a new instance of <see cref="ModuleHost"/>. When using startup args in your application, you can pass these args
        /// through to <see cref="ModuleHost"/> so they can be inspected by any <see cref="Module"/> which may require them.
        /// </summary>
        /// <param name="args">Arguments to pass to modules.</param>
        public ModuleHost(string[] args = null)
        {
            if (args != null)
            {
                Arguments = args;
            }
            else
            {
                Arguments = new List <string>();
            }

            var eventCollection  = new EventCollection(this);
            var moduleCollection = new ModuleCollection(this);

            // Create the events tracking list and a readonly wrapper to pass in the IModuleHost.EventsInProgress property.
            // We do this here since Host starts throwing a few LoggingEvent events into the system while importing and
            // loading, etc...
            _EventsInProgress         = new Dictionary <string, IEvent>();
            _ReadOnlyEventsInProgress = new ReadOnlyDictionary <string, IEvent>(_EventsInProgress);

            eventCollection.ImportEvents();
            moduleCollection.ImportModules();

            _EventCollection  = eventCollection;
            _ModuleCollection = moduleCollection;
        }
Exemple #12
0
        public TypeEdgeHost(IConfigurationRoot configuration)
        {
            _deviceId = configuration.GetValue <string>("DeviceId");
            _iotHubConnectionString = configuration.GetValue <string>("IotHubConnectionString");


            if (string.IsNullOrEmpty(_iotHubConnectionString))
            {
                throw new Exception("Missing \"IotHubConnectionString\" value in configuration");
            }

            if (string.IsNullOrEmpty(_deviceId))
            {
                throw new Exception("Missing \"DeviceId\"value in configuration");
            }

            _containerBuilder = new ContainerBuilder();
            _hub = new EdgeHub();

            Upstream = new Upstream <JsonMessage>(_hub);

            _inContainer = File.Exists(@"/.dockerenv");

            _externalModules = new ModuleCollection();
        }
        public void InsertItemTest()
        {
            ModuleCollection mc;
            Package          package;
            Module           m;


            //
            // Setup the test.
            //
            package = new Package();
            mc      = new ModuleCollection(package);
            mc.Add(new Module());
            m = new Module();

            //
            // Run the test.
            //
            mc.Insert(0, m);

            //
            // Verify the test.
            //
            Assert.AreSame(m, mc[0]);
        }
        public void SetItemTest()
        {
            ModuleCollection mc;
            Package          package, package2;
            Module           m1, m2;


            //
            // Setup the test.
            //
            package    = new Package();
            package2   = new Package();
            mc         = new ModuleCollection(package);
            m1         = new Module();
            m1.Package = package2;
            m2         = new Module();
            mc.Add(m1);

            //
            // Run the test.
            //
            mc[0] = m2;

            //
            // Verify the test.
            //
            Assert.AreSame(m2, mc[0]);
            Assert.AreEqual(1, mc.Count);
            Assert.AreEqual(null, m1.Package);
            Assert.AreEqual(package, m2.Package);
        }
Exemple #15
0
        //# Creates a new assembly, inserting it into the provided project.
        public Assembly(Project project, string fileName)
        {
            try {
                m_project = project.CheckNotNull("project");
                m_peFile = new PEFile(this, fileName);

                var assemblyRowCount = MetadataTable.Assembly.RowCount(m_peFile);
                if (assemblyRowCount <= 0)
                {
                    throw new FileLoadException("Not an assembly", fileName);
                }
                if (assemblyRowCount > 1)
                {
                    throw new FileLoadException("Too many rows in the assembly table.");
                }

                m_modules = new ModuleCollection(this, m_peFile);
                project.Add(this);
            }
            catch
            {
                Dispose();
                throw;
            }
        }
        /// <summary>
        /// Generates the javascript code for the game described in the specified model.
        /// </summary>
        /// <param name="model">The model that describes the game.</param>
        public string GenerateGameCode(GameModel model)
        {
            if (model == null)
                throw new ArgumentNullException("model");

            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            UpdateModules(model.Units);
            UpdateModules(model);

            var unitModules = new ModuleCollection();
            foreach (var unit in model.Units)
            {
                unitModules = new ModuleCollection(unitModules.Union(unit.Modules, Module.Comparer));
            }

            string background = model.Background.GenerateCode();
            string modules = unitModules.GenerateUnitModulesCode() + "\n" + model.Modules.GenerateGameModulesCode();
            string unitConstructors = GenerateUnitConstructors();
            string units = unitConstructors + model.Units.GenerateCollectionCode((unit) => unit.GenerateCode());
            string bindings = model.KeyBindings.GenerateCollectionCode((binding) => binding.GenerateCode());

            string game = Regex.Replace(gameTemplate, BackgroundPlaceholder, background, RegexOptions.None);
            game = Regex.Replace(game, ModulesPlaceholder, modules, RegexOptions.None);
            game = Regex.Replace(game, UnitsPlaceholder, units, RegexOptions.None);
            game = Regex.Replace(game, KeyBindingsPlaceholder, bindings, RegexOptions.None);

            return game;
        }
Exemple #17
0
        public async Task Initialize()
        {
            _collection = new ModuleCollection();
            LinkModelsRegistration.RegisterModules(_collection);
            await _collection.Seal();

            _modules = _collection.GetModuleProvider();
        }
        /// <summary>
        /// Constructs a new <see cref="JsGenerator"/> using the specified <see cref="ModuleCollection"/>.
        /// </summary>
        /// <param name="modules"></param>
        public JsGenerator(ModuleCollection modules)
        {
            if (modules == null)
                throw new ArgumentNullException("modules");

            gameTemplate = PathFinder.ReadEmbeddedFile(PathFinder.GameTemplateFile);
            presetModules = modules.ToDictionary(x => x.Name);
        }
Exemple #19
0
 private void Initialize()
 {
     modules = new ModuleCollection(this, 6);
     server  = new SocketTcpServer(port);
     server.ClientConnected    += new TcpClientConnectedEventHandler(server_ClientConnected);
     server.ClientDisconnected += new TcpClientConnectedEventHandler(server_ClientDisconnected);
     server.DataReceived       += new TcpDataReceivedEventHandler(server_DataReceived);
 }
Exemple #20
0
        public async Task Cleanup()
        {
            await _collection.Dispose();

            _collection = null;
            _provider   = null;
            _store      = null;
        }
Exemple #21
0
        public PagedList <Domain.Entity> QueryPaged(Func <QueryDescriptor <Domain.Entity>, QueryDescriptor <Domain.Entity> > container, Guid solutionId, bool existInSolution)
        {
            QueryDescriptor <Domain.Entity> q = container(QueryDescriptorBuilder.Build <Domain.Entity>());
            var datas = _entityRepository.QueryPaged(q, ModuleCollection.GetIdentity(EntityDefaults.ModuleName), solutionId, existInSolution);

            WrapLocalizedLabel(datas.Items);
            return(datas);
        }
Exemple #22
0
        private void Init()
        {
            CleanUp();

            BuildDiContainer();

            _modules = CreateModules();
        }
Exemple #23
0
        public PagedList <Domain.SystemForm> QueryPaged(Func <QueryDescriptor <Domain.SystemForm>, QueryDescriptor <Domain.SystemForm> > container, Guid solutionId, bool existInSolution, FormType formType)
        {
            QueryDescriptor <Domain.SystemForm> q = container(QueryDescriptorBuilder.Build <Domain.SystemForm>());
            var datas = _systemFormRepository.QueryPaged(q, ModuleCollection.GetIdentity(formType == FormType.Dashboard ? DashBoardDefaults.ModuleName : FormDefaults.ModuleName), solutionId, existInSolution);

            WrapLocalizedLabel(datas.Items);
            return(datas);
        }
Exemple #24
0
        public void Remove(Package package, ModuleCollection modules, IWriterCollection writers)
        {
            if (LoadedPackages.Contains(package))
            {
                Unload(package, modules, writers);
            }

            PackagesCollection.Packages.Remove(package);
        }
        public PagedList <SolutionComponent> QueryPaged(int page, int pageSize, Guid solutionId, string componentTypeName)
        {
            var identity = ModuleCollection.GetIdentity(componentTypeName);
            var q        = QueryDescriptorBuilder.Build <SolutionComponent>();

            q.Where(x => x.SolutionId == solutionId && x.ComponentType == identity);
            q.Page(page, pageSize);
            return(_solutionComponentRepository.QueryPaged(q));
        }
Exemple #26
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!this.Page.IsPostBack && this.Session["yhdm"] != null)
     {
         base.Response.Redirect("ShowInfomation.aspx");
         this.allModuleList = ModuleAction.GetUserModule(this.Session["yhdm"].ToString(), this.Session["pttest"].ToString());
         if (base.Request["id"] != null)
         {
             this.PartList = ModuleAction.GetOneLevelByID(base.Request["id"]);
         }
         else
         {
             this.PartList = ModuleAction.GetOneLevel();
         }
         HtmlTableRow htmlTableRow  = new HtmlTableRow();
         HtmlTableRow htmlTableRow2 = new HtmlTableRow();
         int          num;
         if (base.Request["id"] != null)
         {
             num = 1;
             if (this.PartList.Count != 0)
             {
                 this.str_title = this.PartList[0].ModuleName;
             }
         }
         else
         {
             num = 0;
         }
         int i;
         for (i = num; i < this.PartList.Count; i++)
         {
             if (i != num && (i - num) % 4 == 0)
             {
                 this.table_Navigate.Rows.Add(htmlTableRow);
                 this.table_Navigate.Rows.Add(htmlTableRow2);
                 this.RenderSpaceRow(this.table_Navigate);
                 htmlTableRow  = new HtmlTableRow();
                 htmlTableRow2 = new HtmlTableRow();
             }
             this.RenderImageRow(htmlTableRow, this.PartList[i]);
             this.RenderFontRow(htmlTableRow2, this.PartList[i]);
         }
         this.table_Navigate.Rows.Add(htmlTableRow);
         this.table_Navigate.Rows.Add(htmlTableRow2);
         this.RenderSpaceRow(this.table_Navigate);
         if ((i - num) % 4 != 0)
         {
             for (i = (i - num) % 4; i < 4; i++)
             {
                 this.RenderEmptyCell(htmlTableRow, "image");
                 this.RenderEmptyCell(htmlTableRow2, "font");
             }
         }
     }
 }
 private ObservableCollection <VsModule> GetDuplicateModulesFromModuleCollection()
 {
     return(ModuleCollection.Where(module =>
                                   ModuleCollection
                                   .Except(new ObservableCollection <VsModule> {
         module
     })
                                   .Any(x => x.Name == module.Name)
                                   ).ToObservableCollection());
 }
Exemple #28
0
        public static IServiceCollection AddInfrastructure(this IServiceCollection serviceCollection,
                                                           ModuleCollection modules)
        {
            serviceCollection.AddAutomapper(modules)
            .AddFeatures(modules)
            .AddRepository()
            .AddScoped <IWlMemoryCache, WlMemoryCache>();

            return(serviceCollection);
        }
Exemple #29
0
        private static ModuleCollection GetLoadedModules(IExceptionlessLog log, bool includeSystem = false, bool includeDynamic = false)
        {
            var modules = new ModuleCollection();

#if !PORTABLE && !NETSTANDARD1_2
            try {
                int id = 1;
                foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
                {
                    if (!includeDynamic && assembly.IsDynamic)
                    {
                        continue;
                    }

#if !NETSTANDARD1_3 && !NETSTANDARD1_4
                    try {
                        if (!includeDynamic && String.IsNullOrEmpty(assembly.Location))
                        {
                            continue;
                        }
                    } catch (SecurityException ex) {
                        const string message = "An error occurred while getting the Assembly.Location value. This error will occur when when you are not running under full trust.";
                        log.Error(typeof(ExceptionlessClient), ex, message);
                    }
#endif

                    if (!includeSystem)
                    {
                        try {
                            string publicKeyToken = assembly.GetAssemblyName().GetPublicKeyToken().ToHex();
                            if (_msPublicKeyTokens.Contains(publicKeyToken))
                            {
                                continue;
                            }

                            var attrs = assembly.GetCustomAttributes(typeof(System.CodeDom.Compiler.GeneratedCodeAttribute)).ToList();
                            if (attrs.Count > 0)
                            {
                                continue;
                            }
                        } catch {}
                    }

                    var module = assembly.ToModuleInfo();
                    module.ModuleId = id;
                    modules.Add(module);

                    id++;
                }
            } catch (Exception ex) {
                log.Error(typeof(ExceptionlessClient), ex, "Error loading modules: " + ex.Message);
            }
#endif
            return(modules);
        }
Exemple #30
0
        public static ModuleCollection GetUserModule(string userCode, string ptver)
        {
            moduleDT = SystemModule.GetUserPurviewModules(userCode, ptver);
            ModuleCollection modules = new ModuleCollection();

            foreach (DataRow row in moduleDT.Rows)
            {
                modules.Add(DataTableConvertModule(row));
            }
            return(modules);
        }
Exemple #31
0
        private static ModuleCollection GetLoadedModules(IExceptionlessLog log, bool includeSystem = false, bool includeDynamic = false)
        {
            var modules = new ModuleCollection();

            int id = 1;

            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                if (!includeDynamic && assembly.IsDynamic)
                {
                    continue;
                }

                try {
                    if (!includeDynamic && String.IsNullOrEmpty(assembly.Location))
                    {
                        continue;
                    }
                } catch (SecurityException ex) {
                    const string message = "An error occurred while getting the Assembly.Location value. This error will occur when when you are not running under full trust.";
                    log.Error(typeof(ExceptionlessClient), ex, message);
                }

                if (!includeSystem)
                {
                    try {
                        string publicKeyToken = assembly.GetAssemblyName().GetPublicKeyToken().ToHex();
                        if (_msPublicKeyTokens.Contains(publicKeyToken))
                        {
                            continue;
                        }

                        object[] attrs = assembly.GetCustomAttributes(typeof(GeneratedCodeAttribute), true);
                        if (attrs.Length > 0)
                        {
                            continue;
                        }
                    } catch {}
                }

                var module = assembly.ToModuleInfo();
                if (module.ModuleId > 0)
                {
                    continue;
                }

                module.ModuleId = id;
                modules.Add(module);

                id++;
            }

            return(modules);
        }
        public async Task Initialize()
        {
            _collection = new ModuleCollection();
            _collection.RegisterModule <MakabaNetworkConfig, IMakabaNetworkConfig>();
            _collection.RegisterModule <CommonUriGetter, INetworkUriGetter>();
            _collection.RegisterModule <MakabaUriGetter, INetworkUriGetter>();

            await _collection.Seal();

            _provider = _collection.GetModuleProvider();
        }
        public async Task Cleanup()
        {
            var config = _provider.QueryModule <IMakabaNetworkConfig>();

            config.BaseUri = null;
            await config.Save();

            await _collection.Dispose();

            _collection = null;
            _provider   = null;
        }
Exemple #34
0
 private void ClearUseModules()
 {
     if (UseModules != null)
     {
         UseModules.Modules.Clear();
         return;
     }
     UseModules = new ModuleCollection()
     {
         CanAcceptChildren = true,
         Modules           = new ReactiveCollection <Module>()
     };
 }
        public async Task Initialize()
        {
            _collection = new ModuleCollection();
            _collection.RegisterModule <ObjectSerializationService, IObjectSerializationService>();
            PostModelsRegistration.RegisterModules(_collection);
            LinkModelsRegistration.RegisterModules(_collection);
            _collection.RegisterModule <FakeExternalPostMediaSerializer, IObjectSerializer>();
            _collection.RegisterModule <FakePostAttributeSerializer, IObjectSerializer>();
            _collection.RegisterModule <FakePostNodeSerializer, IObjectSerializer>();
            await _collection.Seal();

            _modules = _collection.GetModuleProvider();
        }
Exemple #36
0
 ModuleContainer BuildModuleContainer(ModuleContainerBuilder builder, ModuleCollection modules, string topLevelDirectoryNameConvention)
 {
     if (modules.Count == 0)
     {
         // By convention, each subdirectory of topLevelDirectoryNameConvention is a module.
         builder.AddModuleForEachSubdirectoryOf(topLevelDirectoryNameConvention, "");
     }
     else
     {
         AddModulesFromConfig(modules, builder);
     }
     return(builder.Build());
 }
 public ServiceBusConfiguration()
 {
     WorkerAvailabilityManager = new WorkerAvailabilityManager();
     Modules = new ModuleCollection();
     TransactionScope = new TransactionScopeConfiguration();
     QueueManager = Core.QueueManager.Default();
     Serializer = new DefaultSerializer();
     MessageHandlerFactory = new DefaultMessageHandlerFactory();
     MessageRouteProvider = new DefaultMessageRouteProvider();
     ForwardingRouteProvider = new DefaultForwardingRouteProvider();
     PipelineFactory = new DefaultPipelineFactory();
     TransactionScopeFactory = new DefaultTransactionScopeFactory();
     Policy = new DefaultServiceBusPolicy();
     ThreadActivityFactory = new DefaultThreadActivityFactory();
 }
        /// <summary>
        /// Loads modules configuration from the provided XML document
        /// </summary>
        /// <param name="blackboard">The blackboard where will be loaded the modules</param>
        /// <param name="doc">The xml document from which the modules will be loaded</param>
        /// <param name="log">The log writer</param>
        /// <returns>The number of enabled modules loaded</returns>
        private static int LoadBlackboardModules(Blackboard blackboard, XmlDocument doc, ILogWriter log)
        {
            XmlNodeList modules;
            int i;
            //Command startupCommand;
            SortedList<string, ModuleClient> disabledModules;
            int clientModulesAdded;

            if (doc.GetElementsByTagName("modules").Count < 1)
            {
                log.WriteLine(0, "No modules to load");
                throw new Exception("No modules to load");
            }
            modules = doc.GetElementsByTagName("modules")[0].ChildNodes;

            clientModulesAdded = 0;
            disabledModules = new SortedList<string, ModuleClient>();
            for (i = 0; i < modules.Count; ++i)
            {
                if(LoadModule(blackboard, modules[i], log, disabledModules))
                    ++clientModulesAdded;
            }

            // Add disabled modules
            AddDisabledModules(blackboard, disabledModules, log);
            return clientModulesAdded;
        }
        /// <summary>
        /// Creates a blackboard from a XML configuration file
        /// </summary>
        /// <param name="path">The path of the XML configuration file</param>
        /// <param name="log">Output log</param>
        /// <returns>The configured blackboard</returns>
        public static Blackboard FromXML(string path, TextWriter log)
        {
            Blackboard blackboard;
            XmlDocument doc;
            XmlDocument tmpDoc;
            XmlNodeList modules;
            XmlNodeList commands;
            int i, j, cmdCount;

            string moduleName;
            string programPath;
            string programArgs;
            string cmdName;
            bool cmdParams;
            bool cmdAnswer;
            bool cmdPriority;
            int cmdTimeOut;
            Command startupCommand;
            Prototype msg;
            List<Prototype> msgList;
            ModuleClient mod;
            IPAddress ip;
            int port;

            log.Flush();
            if (!File.Exists(path))
            {
                log.WriteLine("File does not exist");
                throw new FileLoadException("File does not exist");
            }
            doc = new XmlDocument();
            doc.Load(path);

            if (
                (doc.GetElementsByTagName("blackboard").Count != 1) ||
                (doc.GetElementsByTagName("configuration").Count != 1) ||
                (doc.GetElementsByTagName("modules").Count < 1))
            {
                log.WriteLine("Incorrect format");
                throw new FileLoadException("Incorrect format");
            }

            blackboard = new Blackboard();
            log.WriteLine("Loading configuration...");
            tmpDoc = new XmlDocument();
            tmpDoc.LoadXml(doc.GetElementsByTagName("configuration")[0].OuterXml);
            // Leo puerto
            if ((tmpDoc.GetElementsByTagName("port").Count != 1) ||
                !Int32.TryParse(tmpDoc.GetElementsByTagName("port")[0].InnerText, out blackboard.port))
            {
                blackboard.port = 2300;
                log.WriteLine("No Blackboard port specified, using default: " + blackboard.Port);
            }
            else log.WriteLine("Blackboard port: " + blackboard.Port);

            if (doc.GetElementsByTagName("modules").Count < 1)
            {
                log.WriteLine("No modules to load");
                throw new Exception("No modules to load");
            }
            modules = doc.GetElementsByTagName("modules")[0].ChildNodes;
            blackboard.Initialize();
            #region Extraccion de Modulos
            for (i = 0; i < modules.Count; ++i)
            {
                try
                {
                    // Verifico que sea un modulo
                    if ((modules[i].Name != "module") ||
                        (modules[i].Attributes.Count < 1) ||
                        (modules[i].Attributes["name"].Value.Length < 1))
                        continue;

                    #region Extraccion de info del modulo
                    moduleName = modules[i].Attributes["name"].Value.ToUpper();
                    log.WriteLine("Loading module " + moduleName);
                    // Creo un subdocumento XML
                    tmpDoc.LoadXml(modules[i].OuterXml);
                    // Leo el Path de la aplicacion
                    if (tmpDoc.GetElementsByTagName("programPath").Count != 0)
                        programPath = tmpDoc.GetElementsByTagName("programPath")[0].InnerText;
                    // Leo los argumentos con que se inicia la aplicacion
                    if (tmpDoc.GetElementsByTagName("programArgs").Count != 0)
                        programArgs = tmpDoc.GetElementsByTagName("programArgs")[0].InnerText;
                    // Leo el comando de inicio
                    //if (tmpDoc.GetElementsByTagName("startupCommand").Count != 0)
                    //	startupMessage = Command.Parse(tmpDoc.GetElementsByTagName("startupCommand")[0].InnerText);
                    // Leo la IP de la maquina donde esta el modulo
                    if (
                        (tmpDoc.GetElementsByTagName("ip").Count == 0) ||
                        !IPAddress.TryParse(tmpDoc.GetElementsByTagName("ip")[0].InnerText, out ip))
                    {
                        log.WriteLine("\tInvalid IP Address");
                        log.WriteLine("Module skipped");
                        continue;
                    }
                    // Leo el puerto de conexion del modulo
                    if (
                        (tmpDoc.GetElementsByTagName("port").Count == 0) ||
                        !Int32.TryParse(tmpDoc.GetElementsByTagName("port")[0].InnerText, out port) ||
                        (port <= 1024))
                    {
                        log.WriteLine("\tInvalid port");
                        log.WriteLine("Module skipped");
                        continue;
                    }
                #endregion

                    // Creo el modulo
                    mod = new ModuleClient(moduleName, ip, port);

                    // Leo lista de comandos.
                    log.WriteLine("\tLoading module commands...");
                    if (doc.GetElementsByTagName("commands").Count < 1)
                    {
                        log.WriteLine("\tNo commands to load");
                        log.WriteLine("Module skipped");
                        continue;
                    }
                    commands = tmpDoc.GetElementsByTagName("commands")[0].ChildNodes;
                    msgList = new List<Prototype>(commands.Count);

                    #region Extraccion de Comandos de modulo

                    for (j = 0; j < commands.Count; ++j)
                    {
                        // Verifico que sea un comando
                        if ((commands[j].Name == "command") &&
                        (commands[j].Attributes.Count >= 3) &&
                        (commands[j].Attributes["name"].Value.Length > 1) &&
                        Boolean.TryParse(commands[j].Attributes["answer"].Value, out cmdAnswer) &&
                        Int32.TryParse(commands[j].Attributes["timeout"].Value, out cmdTimeOut) &&
                        (cmdTimeOut >= 0))
                        {
                            // Leo nombre de comando
                            cmdName = commands[j].Attributes["name"].Value;
                            log.WriteLine("\t\tAdded command " + cmdName);
                            // Verifico si requiere parametros
                            if(!Boolean.TryParse(commands[j].Attributes["parameters"].Value, out cmdParams))
                                cmdParams = true;
                            // Verifico si tiene prioridad
                            if (!Boolean.TryParse(commands[j].Attributes["priority"].Value, out cmdPriority))
                                cmdPriority = false;
                            // Creo el prototipo
                            msg = new Prototype(cmdName, cmdParams, cmdAnswer, cmdTimeOut);
                            // Agrego el prototipo al modulo
                            mod.Prototypes.Add(msg);
                            msgList.Add(msg);
                        }
                        else log.WriteLine("\t\tInvalid Command ");
                    }
                    #endregion
                    // Si no hay comandos soportados por el modulo, salto el modulo
                    if (msgList.Count < 1)
                    {
                        log.WriteLine("\tAll commands rejected.");
                        log.WriteLine("Module skipped");
                        continue;
                    }
                    // Agrego el modulo al blackboard
                    blackboard.modules.Add(mod);
                    log.WriteLine("Loading module complete!");
                }
                catch
                {
                    // Error al cargar el modulo
                    log.WriteLine("Invalid module");
                    // Continuo con el siguiente
                    continue;
                }
            #endregion
            }
            return blackboard;

            /*
            <module name="">
            <programPath></programPath>
            <programArgs></programArgs>
            <startupCommand></startupCommand>
            <ip>192.168.1.x</ip>
            <port>2000</port>
            <commands>
            <command name="" answer="True" timeout="100" />
            <command name="" answer="True" timeout="100" />
            <command name="" answer="True" timeout="100" />
            </commands>
            </module>
            */
        }
 public ServiceBusConfiguration()
 {
     WorkerAvailabilityManager = new WorkerAvailabilityManager();
     QueueManager = new QueueManager();
     Modules = new ModuleCollection();
 }
        private static ModuleCollection GetLoadedModules(
#if EMBEDDED
            IExceptionlessLog log,
#endif
            bool includeSystem = false, bool includeDynamic = false) {
            var modules = new ModuleCollection();

            int id = 1;
            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) {
#if PFX_LEGACY_3_5
                try {
                    if (!includeDynamic && assembly.ManifestModule is System.Reflection.Emit.MethodBuilder)
                        continue;   
                } catch (NotImplementedException ex) {
#if EMBEDDED
                    log.Error(ex, "An error occurred while checking if the current assembly is a dynamic assembly.");  
#endif
                }
#else
                if (!includeDynamic && assembly.IsDynamic)
                    continue;

                try {
                    if (!includeDynamic && String.IsNullOrEmpty(assembly.Location))
                        continue;
                } catch (SecurityException ex) {
                    const string message = "An error occurred while getting the Assembly.Location value. This error will occur when when you are not running under full trust.";
#if EMBEDDED
                    log.Error(typeof(ExceptionlessClient), ex, message);
#else
                    Trace.WriteLine(String.Format("{0} Exception: {1}", message, ex));
#endif
                }

#endif

                if (!includeSystem) {
                    try {
                        string publicKeyToken = assembly.GetAssemblyName().GetPublicKeyToken().ToHex();
                        if (_msPublicKeyTokens.Contains(publicKeyToken))
                            continue;

                        object[] attrs = assembly.GetCustomAttributes(typeof(GeneratedCodeAttribute), true);
                        if (attrs.Length > 0)
                            continue;
                    } catch {}
                }

#if EMBEDDED
                var module = assembly.ToModuleInfo(log);
                module.ModuleId = id;
                modules.Add(assembly.ToModuleInfo(log));
#else
                var module = assembly.ToModuleInfo();
                module.ModuleId = id;
                modules.Add(assembly.ToModuleInfo());
#endif
                id++;
            }

            return modules;
        }
 private void Initialize()
 {
     modules = new ModuleCollection(this, 6);
     server = new SocketTcpServer(port);
     server.ClientConnected += new TcpClientConnectedEventHandler(server_ClientConnected);
     server.ClientDisconnected += new TcpClientConnectedEventHandler(server_ClientDisconnected);
     server.DataReceived += new TcpDataReceivedEventHandler(server_DataReceived);
 }
Exemple #43
0
        public void Dispose()
        {
            if (m_peFile != null) {
                m_peFile.Dispose();
            }

            if (m_modules != null) {
                m_modules.Dispose();
            }

            m_modules = null;
            m_peFile = null;
            m_assemblyRow = null;
            m_project = null;
        }
Exemple #44
0
 public static bool Compare(this ModuleCollection source, ModuleCollection n)
 {
     return Compare<Module>(source,n);
 }
Exemple #45
0
 public static bool Compare(this ModuleCollection source, ModuleCollection n, Func<Module, Module, bool> checkitem)
 {
     return Compare<Module>(source,n,checkitem);
 }
Exemple #46
0
 public static bool Compare(this ModuleCollection source, ModuleCollection n, Func<Module, Module, Action<string, string>, bool> checkitem, Action<string, string> errAct)
 {
     return Compare<Module>(source,n,checkitem,errAct);
 }
        /// <summary>
        /// Initializes a new instance of Blackboard
        /// </summary>
        private Blackboard()
        {
            this.modules = new ModuleCollection(this, 20);
            this.prototypes = new Dictionary<string, IPrototype>(1000);
            this.prototypesLock = new ReaderWriterLock();
            //modules.ModuleAdded += new ModuleClientAddRemoveEH(modules_ModuleAdded);
            //modules.ModuleRemoved += new ModuleClientAddRemoveEH(modules_ModuleRemoved);
            this.modules.ModuleAdded += new IModuleAddRemoveEH(modules_ModuleAdded);
            this.modules.ModuleRemoved += new IModuleAddRemoveEH(modules_ModuleRemoved);
            this.commandsPending = new ProducerConsumer<Command>(1000);
            this.commandsWaiting = new List<Command>(100);
            this.responses = new List<Response>(100);
            this.log = new LogWriter();
            this.log.VerbosityTreshold = verbosity;
            this.dataReceived = new ProducerConsumer<TcpPacket>(1000);
            this.retryQueue = new Queue<Response>(100);
            this.sendAttempts = 0;
            this.testTimeOut = TimeSpan.MinValue;
            this.autoStopTime = TimeSpan.MinValue;
            this.startupSequence = new StartupSequenceManager(this);
            this.shutdownSequence = new ShutdownSequenceManager(this);
            this.pluginManager = new BlackboardPluginManager(this);

            this.mainThreadRunningEvent = new ManualResetEvent(false);
            this.parserThreadRunningEvent = new ManualResetEvent(false);
        }
Exemple #48
0
 public Error() {
     Modules = new ModuleCollection();
 }
        private static ModuleCollection GetLoadedModules(IExceptionlessLog log, bool includeSystem = false, bool includeDynamic = false) {
            var modules = new ModuleCollection();

            try {
                int id = 1;
                foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) {
                    if (!includeDynamic && assembly.IsDynamic)
                        continue;

                    try {
                        if (!includeDynamic && String.IsNullOrEmpty(assembly.Location))
                            continue;
                    } catch (SecurityException ex) {
                        const string message = "An error occurred while getting the Assembly.Location value. This error will occur when when you are not running under full trust.";
                        log.Error(typeof(ExceptionlessClient), ex, message);
                    }

                    if (!includeSystem) {
                        try {
                            string publicKeyToken = assembly.GetAssemblyName().GetPublicKeyToken().ToHex();
                            if (_msPublicKeyTokens.Contains(publicKeyToken))
                                continue;

                            object[] attrs = assembly.GetCustomAttributes(typeof(GeneratedCodeAttribute), true);
                            if (attrs.Length > 0)
                                continue;
                        } catch {}
                    }

                    var module = assembly.ToModuleInfo();
                    module.ModuleId = id;
                    modules.Add(module);

                    id++;
                }
            } catch (Exception ex) {
                log.Error(typeof(ExceptionlessClient), ex, "Error loading modules: " + ex.Message);
            }

            return modules;
        }
        protected void Initialize()
        {
            RootPath = Server.MapPath(PathFinder.Root);

            string unitPresetModulesPath = Path.Combine(RootPath, PathFinder.DefaultUnitModules),
                gamePresetModulesPath = Path.Combine(RootPath, PathFinder.DefaultGameModules);

            var moduleSerializer = new XmlSerializer(typeof(ModuleCollection));
            using (var unitFile = File.OpenRead(unitPresetModulesPath))
            using (var gameFile = File.OpenRead(gamePresetModulesPath))
            {
                var unitModules = moduleSerializer.Deserialize(unitFile) as ModuleCollection;
                var gameModules = moduleSerializer.Deserialize(gameFile) as ModuleCollection;
                PresetModules = new ModuleCollection(unitModules.Concat(gameModules));
            }
            CreateConfigFile();
            GameMaker.PathFinder.CreateExtensionsScipt(Path.Combine(RootPath, @"Scripts/Extensions.js"));
        }
        /// <summary>
        /// Loads the startup sequence of the blackboard modules
        /// </summary>
        /// <param name="blackboard">The blackboard where will be loaded the startup sequence</param>
        /// <param name="doc">The xml document from which the actions will be loaded</param>
        /// <param name="log">The log writer</param>
        private static void LoadStartupSequence(Blackboard blackboard, XmlDocument doc, ILogWriter log)
        {
            XmlNodeList modules;
            string moduleName;

            if (doc.GetElementsByTagName("startupSequence").Count != 1)
            {
                log.WriteLine(1, "Startup sequence not found");
                return;
            }

            modules = doc.GetElementsByTagName("startupSequence")[0].ChildNodes;
            for(int i = 0; i < modules.Count; ++i)
            {
                try
                {
                    // Module check
                    if ((modules[i].Name != "module") ||
                        //(modules[i].Attributes.Count < 1) ||
                        //(modules[i].Attributes["name"].Value.Length < 1) ||
                        (modules[i].InnerText == null) ||
                        (modules[i].InnerText.Length < 1))
                        continue;

                    //moduleName = modules[i].Attributes["name"].Value.ToUpper();
                    moduleName = modules[i].InnerText.ToUpper();
                    if(blackboard.StartupSequence.ModuleSequence.Contains(moduleName))
                        continue;
                    blackboard.StartupSequence.ModuleSequence.Add(moduleName);
                }
                catch
                {
                    continue;
                }
            }
            log.WriteLine(1, "Startup sequence: " + String.Join(", ", blackboard.StartupSequence.ModuleSequence.ToArray()));
        }
		internal Process(NDebugger debugger, ICorDebugProcess corProcess, string workingDirectory)
		{
			this.debugger = debugger;
			this.corProcess = corProcess;
			this.workingDirectory = workingDirectory;
			
			this.callbackInterface = new ManagedCallback(this);
			
			activeEvals = new EvalCollection(debugger);
			modules = new ModuleCollection(debugger);
			modules.Added += OnModulesAdded;
			threads = new ThreadCollection(debugger);
			appDomains = new AppDomainCollection(debugger);
		}
        public virtual IModuleCollection TransformModuleCollection(IModuleCollection value)
        {
            IModule[] array = new IModule[value.Count];
            for (int i = 0; i < value.Count; i++)
            {
                array[i] = this.TransformModule(value[i]);
            }

            IModuleCollection target = new ModuleCollection();
            target.AddRange(array);
            return target;
        }