Ejemplo n.º 1
0
        private AssemblyClone InternalLoad(string path)
        {
            var assembly = Assembly.Load(AssemblyName.GetAssemblyName(path));
            var clone    = new AssemblyClone(assembly);

            return(clone);
        }
Ejemplo n.º 2
0
        private AssemblyClone InternalLoad(AssemblyName assemblyName)
        {
            var assembly = Assembly.Load(assemblyName);
            var clone    = new AssemblyClone(assembly);

            return(clone);
        }
Ejemplo n.º 3
0
        public static string GetFrameworkVersion(this AssemblyClone assembly)
        {
            // .NETFramework,Version=v4.0

            var framework = assembly.GetFramework();
            var version   = framework.RegexGet(@".*?(?<version>\d+\.?\d*)", "version");

            return(version);
        }
Ejemplo n.º 4
0
        public static string GetGACLocation(this AssemblyClone assembly)
        {
            // Hydra.DesktopDebuggingAgent\v4.0_1.0.0.0__4c46114699850d44

            var parts            = assembly.GetNameParts();
            var frameworkVersion = assembly.GetFrameworkVersion();
            var fileName         = Path.GetFileName(assembly.Location);
            var path             = Path.Combine(@"C:\Windows\Microsoft.NET\assembly\GAC_MSIL\", string.Format(@"{0}\v{1}_{2}__{3}", parts.AssemblyName, frameworkVersion, parts.Version, parts.PublicKeyToken), fileName);

            return(path);
        }
Ejemplo n.º 5
0
        public static string GetGACFolder(this AssemblyClone assembly)
        {
            // Hydra.DesktopDebuggingAgent\v4.0_1.0.0.0__4c46114699850d44

            var parts            = assembly.GetNameParts();
            var frameworkVersion = assembly.GetFrameworkVersion();
            var fileName         = Path.GetFileName(assembly.Location);
            var path             = string.Format(@"{0}\v{1}_{2}__{3}", parts.AssemblyName, frameworkVersion, parts.Version, parts.PublicKeyToken);

            return(path);
        }
Ejemplo n.º 6
0
        public static XDocument ToXml(this AssemblyClone assembly)
        {
            var serializer   = XmlSerializer.FromTypes(new Type[] { typeof(AssemblyClone) })[0];
            var document     = new XmlDocument();
            var memoryStream = new MemoryStream();

            serializer.Serialize(memoryStream, assembly);

            memoryStream.Seek(0, SeekOrigin.Begin);

            return(XDocument.Load(memoryStream));
        }
Ejemplo n.º 7
0
        public static string GetFramework(this AssemblyClone assembly)
        {
            var frameworkName        = string.Empty;
            var frameworkDisplayName = string.Empty;
            var customAttributes     = assembly.GetCustomAttributesData();
            var targetFramework      = customAttributes.FirstOrDefault(a => (a as dynamic).AttributeType == typeof(TargetFrameworkAttribute));

            if (null != targetFramework)
            {
                if (targetFramework.ConstructorArguments.Any())
                {
                    frameworkName = (string)targetFramework.ConstructorArguments[0].Value;

                    return(frameworkName);
                }
            }

            return(null);
        }