Beispiel #1
0
 /// <summary>
 /// Create a new noise module with the given values
 /// </summary>
 /// <param name="source">the source module</param>
 /// <param name="xDisplaceModule">the displacement module that displaces the x coordinate</param>
 /// <param name="yDisplaceModule">the displacement module that displaces the y coordinate</param>
 /// <param name="zDisplaceModule">the displacement module that displaces the z coordinate</param>
 public Displace(IModule source, IModule xDisplaceModule, IModule yDisplaceModule, IModule zDisplaceModule)
 {
     _sourceModule = source;
     _xDisplaceModule = xDisplaceModule;
     _yDisplaceModule = yDisplaceModule;
     _zDisplaceModule = zDisplaceModule;
 }
Beispiel #2
0
        // <summary>
        // Initialises a new instance of the Plane class.
        // </summary>
        // <param name="sourceModule">The module from which to retrieve noise.</param>
        public Plane(IModule sourceModule)
        {
            if (sourceModule == null)
                throw new ArgumentNullException("A source module must be provided.");

            SourceModule = sourceModule;
        }
        public override void SetModuleSettings(IModule module)
        {
            SvrTexture texture = (SvrTexture)module;

            // Set the pixel format
            switch (pixelFormatBox.SelectedIndex)
            {
                case 0: texture.PixelFormat = SvrPixelFormat.Rgb5a3; break;
                case 1: texture.PixelFormat = SvrPixelFormat.Argb8888; break;
            }

            // Set the data format
            switch (dataFormatBox.SelectedIndex)
            {
                case 0: texture.DataFormat = SvrDataFormat.Rectangle; break;
                case 1: texture.DataFormat = SvrDataFormat.Index4ExternalPalette; break;
                case 2: texture.DataFormat = SvrDataFormat.Index8ExternalPalette; break;
                case 3: texture.DataFormat = SvrDataFormat.Index4; break;
                case 4: texture.DataFormat = SvrDataFormat.Index8; break;
            }

            // Set the global index stuff
            texture.HasGlobalIndex = hasGlobalIndexCheckBox.Checked;
            if (texture.HasGlobalIndex)
            {
                uint globalIndex = 0;
                if (!uint.TryParse(globalIndexTextBox.Text, out globalIndex))
                {
                    globalIndex = 0;
                }
                texture.GlobalIndex = globalIndex;
            }
        }
 private void StartAsyncUploading(IModule uploader, String name, byte[] bytes)
 {
     var backgroundWorker = new BackgroundWorker();
     backgroundWorker.DoWork += (s, e) => e.Result = uploader.Upload(name, bytes);
     backgroundWorker.RunWorkerCompleted += (s, e) => Clipboard.SetText((String) e.Result);
     backgroundWorker.RunWorkerAsync();
 }
        public void ReleaseModule(IModule module)
        {
            _container.Release(module);
            _container.Release(_roomModules[module]);

            _roomModules.Remove(module);
        }
Beispiel #6
0
        public ClampOutput(IModule sourceModule)
        {
            SourceModule = sourceModule;

            LowerBound = -1;
            UpperBound = 1;
        }
 public ModuleBasedOnRegistration(IModule sourceModule, BasedOnRegistrationBase basedOn)
     : base(basedOn.RegistrationElement)
 {
     this.sourceModule = sourceModule;
     this.basedOn = basedOn;
     basedOn.Module = sourceModule;
 }
 public ModuleLayout(IModule module)
 {
     this.InitializeComponent();
     this.module = module;
     this.module.setFrame(Window.Current.Content as Frame);
     this.moduleName.Text = module.getName();
 }
 public ModuleGene(uint innovationId, IModule function, List<uint> inputs, List<uint> outputs)
 {
     this.InnovationId = innovationId;
     this.Function = function;
     this.InputIds = inputs;
     this.OutputIds = outputs;
 }
Beispiel #10
0
 public ProductsController(INews news, IModule module, IPhoto photo, ICacheManager cache)
 {
     _news = news;
     _module = module;
     _cache = cache;
     _photo = photo;
 }
Beispiel #11
0
        public override void Visit(IModule module)
        {
            this.module = module;

            // Visit these assembly-level attributes even when producing a module.
            // They'll be attached off the "AssemblyAttributesGoHere" typeRef if a module is being produced.
            Visit(module.AssemblyAttributes);
            Visit(module.AssemblySecurityAttributes);

            Visit(module.GetAssemblyReferences(Context));
            Visit(module.ModuleReferences);
            Visit(module.ModuleAttributes);
            Visit(module.GetTopLevelTypes(Context));

            foreach (var exportedType in module.GetExportedTypes(Context.Diagnostics))
            {
                VisitExportedType(exportedType.Type);
            }

            if (module.AsAssembly == null)
            {
                Visit(module.GetResources(Context));
            }

            VisitImports(module.GetImports());
        }
