Example #1
0
        public ExportBase ExportFactoryInit(ExportInfo exportInfo)
        {
            try
            {
                if (exportInfo != null)
                {
                    if (exportInfo.ReportDetails.ExportFormat == ReportingInterfaces.EnumHelper.ExportFormat.EXCEL.ToString())
                    {
                        export = new ExcelExport(exportInfo);
                    }
                    else if (exportInfo.ReportDetails.ExportFormat == ReportingInterfaces.EnumHelper.ExportFormat.CSV.ToString())
                    {
                        export = new CSVExport(exportInfo);
                    }
                    else if (exportInfo.ReportDetails.ExportFormat == ReportingInterfaces.EnumHelper.ExportFormat.HTML.ToString())
                    {
                        export = new HtmLExport(exportInfo);
                    }
                }
                else
                {
                    AMTLogger.WriteToLog("Export Info is null", MethodBase.GetCurrentMethod().Name, 0, AMTLogger.LogInfo.Info);
                }
            }
            catch (Exception ex)
            {
                AMTLogger.WriteToLog(ex.Message, MethodBase.GetCurrentMethod().Name, 0, AMTLogger.LogInfo.Error);
            }

            return(export);
        }
Example #2
0
        /// <summary>
        /// Generate an exported report
        /// </summary>
        /// <param name="Report">The report to run/param>
        /// <param name="newName">The name of the generated file</param>
        /// <param name="newDescription">The name of the generated description</param>
        /// <param name="timezoneName">the timezone the report will be evaluated in</param>
        /// <param name="exportFormat">The format for exporting</param>
        public static Document ExportTo(Report report, string newName, string newDescription, string timezoneName, ExportFormat exportFormat)
        {
            var settings = new ExportSettings
            {
                TimeZone = timezoneName,
                Format   = exportFormat
            };

            var exportInterface = Factory.Current.Resolve <IExportDataInterface>();

            ExportInfo exportInfo = null;

            try
            {
                exportInfo = exportInterface.ExportData(report.Id, settings);
            }
            catch (Exception ex)
            {
                throw new WorkflowRunException("Failed to run report", ex);
            }

            var extension    = ToExtension(exportFormat);
            var documentType = ToDocType(exportFormat);

            var doc = DocHelper.CreateDoc(exportInfo.FileHash, newName, newDescription, extension, documentType);

            return(doc);
        }
