|
/*
* Copyright � 2005-2006 Danilo Mendez <danilo.mendez@kontac.net>
* Adolfo Socorro <ajs@esolutionspr.com>
* www.kontac.net
* All rights reserved.
* Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence.
*/
namespace SmartCode.Studio.AssemblyCache
{
using System;
using System.Collections;
using System.Runtime.InteropServices;
using System.Text;
using SmartCode.Studio.Templates;
internal class CacheAssemblies
{
internal CacheAssemblies()
{
}
internal bool GetGACCache(ArrayList al)
{
if (this.GetGACCache(al, CacheFlags.CACHE_GAC))
{
return this.GetGACCache(al, CacheFlags.CACHE_ZAP);
}
return false;
}
private bool GetGACCache(ArrayList al, CacheFlags flags)
{
IAssemblyEnum assemblyEnum;
bool addAssembly = true;
if (Controllers.GetEnumerator(out assemblyEnum, IntPtr.Zero, IntPtr.Zero, flags, IntPtr.Zero) != 0)
{
return false;
}
IAssemblyName assemblyName = null;
int i = 0;
StringBuilder sbAssemblyName = new StringBuilder(0x100);
StringBuilder sbAssemblyQualifiedName = new StringBuilder(0x100);
while (true)
{
int iNext = assemblyEnum.GetNextAssembly(IntPtr.Zero, out assemblyName, 0);
if (iNext == 0)
{
addAssembly = true;
uint capacity = (uint) sbAssemblyName.Capacity;
assemblyName.GetName(ref capacity, sbAssemblyName);
uint capacity2 = (uint) sbAssemblyQualifiedName.Capacity;
assemblyName.GetDisplayName(sbAssemblyQualifiedName, ref capacity2, NameDisplayFlags.PUBLIC_KEY | NameDisplayFlags.VERSION | NameDisplayFlags.KEY_TOKEN | NameDisplayFlags.CULTURE);
LibraryInfo library = new LibraryInfo(sbAssemblyName.ToString(), sbAssemblyQualifiedName.ToString());
for (int j = 0; j < al.Count; j++)
{
if (((LibraryInfo)al[j]).AssemblyName == library.AssemblyName)
{
addAssembly = false;
break;
}
}
if (addAssembly)
{
al.Add(library);
i++;
}
Marshal.ReleaseComObject(assemblyName);
assemblyName = null;
}
if (iNext != 0)
{
return true;
}
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
Danilo is the creator of
SmartRules, a Business Rules Engine. He is an industry consultant working primarily with companies interested in implementing dynamic rules programming concepts to add flexibility to their architectures on web, CE, and desktop platforms. He operates his own website,
Kontac, where you will find more information.
To contact Danilo, email him at danilo.mendez@gmail.com.