public IViewExtension Load(string extensionPath)
        {
            var document = new XmlDocument();

            document.Load(extensionPath);

            var topNode = document.GetElementsByTagName("ViewExtensionDefinition");

            if (topNode.Count == 0)
            {
                Log("Malformed " + extensionPath + " file");
                return(null);
            }

            var definition = new ViewExtensionDefinition();
            var path       = Path.GetDirectoryName(extensionPath);

            foreach (XmlNode item in topNode[0].ChildNodes)
            {
                if (item.Name == "AssemblyPath")
                {
                    path = Path.Combine(path, item.InnerText);
                    definition.AssemblyPath = path;
                }
                else if (item.Name == "TypeName")
                {
                    definition.TypeName = item.InnerText;
                }
            }

            var extension = Load(definition);

            return(extension);
        }
Ejemplo n.º 2
0
 internal IViewExtension Load(ViewExtensionDefinition viewExtension)
 {
     try
     {
         if (viewExtension.IsEnabled)
         {
             if (viewExtension.RequiresSignedEntryPoint)
             {
                 CertificateVerification.CheckAssemblyForValidCertificate(viewExtension.AssemblyPath);
             }
             var assembly = Assembly.LoadFrom(viewExtension.AssemblyPath);
             var result   = assembly.CreateInstance(viewExtension.TypeName) as IViewExtension;
             ExtensionLoading?.Invoke(result);
             return(result);
         }
         return(null);
     }
     catch (Exception ex)
     {
         var name = viewExtension.TypeName == null ? "null" : viewExtension.TypeName;
         Log("Could not create an instance of " + name);
         Log(ex.Message);
         Log(ex.StackTrace);
         return(null);
     }
 }
Ejemplo n.º 3
0
        public IViewExtension Load(string extensionPath)
        {
            var document = new XmlDocument();
            document.Load(extensionPath);

            var topNode = document.GetElementsByTagName("ViewExtensionDefinition");

            if (topNode.Count == 0)
            {
                Log("Malformed " + extensionPath + " file");
                return null;
            }

            var definition = new ViewExtensionDefinition();
            var path = Path.GetDirectoryName(extensionPath);
            foreach (XmlNode item in topNode[0].ChildNodes)
            {
                if (item.Name == "AssemblyPath")
                {
                    path = Path.Combine(path, item.InnerText);
                    definition.AssemblyPath = path;
                }
                else if (item.Name == "TypeName")
                {
                    definition.TypeName = item.InnerText;
                }
            }

            var extension = Load(definition);
            return extension;
        }
Ejemplo n.º 4
0
        public IViewExtension Load(string extensionPath)
        {
            var document = new XmlDocument();

            document.Load(extensionPath);

            var topNode = document.GetElementsByTagName("ViewExtensionDefinition");

            if (topNode.Count == 0)
            {
                Log("Malformed " + extensionPath + " file");
                return(null);
            }

            var definition = new ViewExtensionDefinition();
            var path       = Path.GetDirectoryName(extensionPath);

            foreach (XmlNode item in topNode[0].ChildNodes)
            {
                if (item.Name == "AssemblyPath")
                {
                    path = Path.Combine(path, item.InnerText);
                    definition.AssemblyPath = path;
                }
                else if (item.Name == "TypeName")
                {
                    definition.TypeName = item.InnerText;
                }
                else if (item.Name == "IsEnabled")
                {
                    // Because the default value for this property is true so we check if user specifically put it false
                    bool.TryParse(item.InnerText, out bool result);
                    definition.IsEnabled = result;
                }
            }

            //Check if the view extension definition file was located in a directory which requires certificate validation.
            foreach (var pathToVerifyCert in DirectoriesToVerifyCertificates)
            {
                if (extensionPath.Contains(pathToVerifyCert))
                {
                    definition.RequiresSignedEntryPoint = true;
                }
            }

            var extension = Load(definition);

            return(extension);
        }
Ejemplo n.º 5
0
 private IViewExtension Load(ViewExtensionDefinition viewExtension)
 {
     try
     {
         var assembly = Assembly.LoadFrom(viewExtension.AssemblyPath);
         var result = assembly.CreateInstance(viewExtension.TypeName) as IViewExtension;
         return result;
     }
     catch
     {
         var name = viewExtension.TypeName == null ? "null" : viewExtension.TypeName;
         Log("Could not create an instance of " + name);
         return null;
     }
 }
Ejemplo n.º 6
0
 private IViewExtension Load(ViewExtensionDefinition viewExtension)
 {
     try
     {
         var assembly = Assembly.LoadFrom(viewExtension.AssemblyPath);
         var result   = assembly.CreateInstance(viewExtension.TypeName) as IViewExtension;
         return(result);
     }
     catch
     {
         var name = viewExtension.TypeName == null ? "null" : viewExtension.TypeName;
         Log("Could not create an instance of " + name);
         return(null);
     }
 }