Beispiel #12
0
        /// <summary>
        /// Creates an <see cref="IntegerType"/> instance.
        /// </summary>
        /// <param name="module"></param>
        /// <param name="name"></param>
        /// <param name="enumerator"></param>
        public IntegerType(IModule module, string name, Symbol type, ISymbolEnumerator symbols)
            : base (module, name)
        {
            Types? t = GetExactType(type);
            type.Assert(t.HasValue, "Unknown symbol for unsigned type!");
            _type = t.Value;

            _isEnumeration = false;

            Symbol current = symbols.NextNonEOLSymbol();
            if (current == Symbol.OpenBracket)
            {
                _isEnumeration = true;
                symbols.PutBack(current);
                _map = Lexer.DecodeEnumerations(symbols);
            }
            else if (current == Symbol.OpenParentheses)
            {
                symbols.PutBack(current);
                _ranges = Lexer.DecodeRanges(symbols);
                current.Assert(!_ranges.IsSizeDeclaration, "SIZE keyword is not allowed for ranges of integer types!");
            }
            else
            {
                symbols.PutBack(current);
            }
        }
        public static IModule RewriteModule(IMetadataHost host, ILocalScopeProvider localScopeProvider, ISourceLocationProvider sourceLocationProvider, IModule module)
        {
            var m = new PropertyChangedWeaver(host);
            m._rewriter = new ReferenceReplacementRewriter(host, localScopeProvider, sourceLocationProvider);

            return m.Rewrite(module);
        }
Beispiel #14
0
        public void LoadModule(string ModuleName)
        {
            if (ModuleName == "Dummy") return;
            Assembly a = null;
            try {
                a = Assembly.LoadFrom(ModuleName);
            }
            catch {
                throw new ModuleLoadException(string.Format("Не могу загрузить сборку \"{0}\"", ModuleName));
            }

            Type[] allTypes = a.GetTypes();
            foreach (Type type in allTypes) // ищем во всех классах интерфейс IModule
            {
                Type IModule = type.GetInterface("IModule");
                if (IModule != null) {
                    _module = (IModule) Activator.CreateInstance(type);
                    break;
                }
            }

            if (_module == null)
                throw new ModuleLoadException(string.Format("В сборке \"{0}\" не найден интерфейс IModule.", ModuleName));

            _module.Init();
        }