Example #3
0
        private String ExportForPreview()
        {
            String PreviewPath = Path.Combine(ApplicationInfo.ApplicationDocumentPath, "Preview");

            try
            {
                if (!Directory.Exists(PreviewPath))
                {
                    Directory.CreateDirectory(PreviewPath);
                }
                ExportInfo item = new ExportInfo()
                {
                    ReportDetails = new ReportInfo()
                    {
                        ExportFormat  = EnumHelper.ExportFormat.HTML.ToString(),
                        ReportName    = this.ReportCategory.ToString(),
                        GeneratorName = "Adminstrator",
                        ProductName   = "AMT",
                        ReportDate    = DateTime.Now.ToString(),
                        ExportPath    = PreviewPath
                    },
                    MachineInfo = wmimachineInfo
                };
                ReportObject.ExportReportData(item);

                PreviewPath = Path.Combine(PreviewPath, this.ReportCategory.ToString() + "." + item.ReportDetails.ExportFormat);
            }
            catch (Exception)
            {
                throw;
            }

            return(PreviewPath);
        }
        public void TestSetParametersWhenThereIsNoFolder()
        {
            SettingsStore store = SettingsStore.Default;

            SettingsStore.Default = new SettingsStore();

            ExportInfo info = new ExportInfo();

            info.Folder = "c:\\TestFolder_NotExistInSettings\\";

            Assert.AreEqual(0, SettingsStore.Default.FoldersToExport.Count);

            ExportControl control = new ExportControl();

            control.OnShowView();
            control.ApplyExportInfo(info);

            Assert.AreEqual(1, SettingsStore.Default.FoldersToExport.Count);
            Assert.AreEqual(info.Folder, SettingsStore.Default.FoldersToExport[0].Path);

            store.FoldersToExport.Add(new PathInfo()
            {
                Path = "c:\\SomeFolder\\"
            });
            info.Folder = "c:\\AnotherTestFolder_NotExist";
            control.ApplyExportInfo(info);
            Assert.AreEqual(2, SettingsStore.Default.FoldersToExport.Count);
            Assert.AreEqual(info.Folder, SettingsStore.Default.FoldersToExport[1].Path);

            Assert.AreEqual(2, control.FoldersListCombo.Properties.Items.Count);
            Assert.AreEqual(true, control.FoldersListCombo.Properties.Items.Contains(SettingsStore.Default.FoldersToExport[0]));
            Assert.AreEqual(true, control.FoldersListCombo.Properties.Items.Contains(SettingsStore.Default.FoldersToExport[1]));
        }
        public void TestSetParametersWhenThereIsNoRenameMask()
        {
            SettingsStore store = SettingsStore.Default;

            SettingsStore.Default = store;

            ExportInfo info = new ExportInfo();

            info.RenameMaskName = "MyMask";
            info.RenameMask     = "{FileName} - {Width}x{Height} - {Index} of {Count}.{Extension}";
            FileRenameManager.Default.Template = info.RenameMask;

            foreach (FileRenameValueReference fref in FileRenameManager.Default.TemplateValues)
            {
                info.FileRenameValues.Add(fref);
            }

            int           count   = SettingsStore.Default.FileRenameTemplates.Count;
            ExportControl control = new ExportControl();

            control.OnShowView();
            control.ApplyExportInfo(info);

            Assert.AreEqual(count + 1, SettingsStore.Default.FileRenameTemplates.Count);
            Assert.AreEqual(info.RenameMaskName, SettingsStore.Default.FileRenameTemplates[count].Name);
            Assert.AreEqual(info.RenameMask, SettingsStore.Default.FileRenameTemplates[count].Template);

            Assert.AreEqual(count + 1, control.FileRenameMaskCombo.Properties.Items.Count);
            for (int i = 0; i < SettingsStore.Default.FileRenameTemplates.Count; i++)
            {
                Assert.AreEqual(SettingsStore.Default.FileRenameTemplates[i], control.FileRenameMaskCombo.Properties.Items[i]);
            }

            Assert.AreEqual(11, control.KeywordsListBox.Items.Count);
        }
        public void CreateFileExporter_Always_ReturnFileExporter()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var context = new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext(new ObservableList <DuneLocationCalculationsForTargetProbability>(),
                                                                                                    new DuneErosionFailureMechanism(),
                                                                                                    assessmentSection);

            using (var plugin = new DuneErosionPlugin())
            {
                ExportInfo info = GetExportInfo(plugin);

                // Call
                IFileExporter fileExporter = info.CreateFileExporter(context, "test");

                // Assert
                Assert.IsInstanceOf <DuneLocationCalculationsExporter>(fileExporter);
            }

            mocks.VerifyAll();
        }
Example #7
0
        public static string ExportInfoToString(ExportInfo e)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(e.Index + "\t: \"" + e.Name + "\"");
            for (int i = 0; i < 10; i++)
            {
                if (e.Name.Length + 12 < i * 8)
                {
                    sb.AppendLine("\t");
                }
            }
            sb.AppendLine("Export:");
            switch (e.WayOfExport)
            {
            case 0:
                sb.Append(" not exported");
                break;

            case 1:
                sb.Append(" with asm jmp");
                break;

            case 2:
                sb.Append(" with call");
                break;

            case 3:
                sb.Append(" with link");
                break;
            }
            return(sb.ToString());
        }
