/// <summary>
 /// The action taken on application initialization.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="eventArgs">The event args.</param>
 private void OnApplicationInitialized(object sender, EventArgs eventArgs)
 {
     SingleServerService service = ExternalServiceRegistry.GetService(ExternalServices.BuiltInExternalServices.IFCExporterService) as SingleServerService;
     if (service != null)
     {
         Exporter exporter = new Exporter();
         service.AddServer(exporter);
         service.SetActiveServer(exporter.GetServerId());
     }
     // TODO log this failure accordingly
 }
        /// <summary>
        /// Initializes property sets.
        /// </summary>
        /// <param name="propertySetsToExport">Existing functions to call for property set initialization.</param>
        /// <param name="fileVersion">The IFC file version.</param>
        public static void InitPropertySets(Exporter.PropertySetsToExport propertySetsToExport, IFCVersion fileVersion)
        {
            ParameterCache cache = ExporterCacheManager.ParameterCache;

            ExportSchema = fileVersion; // set the variable accordingly

            if (ExporterCacheManager.ExportOptionsCache.PropertySetOptions.ExportIFCCommon)
            {
                if (propertySetsToExport == null)
                    propertySetsToExport = InitCommonPropertySets;
                else
                    propertySetsToExport += InitCommonPropertySets;
            }

            if (ExporterCacheManager.ExportOptionsCache.PropertySetOptions.ExportSchedulesAsPsets)
            {
                if (propertySetsToExport == null)
                    propertySetsToExport = InitCustomPropertySets;
                else
                    propertySetsToExport += InitCustomPropertySets;
            }

            if (ExporterCacheManager.ExportOptionsCache.PropertySetOptions.ExportUserDefinedPsets)
            {
                if (propertySetsToExport == null)
                    propertySetsToExport = InitUserDefinedPropertySets;
                else
                    propertySetsToExport += InitUserDefinedPropertySets;
            }

            if (ExportSchema == IFCVersion.IFCCOBIE)
            {
                if (propertySetsToExport == null)
                    propertySetsToExport = InitCOBIEPropertySets;
                else
                    propertySetsToExport += InitCOBIEPropertySets;
            }

            if (propertySetsToExport != null)
                propertySetsToExport(cache.PropertySets, ExportSchema);
        }
        /// <summary>
        /// Initializes property sets.
        /// </summary>
        /// <param name="propertySetsToExport">Existing functions to call for property set initialization.</param>
        public static void InitPropertySets(Exporter.PropertySetsToExport propertySetsToExport)
        {
            ParameterCache cache = ExporterCacheManager.ParameterCache;


            if (ExporterCacheManager.ExportOptionsCache.PropertySetOptions.ExportIFCCommon)
            {
                if (propertySetsToExport == null)
                    propertySetsToExport = InitCommonPropertySets;
                else
                    propertySetsToExport += InitCommonPropertySets;
            }

            if (ExporterCacheManager.ExportOptionsCache.PropertySetOptions.ExportSchedulesAsPsets)
            {
                if (propertySetsToExport == null)
                    propertySetsToExport = InitCustomPropertySets;
                else
                    propertySetsToExport += InitCustomPropertySets;
            }

            if (ExporterCacheManager.ExportOptionsCache.PropertySetOptions.ExportUserDefinedPsets)
            {
                if (propertySetsToExport == null)
                    propertySetsToExport = InitUserDefinedPropertySets;
                else
                    propertySetsToExport += InitUserDefinedPropertySets;
            }

            if (ExporterCacheManager.ExportOptionsCache.ExportAsCOBIE)
            {
                if (propertySetsToExport == null)
                    propertySetsToExport = InitCOBIEPropertySets;
                else
                    propertySetsToExport += InitCOBIEPropertySets;
            }

            if (propertySetsToExport != null)
                propertySetsToExport(cache.PropertySets);
        }
        /// <summary>
        /// Initializes quantities.
        /// </summary>
        /// <param name="fileVersion">The IFC file version.</param>
        /// <param name="exportBaseQuantities">True if export base quantities.</param>
        public static void InitQuantities(Exporter.QuantitiesToExport quantitiesToExport, bool exportBaseQuantities)
        {
            ParameterCache cache = ExporterCacheManager.ParameterCache;

            if (exportBaseQuantities)
            {
                if (quantitiesToExport == null)
                    quantitiesToExport = InitBaseQuantities;
                else
                    quantitiesToExport += InitBaseQuantities;
            }

            if (ExporterCacheManager.ExportOptionsCache.ExportAsCOBIE)
            {
                if (quantitiesToExport == null)
                    quantitiesToExport = InitCOBIEQuantities;
                else
                    quantitiesToExport += InitCOBIEQuantities;
            }

            if (quantitiesToExport != null)
                quantitiesToExport(cache.Quantities);
        }
        /// <summary>
        /// Initializes quantities.
        /// </summary>
        /// <param name="fileVersion">The IFC file version.</param>
        /// <param name="exportBaseQuantities">True if export base quantities.</param>
        public static void InitQuantities(Exporter.QuantitiesToExport quantitiesToExport, IFCVersion fileVersion, bool exportBaseQuantities)
        {
            ParameterCache cache = ExporterCacheManager.ParameterCache;

            ExportSchema = fileVersion; // set the variable accordingly

            if (exportBaseQuantities)
            {
                if (quantitiesToExport == null)
                    quantitiesToExport = InitBaseQuantities;
                else
                    quantitiesToExport += InitBaseQuantities;
            }

            if (ExportSchema == IFCVersion.IFCCOBIE)
            {
                if (quantitiesToExport == null)
                    quantitiesToExport = InitCOBIEQuantities;
                else
                    quantitiesToExport += InitCOBIEQuantities; 
            }

            if (quantitiesToExport != null)
                quantitiesToExport(cache.Quantities, fileVersion);
        }