internal bool ResolveComReferenceAx(ComReferenceInfo referenceInfo, string outputDirectory, string refName, out ComReferenceWrapperInfo wrapperInfo)
 {
     wrapperInfo = null;
     string key = ComReference.UniqueKeyFromTypeLibAttr(referenceInfo.attr);
     if (this.cacheAx.ContainsKey(key))
     {
         wrapperInfo = (ComReferenceWrapperInfo) this.cacheAx[key];
         return true;
     }
     try
     {
         AxReference reference = new AxReference(base.Log, this, referenceInfo, refName, outputDirectory, this.DelaySign, this.KeyFile, this.KeyContainer, this.IncludeVersionInInteropName, this.aximpPath, base.BuildEngine, this.EnvironmentVariables);
         if (!reference.FindExistingWrapper(out wrapperInfo, this.timestampCache[referenceInfo.typeLibPath]) && !reference.GenerateWrapper(out wrapperInfo))
         {
             return false;
         }
         this.cacheAx.Add(key, wrapperInfo);
     }
     catch (Exception exception)
     {
         if (Microsoft.Build.Shared.ExceptionHandling.NotExpectedException(exception))
         {
             throw;
         }
         return false;
     }
     return true;
 }
示例#2
0
        /// <summary>
        /// Helper function - resolves an ActiveX reference given the type library attributes.
        /// </summary>
        /// <param name="referenceInfo">Information about the reference to be resolved</param>
        /// <param name="outputDirectory">Directory the interop DLL should be written to</param>
        /// <param name="refName">Name of reference</param>
        /// <param name="wrapperInfo">Information about wrapper locations</param>
        /// <returns>True if the reference was already found or successfully generated, false otherwise.</returns>
        internal bool ResolveComReferenceAx(ComReferenceInfo referenceInfo, string outputDirectory, string refName, out ComReferenceWrapperInfo wrapperInfo)
        {
            wrapperInfo = null;
            string typeLibKey = ComReference.UniqueKeyFromTypeLibAttr(referenceInfo.attr);

            // look in the Ax cache first
            if (_cacheAx.ContainsKey(typeLibKey))
            {
                wrapperInfo = (ComReferenceWrapperInfo)_cacheAx[typeLibKey];
                return true;
            }

            try
            {
                // not in the cache? see if anyone was kind enough to generate it for us

                AxReference reference = new AxReference(Log, Silent, this, referenceInfo, refName, outputDirectory, DelaySign, KeyFile, KeyContainer, IncludeVersionInInteropName, _aximpPath, BuildEngine, EnvironmentVariables);

                // wrapper doesn't exist or needs regeneration? generate it then
                if (!reference.FindExistingWrapper(out wrapperInfo, _timestampCache[referenceInfo.strippedTypeLibPath]))
                {
                    if (!reference.GenerateWrapper(out wrapperInfo))
                        return false;
                }

                // if found or successfully generated, cache it.
                _cacheAx.Add(typeLibKey, wrapperInfo);
            }
            catch (Exception e) when (ExceptionHandling.IsIoRelatedException(e))
            {
                return false;
            }

            return true;
        }