Beispiel #15
0
        public override StateEnums.Status Execute(Object o, Hashtable inputData)
        {
            int activityIdStarting = UpdateProcessStatus(Enums.ProcessStatus.Starting, "", (State)o );

            try
            {
                for (int i = 0; i < testLoopCycles; i++)
                {
                    if (!ifRetry) throw new Exception("Cancelling " + job.JobName + "...");
                    Thread.Sleep(testLoopInterval);
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
            }

            log.InfoFormat(((State)o).CurrentJobHash, "NullModule executed.");

            if (impersonatedModule != null)
            {
                IDependency<IModule> impersonatedDependencyToRestore =
                                                            (IDependency<IModule>)this.job.Dependencies[this.Name];
                impersonatedDependencyToRestore.Module = impersonatedModule;
                impersonatedModule = null;
            }

            return StateEnums.Status.Success;
        }
Beispiel #16
0
 public DisplaceInput(IModule sourceModule, IModule xDisplaceModule, IModule yDisplaceModule, IModule zDisplaceModule)
 {
     SourceModule = sourceModule;
     XDisplaceModule = xDisplaceModule;
     YDisplaceModule = yDisplaceModule;
     ZDisplaceModule = zDisplaceModule;
 }
        public IModule AddModule(IModule module)
        {
            // Add
            Modules.Add(module);

            return module;
        }
Beispiel #18
0
 //Constructor//
 public Line(IModule mod0)
 {
     Module0 = mod0;
     Attenuate = true;
     m_x0 = 0.0; m_y0 = 0.0; m_z0 = 0.0;
     m_x1 = 1.0; m_y1 = 1.0; m_z1 = 1.0;
 }
Beispiel #19
0
        /// <summary>
        /// Loads a module into memory so that it can configure a dependency map.
        /// </summary>
        /// <param name="module">
        /// The target module.
        /// </param>
        public void LoadModule(IModule module)
        {
            if(module == null)
                throw new ArgumentNullException("module");

            module.Load(_dependencyMap);
        }
 /// <summary>
 /// Creates new instance of AutofacViewModelFactory using an Autofac Module
 /// 
 /// This will cause the container to be disposed when the AutofacViewModelFactory is disposed
 /// </summary>
 public AutofacViewModelFactory(IModule moduleToRegister)
 {
     var containerBuilder = new ContainerBuilder();
     containerBuilder.RegisterModule(moduleToRegister);
     autofacContainer = containerBuilder.Build();
     shouldDisposeContainer = true;
 }
Beispiel #21
0
        private static void DemoInferables(IModule module)
        {
            ShowConsoleHeader(module);

            // Here we are getting an inferred type that matches interface IFoo based on the namespace bindings for this module.
            var foo = module.Get<IFoo>();
            foo.Dump("Value for foo");

            // This method resolves the inferred on finding the match patten foo2 for Interface type IFoo.
            var foo2 = module.Get<IFoo>("foo2");
            foo.Dump("Value for foo2");

            // Here we are getting foo again- performance very good this time around since all type generation il code has been cached.
            var fooAgain = module.Get<IFoo>();
            fooAgain.Dump("Value for fooAgain");

            // Here we are mapping explicitly to a Foo type, choosing the appropriate constructor and infering dependencies.
            var explicitFoo = module.GetExplicit<Foo>();
            explicitFoo.Dump("Value of explicit foo");

            ShowFactoryTestsHeader();

            // Here we are binding to a custom factory interface, which will automatically generate a type for this factory, cache the it, and instantiate it.
            var factory = module.GetFactory<IFactory>();
            factory.GetFoo().Dump("Value for GetFoo()");
            factory.GetFoo1().Dump("Value for GetFoo1()");
            factory.GetFoo2().Dump("Value for GetFoo2()");
            factory.GetFoo3().Dump("Value for GetFoo3()");
            factory.GetFoo4().Dump("Value for GetFoo4()");
            factory.GetFoo5().Dump("Value for GetFoo5()");
            factory.GetFoo6().Dump("Value for GetFoo6()");
        }
 private static void PersistModuleToFile(string folder, IModule module, IObjectTree tree)
 {
     string fileName = Path.Combine(folder, module.Name + ".module");
     using (StreamWriter writer = new StreamWriter(fileName))
     {
         writer.Write("#");
         foreach (string dependent in module.Dependents)
         {
             writer.Write(dependent);
             writer.Write(',');
         }
         
         writer.WriteLine();
         foreach (IEntity entity in module.Entities)
         {
             IDefinition node = tree.Find(module.Name, entity.Name);
             if (node == null)
             {
                 continue;
             }
             
             uint[] id = node.GetNumericalForm();
             /* 0: id
              * 1: type
              * 2: name
              * 3: parent name
              */
             writer.WriteLine(ObjectIdentifier.Convert(id) + "," + entity.GetType() + "," + entity.Name + "," + entity.Parent);
         }
         
         writer.Close();
     }
 }
Beispiel #23
0
        public void LoadModule(IModule module)
        {
            if (this.modules.Contains (module))
                throw new ArgumentException ();

            this.modules.Add (module);
        }
        public CfgManipulator(IModule module, PeReader.DefaultHost host, Log.Log logger, MethodCfg methodCfg) {
            this.host = host;
            this.logger = logger;
            this.module = module;

            this.methodCfg = methodCfg;
        }
        public CompressedCacheEntry(IModule destination, HttpListenerContext context)
        {
            Created = DateTime.Now;
            using (MemoryStream memory = new MemoryStream())
            {
                // Store the raw document.
                destination.Process(memory, context);
                Content = memory.ToArray();

                // Attempt to deflate the document, store if size is reduced.
                using (MemoryStream deflateMemory = new MemoryStream())
                using (DeflateStream deflate = new DeflateStream(deflateMemory, CompressionLevel.Optimal))
                {
                    deflate.Write(Content, 0, Content.Length);
                    if (deflateMemory.Length < Content.Length)
                    {
                        Deflated = deflateMemory.ToArray();
                        IsDeflated = true;
                    }
                    else
                    {
                        IsDeflated = false;
                    }
                }
            }
        }
Beispiel #26
0
 public TranslatePoint(IModule mod0, double xTrans, double yTrans, double zTrans)
 {
     Module0 = mod0;
     XTranslation = xTrans;
     YTranslation = yTrans;
     ZTranslation = zTrans;
 }
Beispiel #27
0
 public ScalePoint(IModule mod0, double xScale, double yScale, double zScale)
 {
     Module0 = mod0;
     XScale = xScale;
     YScale = yScale;
     ZScale = zScale;
 }
Beispiel #28
0
 public virtual bool SubscribeModule(IModule m)
 {
     if (m.Type == typeof(ControlModule))
     {
         var t = m as ControlModule;
         if(!cmdic.ContainsValue(t))
         {
             cmdic.Add(t.Text, t);
         }
         return true;
     }
     if (m.Type == typeof(AnalysisModule))
     {
         var t = m as AnalysisModule;
         if (!amdic.ContainsValue(t))
         {
             amdic.Add(t.Text, t);
         }
         return true;
     }
     if (m.Type == typeof(SignalModule))
     {
         var t = m as SignalModule;
         if (!smdic.ContainsValue(t))
         {
             smdic.Add(t.Text, t);
         }
         return true;
     }
     return false;
 }
Beispiel #29
0
 public Displace(IModule mod0, IModule xDisplaceModule, IModule yDisplaceModule, IModule zDisplaceModule)
 {
     Module0 = mod0;
     XDisplaceModule = xDisplaceModule;
     YDisplaceModule = yDisplaceModule;
     ZDisplaceModule = zDisplaceModule;
 }
Beispiel #30
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="shape">TBD</param>
 /// <param name="module">TBD</param>
 public GraphImpl(TShape shape, IModule module)
 {
     Shape  = shape;
     Module = module;
 }
Beispiel #31
0
 public string GetAutoInstallPackagesUiUrl(ISite site, IModule module, bool forContentApp)
 {
     return("mvc not implemented #todo #mvc");
 }
Beispiel #32
0
 private ExecutionContext(ExecutionContext original, IModule module)
 {
     Engine    = original.Engine;
     _pipeline = original._pipeline;
     Module    = module;
 }
Beispiel #33
0
 public HubModule(IModule parent, int order) : base(parent, order)
 {
 }
Beispiel #34
0
 public HubModule(IModule parent) : base(parent)
 {
 }
Beispiel #35
0
 public AssemblyTreeNode FindAssemblyNode(IModule module)
 {
     return(FindAssemblyNode(module.PEFile));
 }
Beispiel #36
0
 public S_TRAMPOLINE(IServiceContainer ctx, IModule mod, SpanStream stream) : base(ctx, mod, stream)
 {
 }
        public bool Run(IModule caller, string macroName, ModellerControllerParameter[] arguments)
        {
            string unused = null;

            return(Run(caller, macroName, arguments, null, ref unused));
        }
 /// <summary>
 /// </summary>
 /// <param name="projectFile"></param>
 /// <param name="performanceAnalysis"></param>
 /// <param name="userInitials"></param>
 public ModellerController(IModule caller, string projectFile, bool performanceAnalysis = false, string userInitials = "XTMF")
     : this(caller, projectFile, Guid.NewGuid().ToString(), performanceAnalysis, userInitials)
 {
 }
 public bool Run(IModule caller, string macroName, ModellerControllerParameter[] arguments, ref string returnValue)
 {
     return(Run(caller, macroName, arguments, null, ref returnValue));
 }
Beispiel #40
0
 /// <summary>
 /// Create the array of data with the given size
 /// </summary>
 /// <param name="length">The number of modules that will be installed</param>
 internal abstract void CreateArray(IModule origin, int length);
        private bool WaitForEmmeResponce(IModule caller, ref string returnValue, Action <float> updateProgress)
        {
            // now we need to wait
            try
            {
                string toPrint;
                while (true)
                {
                    BinaryReader reader = new BinaryReader(EMMEPipe);
                    int          result = reader.ReadInt32();
                    switch (result)
                    {
                    case SignalStart:
                    {
                        continue;
                    }

                    case SignalRunComplete:
                    {
                        return(true);
                    }

                    case SignalRunCompleteWithParameter:
                    {
                        returnValue = reader.ReadString();
                        return(true);
                    }

                    case SignalTermination:
                    {
                        throw new XTMFRuntimeException(caller, "The EMME ModellerBridge panicked and unexpectedly shutdown.");
                    }

                    case SignalParameterError:
                    {
                        throw new EmmeToolParameterException(caller, "EMME Parameter Error: " + reader.ReadString());
                    }

                    case SignalRuntimeError:
                    {
                        throw new EmmeToolRuntimeException(caller, "EMME Runtime " + reader.ReadString());
                    }

                    case SignalToolDoesNotExistError:
                    {
                        throw new EmmeToolCouldNotBeFoundException(caller, reader.ReadString());
                    }

                    case SignalCheckToolExists:
                    {
                        return(true);
                    }

                    case SignalSentPrintMessage:
                    {
                        toPrint = reader.ReadString();
                        Console.Write(toPrint);
                        break;
                    }

                    case SignalProgressReport:
                    {
                        var progress = reader.ReadSingle();
                        updateProgress?.Invoke(progress);
                        break;
                    }

                    default:
                    {
                        throw new XTMFRuntimeException(caller, "Unknown message passed back from the EMME ModellerBridge.  Signal number " + result);
                    }
                    }
                }
            }
            catch (EndOfStreamException)
            {
                throw new XTMFRuntimeException(caller, "We were unable to communicate with EMME.  Please make sure you have an active EMME license.  If the problem persists, sometimes rebooting has helped fix this issue with EMME.");
            }
            catch (IOException e)
            {
                throw new XTMFRuntimeException(caller, "I/O Connection with EMME ended while waiting for data, with:\r\n" + e.Message);
            }
        }
Beispiel #42
0
 internal override void CreateArray(IModule origin, int length)
 {
     Property.SetValue(origin, Array.CreateInstance(Property.PropertyType.GetElementType() !, length));
 }
        public ModellerController(IModule caller, string projectFile, string pipeName,
                                  bool performanceAnalysis = false, string userInitials = "XTMF", bool launchInNewProcess = true)
        {
            if (!projectFile.EndsWith(".emp") | !File.Exists(projectFile))
            {
                throw new XTMFRuntimeException(caller, AddQuotes(projectFile) + " is not an existing Emme project file (*.emp)");
            }

            FailTimer   = 30;
            ProjectFile = projectFile;
            string workingDirectory = ProjectFile;

            //Python invocation command:
            //[FullPath...python.exe] -u [FullPath...ModellerBridge.py] [FullPath...EmmeProject.emp] [User initials] [[Performance (optional)]]

            // Get the path of the Python executable
            string emmePath = Environment.GetEnvironmentVariable("EMMEPATH");

            if (String.IsNullOrWhiteSpace(emmePath))
            {
                throw new XTMFRuntimeException(caller, "Please make sure that EMMEPATH is on the system environment variables!");
            }
            string pythonDirectory = Path.Combine(emmePath, FindPython(caller, emmePath));
            string pythonPath      = AddQuotes(Path.Combine(pythonDirectory, @"python.exe"));
            string pythonLib       = Path.Combine(pythonDirectory, "Lib");

            // Get the path of ModellerBridge
            // Learn where the modules are stored so we can find the python script
            // The Entry assembly will be the XTMF.GUI or XTMF.RemoteClient
            var codeBase = typeof(ModellerController).GetTypeInfo().Assembly.Location;
            // When EMME is installed it will link the .py to their python interpreter properly
            string argumentString = AddQuotes(Path.Combine(Path.GetDirectoryName(codeBase), "ModellerBridge.py"));

            EMMEPipe = new NamedPipeServerStream(pipeName, PipeDirection.InOut, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous);
            Parallel.Invoke(() =>
            {
                // no more standard out
                EMMEPipe.WaitForConnection();
                using (BinaryReader reader = new BinaryReader(EMMEPipe, Encoding.UTF8, true))
                {
                    // wait for the start
                    reader.ReadInt32();
                }
            }, () =>
            {
                //The first argument that gets passed into the Bridge is the name of the Emme project file
                argumentString += " " + AddQuotes(projectFile) + " " + userInitials + " " + (performanceAnalysis ? 1 : 0) + " \"" + pipeName + "\"";
                if (launchInNewProcess)
                {
                    //Setup up the new process
                    // When creating this process, we can not start in our own window because we are re-directing the I/O
                    // and windows won't allow us to have a window and take its standard I/O streams at the same time
                    Emme          = new Process();
                    var startInfo = new ProcessStartInfo(pythonPath, argumentString);
                    startInfo.Environment["PATH"] += ";" + pythonLib + ";" + Path.Combine(emmePath, "programs");
                    Emme.StartInfo = startInfo;
                    Emme.StartInfo.CreateNoWindow         = false;
                    Emme.StartInfo.UseShellExecute        = false;
                    Emme.StartInfo.RedirectStandardInput  = false;
                    Emme.StartInfo.RedirectStandardOutput = false;

                    //Start the new process
                    try
                    {
                        Emme.Start();
                    }
                    catch
                    {
                        throw new XTMFRuntimeException(caller, "Unable to create a bridge to EMME to '" + AddQuotes(projectFile) + "'!");
                    }
                }
            });
        }
        /// <summary>
        /// Finds or downloads the ELF module and creates a MachOFile instance for it.
        /// </summary>
        /// <param name="module">module instance</param>
        /// <returns>MachO file instance or null</returns>
        internal MachOFile GetMachOFile(IModule module)
        {
            string    downloadFilePath = null;
            MachOFile machoFile        = null;

            if (File.Exists(module.FileName))
            {
                // TODO - Need to verify the build id matches this local file
                downloadFilePath = module.FileName;
            }
            else
            {
                if (!module.BuildId.IsDefaultOrEmpty)
                {
                    SymbolStoreKey key = MachOFileKeyGenerator.GetKeys(KeyTypeFlags.IdentityKey, module.FileName, module.BuildId.ToArray(), symbolFile: false, symbolFileName: null).SingleOrDefault();
                    if (key is not null)
                    {
                        // Now download the module from the symbol server
                        downloadFilePath = SymbolService.DownloadFile(key);
                    }
                    else
                    {
                        Trace.TraceWarning($"GetMachOFile: no index generated for module {module.FileName} ");
                    }
                }
                else
                {
                    Trace.TraceWarning($"GetMachOFile: module {module.FileName} has no index timestamp/filesize");
                }
            }

            if (!string.IsNullOrEmpty(downloadFilePath))
            {
                Trace.TraceInformation("GetMachOFile: downloaded {0}", downloadFilePath);
                Stream stream;
                try
                {
                    stream = File.OpenRead(downloadFilePath);
                }
                catch (Exception ex) when(ex is DirectoryNotFoundException || ex is FileNotFoundException || ex is UnauthorizedAccessException || ex is IOException)
                {
                    Trace.TraceError($"GetMachOFile: OpenRead exception {ex.Message}");
                    return(null);
                }
                try
                {
                    machoFile = new MachOFile(new StreamAddressSpace(stream), position: 0, dataSourceIsVirtualAddressSpace: false);
                    if (!machoFile.IsValid())
                    {
                        Trace.TraceError($"GetMachOFile: not a valid file");
                        return(null);
                    }
                }
                catch (Exception ex) when(ex is InvalidVirtualAddressException || ex is BadInputFormatException || ex is IOException)
                {
                    Trace.TraceError($"GetMachOFile: exception {ex.Message}");
                    return(null);
                }
            }

            return(machoFile);
        }
Beispiel #45
0
 internal override void CreateArray(IModule origin, int length)
 {
     Field.SetValue(origin, Array.CreateInstance(Field.FieldType.GetElementType() !, length));
 }
 /// <summary>
 /// Traverses only the namespace root of the given assembly, removing any type from the model that have the same
 /// interned key as one of the entries of this.typesToRemove.
 /// </summary>
 public override void TraverseChildren(IModule module)
 {
     this.Traverse(module.UnitNamespaceRoot);
 }
        public AutoCompleteSearchBehaviour(MainWindowViewModel target, ISchedulerContext schedulerContext, IExampleSearchProvider searchProvider, IModule module)
            : base(target)
        {
            _searchProvider = searchProvider;
            _module         = module;

            var searchTextObs = Target.WhenPropertyChanged(x => x.SearchText);

            searchTextObs.Skip(1).Subscribe(UpdateBlurEffect).DisposeWith(this);

            searchTextObs.Where(x => !String.IsNullOrEmpty(x))
            .Throttle(TimeSpan.FromMilliseconds(200), schedulerContext.Default)
            .Select(SearchExamples)
            .ObserveOn(schedulerContext.Dispatcher)
            .Subscribe(UpdateSearchResults)
            .DisposeWith(this);
        }
 public ModuleDisabledEvent(IModule module)
 {
     _pars = new Dictionary <string, object>();
     _pars.Add("Module", module);
 }
        /// <summary>
        /// Finds or downloads the module and creates a PEReader for it.
        /// </summary>
        /// <param name="module">module instance</param>
        /// <returns>reader or null</returns>
        internal PEReader GetPEReader(IModule module)
        {
            string   downloadFilePath = null;
            PEReader reader           = null;

            if (File.Exists(module.FileName))
            {
                // TODO - Need to verify the index timestamp/file size matches this local file
                downloadFilePath = module.FileName;
            }
            else
            {
                if (module.IndexTimeStamp.HasValue && module.IndexFileSize.HasValue)
                {
                    SymbolStoreKey key = PEFileKeyGenerator.GetKey(Path.GetFileName(module.FileName), module.IndexTimeStamp.Value, module.IndexFileSize.Value);
                    if (key is not null)
                    {
                        // Now download the module from the symbol server
                        downloadFilePath = SymbolService.DownloadFile(key);
                    }
                    else
                    {
                        Trace.TraceWarning($"GetPEReader: no index generated for module {module.FileName} ");
                    }
                }
                else
                {
                    Trace.TraceWarning($"GetPEReader: module {module.FileName} has no index timestamp/filesize");
                }
            }

            if (!string.IsNullOrEmpty(downloadFilePath))
            {
                Trace.TraceInformation("GetPEReader: downloaded {0}", downloadFilePath);
                Stream stream;
                try
                {
                    stream = File.OpenRead(downloadFilePath);
                }
                catch (Exception ex) when(ex is DirectoryNotFoundException || ex is FileNotFoundException || ex is UnauthorizedAccessException || ex is IOException)
                {
                    Trace.TraceError($"GetPEReader: OpenRead exception {ex.Message}");
                    return(null);
                }
                try
                {
                    reader = new PEReader(stream);
                    if (reader.PEHeaders == null || reader.PEHeaders.PEHeader == null)
                    {
                        Trace.TraceError($"GetPEReader: PEReader invalid headers");
                        return(null);
                    }
                }
                catch (Exception ex) when(ex is BadImageFormatException || ex is IOException)
                {
                    Trace.TraceError($"GetPEReader: PEReader exception {ex.Message}");
                    return(null);
                }
            }

            return(reader);
        }
Beispiel #50
0
        }        //end Exponent

        public Exponent(IModule source, float exponent)
            : base(source)
        {
            _exponent = exponent;
        }        //end Exponent
        private static Module GetCodeModelFromMetadataModelHelper(IMetadataHost host, IModule module,
                                                                  ISourceLocationProvider /*?*/ sourceLocationProvider, ILocalScopeProvider /*?*/ localScopeProvider, DecompilerOptions options)
        {
            Contract.Requires(host != null);
            Contract.Requires(module != null);
            Contract.Requires(!(module is Dummy));
            Contract.Ensures(Contract.Result <Module>() != null);

            var result   = new MetadataDeepCopier(host).Copy(module);
            var replacer = new ReplaceMetadataMethodBodiesWithDecompiledMethodBodies(host, sourceLocationProvider, localScopeProvider, options);

            replacer.Traverse(result);
            var finder = new HelperTypeFinder(host, sourceLocationProvider);

            finder.Traverse(result);
            Contract.Assume(finder.helperTypes != null);
            Contract.Assume(finder.helperMethods != null);
            Contract.Assume(finder.helperFields != null);
            var remover = new RemoveUnnecessaryTypes(finder.helperTypes, finder.helperMethods, finder.helperFields);

            remover.Traverse(result);
            result.AllTypes.RemoveAll(td => finder.helperTypes.ContainsKey(td.InternedKey)); // depends on RemoveAll preserving order
            return(result);
        }