Example #8
0
        private List <ExportInfo> PrepData(List <SystemInfo> systemInfoList)
        {
            var hrInfoQuery = from si
                              in systemInfoList
                              where si.Name == "HR"
                              select si;

            SystemInfo hrInfo = hrInfoQuery.ToList()[0];

            var nonHRInfoQuery = from si
                                 in systemInfoList
                                 where si.Name != "HR"
                                 select si;

            List <SystemInfo> systemsInfoList = nonHRInfoQuery.ToList();

            List <ExportInfo> exportInfoList = new List <ExportInfo>();
            ExportInfo        exportInfo;

            foreach (SystemInfo sysInfo in systemsInfoList)
            {
                exportInfo = new ExportInfo(sysInfo, hrInfo);
                exportInfoList.Add(exportInfo);
            }
            return(exportInfoList);
        }
        public void IsEnabled_CalculationsWithoutOutput_ReturnFalse()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new DuneErosionFailureMechanism();

            failureMechanism.SetDuneLocations(new[]
            {
                new TestDuneLocation()
            });
            var context = new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext(new ObservableList <DuneLocationCalculationsForTargetProbability>(),
                                                                                                    failureMechanism,
                                                                                                    assessmentSection);

            using (var plugin = new DuneErosionPlugin())
            {
                ExportInfo info = GetExportInfo(plugin);

                // Call
                bool isEnabled = info.IsEnabled(context);

                // Assert
                Assert.IsFalse(isEnabled);
            }

            mocks.VerifyAll();
        }
Example #10
0
        void UpdateAutoGeneratedModelsConfig(string autoGeneratedConfigFilePath)
        {
            var config = JsonHelper.Deserialize <ExportContract>(File.ReadAllText(autoGeneratedConfigFilePath));

            var assemblyName = Model.NamespaceNameForType + ".dll";
            var exportInfo   = config.ExportInfoList.FirstOrDefault(x => x.Assembly == assemblyName);

            if (exportInfo == null)
            {
                exportInfo = new ExportInfo
                {
                    Assembly         = assemblyName,
                    ExportClassNames = new List <string>()
                };

                config.ExportInfoList.Add(exportInfo);
            }

            var ns = Model.NamespaceNameForType;

            var ExportClassNames = exportInfo.ExportClassNames;

            TryAddIfNotExists(ExportClassNames, ns + "." + Model.DefinitionFormDataClassName);
            TryAddIfNotExists(ExportClassNames, ns + "." + Model.FormName + "FormDataSource");
            TryAddIfNotExists(ExportClassNames, ns + "." + Model.FormName + "FormRequest");

            TryAddIfNotExists(ExportClassNames, ns + "." + Model.FormName + "ListFormDataSource");
            TryAddIfNotExists(ExportClassNames, ns + "." + Model.FormName + "ListFormRequest");
            TryAddIfNotExists(ExportClassNames, ns + "." + Model.FormName + "ListFormData");

            Util.WriteFileIfContentNotEqual(autoGeneratedConfigFilePath, JsonHelper.Serialize(config));
        }
Example #11
0
        public void CreateFileExporter_Always_ReturnFileExporter()
        {
            // Setup
            var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike)
            {
                HydraulicBoundaryDatabase =
                {
                    Locations =
                    {
                        new HydraulicBoundaryLocation(1, "test", 0, 0)
                    }
                }
            };
            var          context  = new HydraulicBoundaryDatabaseContext(assessmentSection.HydraulicBoundaryDatabase, assessmentSection);
            const string filePath = "test";

            using (var plugin = new RiskeerPlugin())
            {
                ExportInfo info = GetExportInfo(plugin);

                // Call
                IFileExporter fileExporter = info.CreateFileExporter(context, filePath);

                // Assert
                Assert.IsInstanceOf <HydraulicBoundaryLocationCalculationsExporter>(fileExporter);
            }
        }
Example #12
0
        public void CreateFileExporter_WithContext_ReturnFileExporter()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var context = new WaveHeightCalculationsForUserDefinedTargetProbabilitiesGroupContext(
                new ObservableList <HydraulicBoundaryLocationCalculationsForTargetProbability>(), assessmentSection);

            const string filePath = "test";

            using (var plugin = new RiskeerPlugin())
            {
                ExportInfo info = GetExportInfo(plugin);

                // Call
                IFileExporter fileExporter = info.CreateFileExporter(context, filePath);

                // Assert
                Assert.IsInstanceOf <HydraulicBoundaryLocationCalculationsForTargetProbabilitiesExporter>(fileExporter);
            }

            mocks.VerifyAll();
        }
