Esempio n. 1
0
        static AddinRecord ToPersistentObject(AddinResolution adnResolution)
        {
            if (adnResolution.AddinId.Uid == UidStorage.InvalidAddinUid)
            {
                adnResolution.AddinId.Uid = UidStorage.GetNextAddinUid();
            }

            var addinFilePack  = ToAddinFilePack(adnResolution);
            var addinHeader    = ToPersistentObject(adnResolution.AddinHeader);
            var addinActivator = adnResolution.AddinActivator == null ? null : adnResolution.AddinActivator.ToRecord();
            var addinRecord    = new AddinRecord(addinHeader, addinFilePack, addinActivator)
            {
                Enabled = adnResolution.Enabled
            };

            if (adnResolution.ReferencedAssemblySets != null)
            {
                foreach (var referencedAssemblySet in adnResolution.ReferencedAssemblySets)
                {
                    addinRecord.AddReferencedAssembly(new ReferencedAssemblyRecord
                    {
                        Uid     = referencedAssemblySet.Uid,
                        Version = referencedAssemblySet.Version
                    });
                }
            }

            if (adnResolution.ExtendedAddins != null)
            {
                foreach (var extendedAddin in adnResolution.ExtendedAddins)
                {
                    addinRecord.AddExtendedAddin(new ExtendedAddinRecord
                    {
                        Uid     = extendedAddin.AddinId.Uid,
                        Version = extendedAddin.AddinHeader.Version
                    });
                }
            }

            if (adnResolution.ExtendedExtensionPoints != null)
            {
                foreach (var extendedExtensionPoint in adnResolution.ExtendedExtensionPoints)
                {
                    addinRecord.AddExtendedExtensionPoint(extendedExtensionPoint.Uid);
                }
            }

            if (adnResolution.ExtensionPoints != null)
            {
                foreach (var extensionPoint in adnResolution.ExtensionPoints)
                {
                    var epRecord = extensionPoint.ToRecord();
                    addinRecord.AddExtensionPoint(epRecord);
                }
            }

            if (adnResolution.ExtensionBuilderGroups != null)
            {
                foreach (var extensionBuilderGroup in adnResolution.ExtensionBuilderGroups)
                {
                    addinRecord.AddExtensionBuilderGroup(extensionBuilderGroup.ToRecord());
                }
            }

            if (adnResolution.ExtensionGroups != null)
            {
                foreach (var extensionGroup in adnResolution.ExtensionGroups)
                {
                    addinRecord.AddExtensionGroup(extensionGroup.ToRecord());
                }
            }

            return(addinRecord);
        }
 public bool TryGetAddin(ObjectId addinId, out AddinResolution addin)
 {
     return(_guid2Addins.TryGetValue(addinId.Guid, out addin));
 }
Esempio n. 3
0
 public void RegisterAddin(ObjectId addinId, AddinResolution addin)
 {
     _guid2Addins.Add(addinId.Guid, addin);
 }
Esempio n. 4
0
 public bool TryRegisterAddin(IMessageDialog dialog, ObjectId addinId, AddinResolution newAddin, out AddinResolution existingAddin)
 {
     if (_guid2Addins.TryGetValue(addinId.Guid, out existingAddin))
     {
         dialog.AddError(string.Format("An addin with the identity [{0}] already exists!", addinId.Guid));
         return(false);
     }
     _guid2Addins.Add(addinId.Guid, newAddin);
     return(true);
 }
Esempio n. 5
0
 /// <summary>
 /// Tries to get an type that defined in an addin.
 /// </summary>
 public bool TryGetAddinType(AddinResolution addin, string typeName, out TypeResolution type)
 {
     return(DoTryGetAddinType(addin, typeName, false, out type));
 }
Esempio n. 6
0
        /// <summary>
        /// Gets an type that defined in an addin.
        /// </summary>
        public TypeResolution GetAddinType(AddinResolution addin, string typeName)
        {
            TypeResolution result;

            return(DoTryGetAddinType(addin, typeName, false, out result) ? result : null);
        }
Esempio n. 7
0
        // @return: whether there is collisions.
        protected bool TryRegisterAssets(IMessageDialog dialog, ResolutionContext ctx, AddinResolution adnResolution,
                                         AddinCollision addinCollision)
        {
            var success = true;

            if (adnResolution.Assemblies != null)
            {
                foreach (var asm in adnResolution.Assemblies)
                {
                    ctx.TryRegisterAssembly(dialog, asm);
                }
            }

            if (adnResolution.ExtensionPoints != null)
            {
                foreach (var extensionPoint in adnResolution.ExtensionPoints)
                {
                    ExtensionPointResolution existingExtensionPoint;
                    if (!ctx.TryRegisterExtensionPoint(dialog, extensionPoint, out existingExtensionPoint))
                    {
                        var key = new ExtensionPointCollisionKey(existingExtensionPoint.Id);
                        addinCollision.Add(key, adnResolution, existingExtensionPoint.DeclaringAddin);
                        success = false;
                    }
                }
            }

            // get all extension builders defined under extension point and extension builder set
            var extensionBuilders = adnResolution.GetAllExtensionBuilders();

            if (extensionBuilders != null)
            {
                foreach (var extensionBuilder in extensionBuilders)
                {
                    if (extensionBuilder.ExtensionBuilderKind == ExtensionBuilderKind.Referenced)
                    {
                        continue;
                    }
                    ExtensionBuilderResolution existingExtensionBuilder;
                    if (!ctx.TryRegisterExtensionBuilder(dialog, extensionBuilder, out existingExtensionBuilder))
                    {
                        var key = new ExtensionBuilderCollisionKey(existingExtensionBuilder.Id);
                        addinCollision.Add(key, adnResolution, existingExtensionBuilder.DeclaringAddin);
                        success = false;
                    }
                }
            }

            var extensions = adnResolution.GetAllExtensions();

            if (extensions != null)
            {
                foreach (var extension in extensions)
                {
                    ExtensionResolution existingExtension;
                    if (!ctx.TryRegisterExtension(dialog, extension, out existingExtension))
                    {
                        var key = new ExtensionCollisionKey(existingExtension.Head.Path);
                        addinCollision.Add(key, adnResolution, existingExtension.DeclaringAddin);
                        success = false;
                    }
                }
            }

            return(success);
        }
Esempio n. 8
0
 void UnregisterAddin(ResolutionContext ctx, AddinResolution adnResolution)
 {
     ctx.UnregisterAddin(adnResolution.AddinId);
 }
Esempio n. 9
0
        protected bool TryRegisterAddin(IMessageDialog dialog, ResolutionContext ctx, AddinResolution adnResolution,
                                        AddinCollision addinCollision)
        {
            AddinResolution existingAddin;

            if (ctx.TryRegisterAddin(dialog, adnResolution.AddinId, adnResolution, out existingAddin))
            {
                return(true);
            }
            var key = new AddinCollisionKey(existingAddin.Guid);

            addinCollision.Add(key, adnResolution, existingAddin);
            return(false);
        }