Beispiel #52
0
 internal CachedModule(IModule inner)
 {
     _inner = inner;
 }
        public void StartModule(IModule module)
        {
            if (module.Started)
            {
                return;
            }

            var settings = module as ISettingsProvider;

            if (settings != null)
            {
                settings.SetSettingsHandle(Settings);
                SettingsList.Add(settings);
            }

            var requester = module as ISaveRequester;

            if (requester != null)
            {
                requester.SetSaveHandle(_saver);
            }

            var mapDataFinder = module as IMapDataFinder;

            if (mapDataFinder != null)
            {
                _mapDataFinders.Add(mapDataFinder);
            }

            var mapDataParser = module as IMapDataParser;

            if (mapDataParser != null)
            {
                _mapDataParsers.Add(mapDataParser);
            }

            var mapDataGetter = module as IMapDataGetter;

            if (mapDataGetter != null)
            {
                _mapDataGetters.Add(mapDataGetter);
            }
            var mainWindowUpdater = module as IMainWindowUpdater;

            if (mainWindowUpdater != null)
            {
                mainWindowUpdater.GetMainWindowHandle(MainWindowUpdater);
            }

            var SqliteUser = module as ISqliteUser;

            if (SqliteUser != null)
            {
                SqliteUser.SetSqliteControlerHandle(_sqliteControler);
            }

            var SettingsProvider = module as ISettingsGetter;

            if (SettingsProvider != null)
            {
                SettingsProvider.SetSettingsListHandle(SettingsList);
            }

            var mapDataReplacements = module as IMapDataReplacements;

            if (mapDataReplacements != null)
            {
                _mapDataReplacementSetters.Add(mapDataReplacements);
            }

            var SettingsGetter = module as ISettings;

            if (SettingsGetter != null)
            {
                SettingsGetter.SetSettingsHandle(Settings);
            }

            var modParser = module as IModParser;

            if (modParser != null)
            {
                this._modParser.Add(modParser);
            }

            var modParserGetter = module as IModParserGetter;

            if (modParserGetter != null)
            {
                modParserGetter.SetModParserHandle(this._modParser);
            }

            var msnGetter = module as IMsnGetter;

            if ((msnGetter) != null)
            {
                MsnGetters.Add(msnGetter);
            }

            if (module is IOsuEventSource osuEventSource)
            {
                _osuEventSources.Add(osuEventSource);
            }

            if (module is IHighFrequencyDataHandler handler)
            {
                _highFrequencyDataHandlers.Add(handler);
            }

            if (module is IHighFrequencyDataSender sender)
            {
                sender.SetHighFrequencyDataHandlers(_highFrequencyDataHandlers);
            }


            if (module is IExiter exiter)
            {
                if (module is IPlugin plugin)
                {
                    exiter.SetExitHandle((o) =>
                    {
                        string reason = "unknown";
                        try
                        {
                            reason = o.ToString();
                        }
                        catch { }
                        _logger.Log("Plugin {0} has requested StreamCompanion shutdown! due to: {1}", LogLevel.Basic, plugin.Name, reason);
                        Program.SafeQuit();
                    });
                }
                else
                {
                    exiter.SetExitHandle((o) =>
                    {
                        _logger.Log("StreamCompanion is shutting down", LogLevel.Basic);
                        Program.SafeQuit();
                    });
                }
            }

            module.Start(_logger);
        }