Example #13
0
        public void IsEnabled_ContextWithTargetProbabilities_ReturnsTrue()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var context = new WaveHeightCalculationsForUserDefinedTargetProbabilitiesGroupContext(
                new ObservableList <HydraulicBoundaryLocationCalculationsForTargetProbability>
            {
                new HydraulicBoundaryLocationCalculationsForTargetProbability(0.1)
            }, assessmentSection);

            using (var plugin = new RiskeerPlugin())
            {
                ExportInfo info = GetExportInfo(plugin);

                // Call
                bool isEnabled = info.IsEnabled(context);

                // Assert
                Assert.IsTrue(isEnabled);
            }

            mocks.VerifyAll();
        }
Example #14
0
    static public void Init()
    {
        ExportInfo oComponent = new ExportInfo(typeof(Component));

        oComponent.AddProperty("gameObject");
        oComponent.AddProperty("transform");
        oComponent.AddProperty("tag");
        _ExportClass.Add(oComponent);

        ExportInfo oGameObject = new ExportInfo(typeof(GameObject));

        oGameObject.AddProperty("activeInHierarchy");
        oGameObject.AddProperty("layer");
        oGameObject.AddProperty("transform");
        oGameObject.AddProperty("name");
        _ExportClass.Add(oGameObject);

        ExportInfo oTransforminfo = new ExportInfo(typeof(Transform));

        oTransforminfo.AddProperty("eulerAngles");
        oTransforminfo.AddProperty("forward");
        oTransforminfo.AddProperty("position");
        oTransforminfo.AddProperty("rotation");
        oTransforminfo.AddProperty("parent");
        _ExportClass.Add(oTransforminfo);

        ExportInfo oVector3info = new ExportInfo(typeof(Vector3));

        oVector3info.AddField("x");
        oVector3info.AddField("y");
        oVector3info.AddField("z");
        _ExportClass.Add(oVector3info);
    }
Example #15
0
        private static void ExportItem(ExportInfo exportInfo, object source)
        {
            string exportFilePath = exportInfo.GetExportPath();
            string exportInfoName = exportInfo.Name(source);

            if (exportFilePath != null)
            {
                log.InfoFormat(Resources.GuiExportHandler_ExportItemUsingDialog_Start_exporting_DataType_0_,
                               exportInfoName);

                IFileExporter exporter = exportInfo.CreateFileExporter(source, exportFilePath);

                if (exporter.Export())
                {
                    log.InfoFormat(Resources.GuiExportHandler_ExportItemUsingDialog_Data_exported_to_File_0, exportFilePath);
                    log.InfoFormat(Resources.GuiExportHandler_ExportItemUsingDialog_Export_of_DataType_0_successful,
                                   exportInfoName);
                }
                else
                {
                    log.ErrorFormat(Resources.GuiExportHandler_ExportItemUsingDialog_Export_of_DataType_0_failed,
                                    exportInfoName);
                }
            }
        }
Example #16
0
        private void Export_Click(object sender, EventArgs e)
        {
            try
            {
                String ExportPath = Path.Combine(ApplicationInfo.ApplicationDocumentPath, "Export");
                if (!Directory.Exists(ExportPath))
                {
                    Directory.CreateDirectory(ExportPath);
                }
                ExportDialog exportDialog = new ExportDialog(new ReportExportInfo()
                {
                    ReportName = this.ReportCategory.ToString(), ReportFormat = EnumHelper.ExportFormat.HTML.ToString(), FileLocation = ExportPath
                });
                if (exportDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    ExportInfo item = new ExportInfo()
                    {
                        ReportDetails = new ReportInfo()
                        {
                            ExportFormat = exportDialog.reportExportInfo.ReportFormat, ReportName = exportDialog.reportExportInfo.ReportName, GeneratorName = "Adminstrator", ProductName = "AMT", ReportDate = DateTime.Now.ToString(), ExportPath = exportDialog.txtLocation.Text
                        },
                        MachineInfo = wmimachineInfo
                    };

                    ReportObject.ExportReportData(item);

                    MessageBox.Show("Report exported successfully.");
                }
            }
            catch (Exception ex)
            {
                AMTLogger.WriteToLog(ex.Message, MethodBase.GetCurrentMethod().Name, 0, AMTLogger.LogInfo.Error);
            }
        }
