Beispiel #1
0
        public void Load()
        {
            if (mapAssemblies == null)
            {
                mapAssemblies = new Dictionary <string, MappingAssembly>();
            }
            lock (mapAssemblies)
            {
                mapAssemblies.Clear();

                if (this.mappings == null || this.mappings.Count == 0)
                {
                    throw new AGIException("No mappings were added, before Load method called.");
                }

                foreach (var de in this.mappings)
                {
                    MappingAssembly ma;

                    if (mapAssemblies.ContainsKey(de.ScriptName))
                    {
                        throw new AGIException(String.Format("Duplicate mapping name '{0}'", de.ScriptName));
                    }
                    if (!string.IsNullOrEmpty(de.ScriptAssmebly))
                    {
                        try
                        {
                            ma = new MappingAssembly()
                            {
                                ClassName      = (string)de.ScriptClass,
                                LoadedAssembly = Assembly.LoadFile(de.ScriptAssmebly)
                            };
                        }
                        catch (FileNotFoundException fnfex)
                        {
                            throw new AGIException(string.Format("Unable to load AGI Script {0}, file not found.", Path.Combine(Environment.CurrentDirectory, de.ScriptAssmebly)), fnfex);
                        }
                    }
                    else
                    {
                        ma = new MappingAssembly()
                        {
                            ClassName = (string)de.ScriptClass
                        };
                        if (de.PreLoadedAssembly != null)
                        {
                            ma.LoadedAssembly = de.PreLoadedAssembly;
                        }
                    }

                    mapAssemblies.Add(de.ScriptName, ma);
                }
            }
        }
        public void Load()
        {
            if (mapAssemblies == null)
                mapAssemblies = new Dictionary<string, MappingAssembly>();
            lock (mapAssemblies)
            {
                mapAssemblies.Clear();

                if (this.mappings == null || this.mappings.Count == 0)
                    throw new AGIException("No mappings were added, before Load method called.");

                foreach (var de in this.mappings)
                {
                    MappingAssembly ma;

                    if (mapAssemblies.ContainsKey(de.ScriptName))
                        throw new AGIException(String.Format("Duplicate mapping name '{0}'", de.ScriptName));
                    if (!string.IsNullOrEmpty(de.ScriptAssmebly))
                    {
                        try
                        {
                            ma = new MappingAssembly()
                            {
                                ClassName = (string)de.ScriptClass,
                                LoadedAssembly = Assembly.LoadFile(de.ScriptAssmebly)
                            };
                        }
                        catch (FileNotFoundException fnfex)
                        {
                            throw new AGIException(string.Format("Unable to load AGI Script {0}, file not found.", Path.Combine(Environment.CurrentDirectory, de.ScriptAssmebly)), fnfex);
                        }
                    }
                    else
                    {
                        ma = new MappingAssembly()
                        {
                            ClassName = (string)de.ScriptClass
                        };
                        if (de.PreLoadedAssembly != null)
                            ma.LoadedAssembly = de.PreLoadedAssembly;
                    }

                    mapAssemblies.Add(de.ScriptName, ma);
                }
                
            }
        }