Beispiel #54
0
 public Abs(IModule source)
     : base(source)
 {
 }
Beispiel #55
0
        }        //end Exponent

        public Exponent(IModule source)
            : base(source)
        {
        }        //end Exponent
Beispiel #56
0
 internal ExecutionContext Clone(IModule module) => new ExecutionContext(this, module);
Beispiel #57
0
 public S_REGREL32(IServiceContainer ctx, IModule mod, SpanStream stream) : base(ctx, mod, stream)
 {
 }
        public void Compose(IModule module, Loader.IServiceRepository serviceContainer)
        {
            var    physicalFs       = serviceContainer.Get <IFileSystem>();
            var    contentDirectory = serviceContainer.Get <IContentDirectoryProvider>();
            string sqlitePath       = Path.Combine(contentDirectory.ApplicationData.FullName, "library.db");
            var    optionsBuilder   = new DbContextOptionsBuilder <DatabaseContext>();

            optionsBuilder
            .UseSqlite($"Data Source={sqlitePath}");

            using (var context = new DatabaseContext(optionsBuilder.Options))
            {
                var connection = context.Database.GetDbConnection();
                connection.Open();
                using var command   = connection.CreateCommand();
                command.CommandText = "PRAGMA journal_mode=WAL;";
                command.ExecuteNonQuery();
            }

            // game library dependency tree

            var gameRecordLibrary = new GameRecordLibrary(optionsBuilder);
            var gameLibrary       = new GameLibrary(gameRecordLibrary);
            var configStore       = new ConfigurationCollectionStore(optionsBuilder);

            var fileLibrary = new FileRecordLibrary(optionsBuilder);

            var appDataPath = physicalFs.ConvertPathFromInternal(contentDirectory.ApplicationData.FullName);
            var gameFs      = physicalFs.GetOrCreateSubFileSystem(appDataPath / "games");

            // Add default extensions
            gameLibrary.AddExtension <IGameFileExtensionProvider,
                                      IGameFileExtension>(new GameFileExtensionProvider(fileLibrary, gameFs));

            gameLibrary.AddExtension <IGameConfigurationExtensionProvider,
                                      IGameConfigurationExtension>(new GameConfigurationExtensionProvider(configStore));

            // register game library.
            serviceContainer.Get <IServiceRegistrationProvider>()
            .RegisterService <IGameLibrary>(gameLibrary);

            var pluginLibrary = new PluginConfigurationStore(optionsBuilder);

            // plugin config store

            serviceContainer.Get <IServiceRegistrationProvider>()
            .RegisterService <IPluginConfigurationStore>(pluginLibrary);

            // controller elements

            var inputStore = new ControllerElementMappingProfileStore(optionsBuilder);

            serviceContainer.Get <IServiceRegistrationProvider>()
            .RegisterService <IControllerElementMappingProfileStore>(inputStore);

            // ports
            var portStore = new EmulatedPortStore(optionsBuilder);

            serviceContainer.Get <IServiceRegistrationProvider>()
            .RegisterService <IEmulatedPortStore>(portStore);
        }
Beispiel #59
0
 public IModuleManager AddModule(IModule module)
 {
     Modules.Add(module, null);
     return(this);
 }
Beispiel #60
-1
 private void GenerateResponse(IModule module, HttpListenerContext context)
 {
     // Process the request then close the stream. All logic is delegated
     // to the supplied IModule implementer.
     module.Process(context.Response.OutputStream, context);
     context.Response.Close();
 }