Example #17
0
        public static List <ExportInfo> GetExports(string path)
        {
            infolist = new List <ExportInfo>();
            IntPtr hCurrentProcess = Process.GetCurrentProcess().Handle;
            ulong  baseOfDll;
            bool   status;

            status = SymInitialize(hCurrentProcess, null, false);
            if (status == false)
            {
                throw new Exception("Failed to initialize sym.");
            }
            baseOfDll = SymLoadModuleEx(hCurrentProcess, IntPtr.Zero, path, null, 0, 0, IntPtr.Zero, 0);
            if (baseOfDll == 0)
            {
                SymCleanup(hCurrentProcess);
                throw new Exception("Failed to load module.");
            }
            if (SymEnumerateSymbols64(hCurrentProcess, baseOfDll, EnumSyms, IntPtr.Zero) == false)
            {
                throw new Exception("Failed to enum symbols.");
            }
            SymCleanup(hCurrentProcess);
            for (int i = 0; i < infolist.Count; i++)
            {
                ExportInfo e = infolist[i];
                e.Index     = i;
                infolist[i] = e;
            }
            return(infolist);
        }
Example #18
0
        bool IWMIInit.ExportData(ExportInfo ExportInfo)
        {
            Boolean result = false;

            try
            {
                if (InputConnectionInfo.DatabaseConnectionInfo.DatabaseType == EnumHelper.Databases.SQLServer)
                {
                    dbExportBase = new DataCollection.SqlReportExport(ExportInfo);
                }

                else if (InputConnectionInfo.DatabaseConnectionInfo.DatabaseType == EnumHelper.Databases.SQLServerCE)
                {
                    dbExportBase = new DataCollection.SqlCeReportExport(ExportInfo);
                }

                //dbExportBase.exportInfo = ExportInfo;


                dbExportBase.DatabaseConnect();

                dbExportBase.ExportReportData();

                dbExportBase.DatabaseDisConnect();
            }
            catch (Exception ex)
            {
                AMTLogger.WriteToLog(ex.Message, MethodBase.GetCurrentMethod().Name, 0, AMTLogger.LogInfo.Error);
            }


            return(result);
        }
Example #19
0
        public static bool EnumSyms(string name, ulong address, uint size, IntPtr context)
        {
            ExportInfo ex = new ExportInfo();

            ex.Name = name;
            infolist.Add(ex);
            return(true);
        }
Example #20
0
        private static string GetItemName(ExportInfo exportInfo, object source)
        {
            string exportInfoName = exportInfo.Name(source);

            return(exportInfo.Extension != null
                       ? string.Format(Resources.GetItemName_Name_0_FileExtension_1, exportInfoName, exportInfo.Extension)
                       : exportInfoName);
        }
        /// <summary>
        ///     Pack the export data info.
        /// </summary>
        /// <param name="exportInfo">ExportInfo</param>
        /// <returns>
        ///     ExportDataInfo
        /// </returns>
        private static ExportDataInfo PackResult(ExportInfo exportInfo)
        {
            var result = new ExportDataInfo
            {
                FileHash        = exportInfo.FileHash,
                ResponseMessage = exportInfo.ResponseMessage
            };

            return(result);
        }
        public static IServiceCollection AddExportInfo(
            this IServiceCollection services,
            IConfiguration configuration)
        {
            var exportInfo = new ExportInfo();

            configuration.GetSection(nameof(ExportInfo)).Bind(exportInfo);
            services.AddSingleton(exportInfo);
            return(services);
        }
Example #23
0
        public void ExportFrom(object source)
        {
            ExportInfo exportInfo = GetSupportedExportInfoUsingDialog(source);

            if (exportInfo == null)
            {
                return;
            }

            ExportItem(exportInfo, source);
        }
