/// <summary>
        /// Runs any initialization code required on plug-ins
        /// </summary>
        /// <param name="addinPath">The path to the add-in that is calling this setup (typically acquired using GetType().Assembly.Location)</param>
        public static void ConfigurePlugIns(string addinPath)
        {
            if (UseDetachedAppDomain)
            {
                CrossDomain.ConfigurePlugIns(addinPath);
            }
            else
            {
                // This is usually run for the ComRegister function

                // *********************************************************************************
                //
                // WARNING:
                //
                //   If SolidWorks is loading our add-ins and we have multiple that use SolidDna
                //   it loads and makes use of the existing AngelSix.SolidDna.dll file from
                //   the first add-in loaded and shares it for all future add-ins
                //
                //   This results in any static instances being shared and only one version
                //   of SolidDna being usable on an individual SolidWorks instance
                //
                //   I am not sure of the reason for this but I feel it is a bug in SolidWorks
                //   as changing the GUID of the AngelSix.SolidDna.dll assembly and its
                //   Assembly and File versions doesn't change what gets loaded by SolidWorks
                //
                //   Perhaps when we make this a NuGet package the way it references may
                //   make it work. Until then the only thing to keep in mind is any
                //   static values inside the AngelSix.SolidDna class could be shared between
                //   add-ins so things like PlugIns list will come in here initially at this
                //   point with the last PlugIns list from the previous add-in. This is not an
                //   issue here as we override it straight away before making use of it,
                //   but it is something to bare in mind until we find a better solution
                //
                //
                // *********************************************************************************

                // Try and find the title from the first plug-in found
                var plugins = SolidDnaPlugIns(addinPath, loadAll: true);
                var firstPlugInWithTitle = plugins.FirstOrDefault(f => !string.IsNullOrEmpty(f.AddInTitle));

                if (firstPlugInWithTitle != null)
                {
                    AddInIntegration.SolidWorksAddInTitle       = firstPlugInWithTitle.AddInTitle;
                    AddInIntegration.SolidWorksAddInDescription = firstPlugInWithTitle.AddInDescription;
                }

                // Load all plug-in's at this stage for faster lookup
                PlugIns = SolidDnaPlugIns(addinPath);
            }
        }
        /// <summary>
        /// Runs any initialization code reqiured on plug-ins
        /// </summary>
        public static void ConfigurePlugIns()
        {
            if (mCrossDomain != null)
            {
                mCrossDomain.ConfigurePlugIns();
            }
            else
            {
                // This is usually run for the ComRegister function

                // Try and find the title from the first plug-in found
                var plugins = PlugInIntegration.SolidDnaPlugIns(loadAll: true);
                if (plugins.Count > 0)
                {
                    AddInIntegration.SolidWorksAddInTitle       = plugins.First().AddInTitle;
                    AddInIntegration.SolidWorksAddInDescription = plugins.First().AddInDescription;
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Runs any initialization code required on plug-ins
        /// </summary>
        public static void ConfigurePlugIns()
        {
            if (UseDetachedAppDomain)
            {
                CrossDomain.ConfigurePlugIns();
            }
            else
            {
                // This is usually run for the ComRegister function

                // Try and find the title from the first plug-in found
                var plugins = SolidDnaPlugIns(loadAll: true);
                if (plugins.Count > 0)
                {
                    AddInIntegration.SolidWorksAddInTitle       = plugins.First().AddInTitle;
                    AddInIntegration.SolidWorksAddInDescription = plugins.First().AddInDescription;
                }

                // Load all plug-in's at this stage for faster lookup
                PlugIns = SolidDnaPlugIns();
            }
        }