Example #24
0
    public static void GetTypes()
    {
        string             sAll  = "";
        List <XMLTypeInfo> aList = new List <XMLTypeInfo>();

        foreach (var item in m_ExportClass)
        {
            XMLTypeInfo otypeinfo = new XMLTypeInfo(item);
            otypeinfo.stype         = item.type.FullName.Replace(".", "::");
            otypeinfo.sNameScpeace  = item.type.Assembly.GetName().Name;
            otypeinfo.sBase         = item.type.BaseType.FullName.Replace(".", "::");
            otypeinfo.bIsRefType    = (!item.type.IsValueType).ToString().ToLower();
            otypeinfo.IsCustomized  = true.ToString().ToLower();
            otypeinfo.IsImplemented = true.ToString().ToLower();
            otypeinfo.sDisplayName  = item.type.Name;
            otypeinfo.sDesc         = item.type.Name;
            aList.Add(otypeinfo);
        }

        foreach (var otypeinfo in aList)
        {
            ExportInfo oExportinfo = otypeinfo.exportinfo;
            foreach (var propertyname in oExportinfo.propertynamelist)
            {
                XMLMemberInfo oinfo    = new XMLMemberInfo();
                var           property = oExportinfo.type.GetProperty(propertyname);
                oinfo.Name         = property.Name;
                oinfo.DisplayName  = property.Name;
                oinfo.Desc         = property.Name;
                oinfo.Type         = GetMemberTypeName(property.PropertyType);
                oinfo.TypeFullName = GetMemberFullTypeName(property.PropertyType);
                oinfo.Class        = otypeinfo.stype;
                oinfo.Public       = property.CanRead.ToString().ToLower();
                otypeinfo.AddMemberInfo(oinfo);
            }

            foreach (var propertyname in oExportinfo.fieldnamelist)
            {
                XMLMemberInfo oinfo    = new XMLMemberInfo();
                var           property = oExportinfo.type.GetField(propertyname);
                oinfo.Name         = property.Name;
                oinfo.DisplayName  = property.Name;
                oinfo.Desc         = property.Name;
                oinfo.Type         = GetMemberTypeName(property.FieldType);
                oinfo.TypeFullName = GetMemberFullTypeName(property.FieldType);
                oinfo.Class        = otypeinfo.stype;
                oinfo.Public       = property.IsPublic.ToString().ToLower();
                otypeinfo.AddMemberInfo(oinfo);
            }
            sAll += otypeinfo.tostring();
        }
        Debug.LogError(sAll);
    }
Example #25
0
        /// <summary>
        /// Export script to filesystem
        /// </summary>
        /// <param name="rootPath">Root directory for export.</param>
        /// <param name="clearDirectory">Clear directory before export</param>
        public FileExporter(
            ExportInfo exportSetting,
            ILogger <FileExporter> logger)
        {
            _exportSetting = exportSetting;
            _logger        = logger;

            if (!CheckPath(_exportSetting.Patch))
            {
                throw new DirectoryNotFoundException(_exportSetting.Patch);
            }
        }
Example #26
0
File: Exports.cs Project: zzfeed/pe
        public static async Task <Exports> GetAsync(PortableExecutableImage image, ExportDirectory directory, ExportTable <uint> functionAddresses, ExportTable <uint> nameAddresses, ExportTable <ushort> ordinals)
        {
            var calc           = image.GetCalculator();
            var stream         = image.GetStream();
            var dataDirectory  = image.NTHeaders.DataDirectories[DataDirectoryType.ExportTable];
            var infos          = new List <ExportInfo>();
            var currentOrdinal = directory.Base;

            foreach (var address in functionAddresses)
            {
                var info = new ExportInfo()
                {
                    Address = address,
                    Ordinal = currentOrdinal
                };

                if (address >= dataDirectory.VirtualAddress && address <= (dataDirectory.VirtualAddress + dataDirectory.Size))
                {
                    var offset = calc.RVAToOffset(address).ToInt64();

                    info.ForwardName = await GetStringAsync(stream, offset).ConfigureAwait(false);
                }

                infos.Add(info);

                currentOrdinal++;
            }

            for (var i = 0; i < nameAddresses.Count; i++)
            {
                var nameAddress = nameAddresses[i];
                var ordinal     = ordinals[i];
                var offset      = calc.RVAToOffset(nameAddress).ToInt64();
                var info        = infos[ordinal];

                info.NameAddress = nameAddress;
                info.Name        = await GetStringAsync(stream, offset);
            }

            var exports = new List <Export>(infos.Count);

            foreach (var info in infos)
            {
                var export = new Export(info.Address, info.Name, info.Ordinal, info.ForwardName);

                exports.Add(export);
            }

            var result = new Exports(exports.OrderBy(e => e.Ordinal), directory, functionAddresses, nameAddresses, ordinals);

            return(result);
        }
Example #27
0
        public void TestSerialization()
        {
            SettingsStore store = SettingsStore.Default;

            SettingsStore.Default = new SettingsStore();

            ExportInfo info = new ExportInfo();

            info.FileRenameValues.Clear();

            FileRenameValueProperty prop   = (FileRenameValueProperty)FileRenameManager.Default.GetFileRenameValue("Caption");
            FileRenameValueCustom   custom = (FileRenameValueCustom)FileRenameManager.Default.GetFileRenameValue("CustomText");
            FileRenameValueIndex    index  = (FileRenameValueIndex)FileRenameManager.Default.GetFileRenameValue("Index");
            FileRenameValueCount    count  = (FileRenameValueCount)FileRenameManager.Default.GetFileRenameValue("Count");

            index.StartIndex = 99;

            FileRenameValueReference       propRef    = prop.CreateReference();
            FileRenameValueReferenceString propCustom = (FileRenameValueReferenceString)custom.CreateReference();
            FileRenameValueReference       propIndex  = index.CreateReference();
            FileRenameValueReference       propCount  = count.CreateReference();

            Assert.AreEqual("Caption", propRef.FileRenameValueName);
            Assert.AreEqual("CustomText", propCustom.FileRenameValueName);
            Assert.AreEqual("Index", propIndex.FileRenameValueName);
            Assert.AreEqual("Count", propCount.FileRenameValueName);

            propCustom.Text = "My Custom String";

            info.FileRenameValues.Add(propRef);
            info.FileRenameValues.Add(propCustom);
            info.FileRenameValues.Add(propIndex);
            info.FileRenameValues.Add(propCount);

            SettingsStore.Default.ExportPresets.Add(info);
            SettingsStore.Default.SaveToXml();

            SettingsStore.Default.ExportPresets.Clear();
            SettingsStore.Default.RestoreFromXml();

            Assert.AreEqual(1, SettingsStore.Default.ExportPresets.Count);
            ExportInfo info2 = SettingsStore.Default.ExportPresets[0];

            Assert.AreEqual(info.FileRenameValues.Count, info2.FileRenameValues.Count);
            for (int i = 0; i < info.FileRenameValues.Count; i++)
            {
                Assert.AreEqual(info.FileRenameValues[i].GetType(), info2.FileRenameValues[i].GetType());
                Assert.AreEqual(info.FileRenameValues[i].FileRenameValue.GetType(), info2.FileRenameValues[i].FileRenameValue.GetType());
            }
            SettingsStore.Default = store;
        }
        public void DryIoc_can_consume_catalog()
        {
            var registrations = new List <ExportedRegistrationInfo>();

            ComposablePartCatalog catalog = new TypeCatalog(typeof(Yes), typeof(No), typeof(Ok));

            foreach (var part in catalog.Parts)
            {
                var creationInfoField = part.GetType().GetMembers(t => t.DeclaredFields)
                                        .FirstOrDefault(f => f.Name == "_creationInfo")
                                        .ThrowIfNull();
                var creationInfo = creationInfoField.GetValue(part);

                var getPartMethod = creationInfo.GetType().GetMembers(t => t.DeclaredMethods)
                                    .FirstOrDefault(m => m.Name == "GetPartType")
                                    .ThrowIfNull();

                var implementationType = (Type)getPartMethod.Invoke(creationInfo, ArrayTools.Empty <object>());

                ExportInfo[] exports = null;
                foreach (var exportDefinition in part.ExportDefinitions)
                {
                    //string serviceTypeFullName = null;
                    //object exportTypeObject;
                    //if (exportDefinition.Metadata.TryGetValue(CompositionConstants.ExportTypeIdentityMetadataName, out exportTypeObject))
                    //    serviceTypeFullName = (string)exportTypeObject;
                    //var contractName = exportDefinition.ContractName;
                    //var serviceKey = string.Equals(contractName, serviceTypeFullName) ? null : contractName;
                    //var export = new ExportInfo(null, serviceKey) { ServiceTypeFullName = serviceTypeFullName };

                    var serviceInfo = GetServiceorDefault(exportDefinition);
                    var export      = new ExportInfo(serviceInfo.ServiceType, serviceInfo.Details.ServiceKey);

                    exports = exports.AppendOrUpdate(export);
                }

                var registration = new ExportedRegistrationInfo
                {
                    ImplementationType = implementationType,
                    Exports            = exports
                };

                registrations.Add(registration);
            }

            var container = new Container().WithMefAttributedModel();

            container.RegisterExports(registrations);

            container.Resolve <IAnswer <Ok> >();
        }
Example #29
0
        public void Name_Always_ReturnsName()
        {
            // Setup
            using (var plugin = new RiskeerPlugin())
            {
                ExportInfo info = GetExportInfo(plugin);

                // Call
                string name = info.Name(null);

                // Assert
                Assert.AreEqual("Referentielijn", name);
            }
        }
Example #30
0
        public void Name_Always_ReturnsName()
        {
            // Setup
            using (var plugin = new RiskeerPlugin())
            {
                ExportInfo info = GetExportInfo(plugin);

                // Call
                string name = info.Name(null);

                // Assert
                Assert.AreEqual("Golfhoogten bij vrije doelkans", name);
            }
        }
Example #31
0
 public override void ExportProcess(DrawArgs drawArgs, ExportInfo expInfo)
 {
     using (System.Drawing.Image oBitmap = System.Drawing.Image.FromFile(_imagePath))
     {
         int iWidth = (int)Math.Round((this.maxLon - this.minLon) * (double)expInfo.iPixelsX / (expInfo.dMaxLon - expInfo.dMinLon));
         int iHeight = (int)Math.Round((this.maxLat - this.minLat) * (double)expInfo.iPixelsY / (expInfo.dMaxLat - expInfo.dMinLat));
         int iX = (int)Math.Round((this.minLon - expInfo.dMinLon) * (double)expInfo.iPixelsX / (expInfo.dMaxLon - expInfo.dMinLon));
         int iY = (int)Math.Round((expInfo.dMaxLat - this.maxLat) * (double)expInfo.iPixelsY / (expInfo.dMaxLat - expInfo.dMinLat));
         expInfo.gr.DrawImage(oBitmap, new System.Drawing.Rectangle(iX, iY, iWidth, iHeight));
     }
 }
Example #32
0
 public virtual void ExportProcess(DrawArgs drawArgs, ExportInfo expInfo)
 {
 }
Example #33
0
 public virtual void InitExportInfo(DrawArgs drawArgs, ExportInfo info)
 {
 }
Example #34
0
 public override void InitExportInfo(DrawArgs drawArgs, ExportInfo info)
 {
     //Update(drawArgs);
      lock (((System.Collections.IDictionary)m_topmostTiles).SyncRoot)
      {
     foreach (long key in m_topmostTiles.Keys)
     {
        QuadTile qt = (QuadTile)m_topmostTiles[key];
        qt.InitExportInfo(drawArgs, info);
     }
      }
 }
Example #35
0
 public override void InitExportInfo(DrawArgs drawArgs, ExportInfo info)
 {
     foreach (RenderableObject oRO in this.ChildObjects)
      {
     if (oRO.Initialized && oRO.IsOn)
        oRO.InitExportInfo(drawArgs, info);
      }
 }