Ejemplo n.º 1
0
        private void Initialize()
        {
#if(SILVERLIGHT)
            _assemblies = (from part in Deployment.Current.Parts
                          where ShouldAddAssembly(part.Source)
                          let info = Application.GetResourceStream(new Uri(part.Source, UriKind.Relative))
                          select part.Load(info.Stream)).ToArray();
#else
            var codeBase = Assembly.GetExecutingAssembly().CodeBase;
            var uri = new Uri(codeBase);
            var path = Path.GetDirectoryName(uri.LocalPath);

            var files = new DirectoryInfo(path).GetFiles("*.dll");
            files.Concat(new DirectoryInfo(path).GetFiles("*.exe"));

            var currentAssemblies = AppDomain.CurrentDomain.GetAssemblies().ToList();
            foreach (var file in files)
            {
                var assemblyName = AssemblyName.GetAssemblyName(file.FullName);
                if (!currentAssemblies.Any(assembly => Matches(assemblyName, assembly.GetName()))) // AssemblyName.ReferenceMatchesDefinition(assemblyName, assembly.GetName())))
                    currentAssemblies.Add(Assembly.Load(assemblyName));
            }
            _assemblies = currentAssemblies.Distinct(new AssemblyComparer()).ToArray();
#endif
        }
Ejemplo n.º 2
0
        public void Init()
        {
            Bootstrapper.With.Windsor(AssemblyResolver, BootstrapEnvironment.BUS).And.StartupTasks().UsingThisExecutionOrder(s => s
                        .First<AppDomainAssemblyResolverStartupTask>()
                        .Then<WindsorSetupStartupTask>()
                        .Then().TheRest()).Start();

            var nserviceBusAssemblies = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory)
                                        .GetFiles("NServiceBus*.dll", SearchOption.AllDirectories)
                                        .Select(file => Assembly.LoadFrom(file.FullName));

            container = (IWindsorContainer)Bootstrapper.Container;

            var assemblies = nserviceBusAssemblies.Concat(AssemblyResolver.PluginAssembliesByFullName.Values);

            Configure.With(assemblies)
                .CastleWindsorBuilder(container)
                .MsmqTransport()
                    .IsTransactional(false)
                    .PurgeOnStartup(false)
                .MsmqSubscriptionStorage()
                .XmlSerializer()
                .UnicastBus()
                    .LoadMessageHandlers()
                .CreateBus()
                .Start();
        }
        public void Run()
        {
            var assemblies = new DirectoryInfo(AppDomain.CurrentDomain.DynamicDirectory)
                                        .GetFiles("NServiceBus*.dll", SearchOption.AllDirectories)
                                        .Select(file => Assembly.LoadFrom(file.FullName));



            var bus = Configure.With(assemblies.Concat(MvcApplication.AssemblyResolver.PluginAssembliesByFullName.Values))
                        .Log4Net()
                        .CastleWindsorBuilder((IWindsorContainer)Bootstrapper.Container)
                        .XmlSerializer()
                        .MsmqTransport().IsTransactional(false)
                        .UnicastBus()
                            .LoadMessageHandlers()
                        .CreateBus()
                        .Start();

            MvcApplication.Bus = bus;
        }
Ejemplo n.º 4
0
        private static Dictionary <String, Texture2D> LoadIconDictionary(String IconFolderName)
        {
            Dictionary <String, Texture2D> dictReturn = new Dictionary <string, Texture2D>();
            Texture2D texLoading;

            //Where are the Icons
            String strIconPath = string.Format("{0}/PluginData/{1}", PathPlugin, IconFolderName);

            //String strIconDBPath = string.Format("{0}/{1}", DBPathPlugin, IconFolderName);

            MonoBehaviourExtended.LogFormatted("Checking for strIconPath folder: {0}", strIconPath);
            if (Directory.Exists(strIconPath))
            {
                //get all the png and tga's
                FileInfo[] fileIconsPNG = new System.IO.DirectoryInfo(strIconPath).GetFiles("*.png");
                FileInfo[] fileIconsTGA = new System.IO.DirectoryInfo(strIconPath).GetFiles("*.tga");
                FileInfo[] fileIcons    = fileIconsPNG.Concat(fileIconsTGA).ToArray();

                foreach (FileInfo fileIcon in fileIcons)
                {
                    try
                    {
                        //load the file from the GameDB
                        texLoading = new Texture2D(32, 16, TextureFormat.ARGB32, false);
                        if (LoadImageFromFile(ref texLoading, fileIcon.Name, strIconPath))
                        {
                            dictReturn.Add(fileIcon.Name.ToLower().Replace(".png", "").Replace(".tga", ""), texLoading);
                        }
                    }
                    catch (Exception)
                    {
                        MonoBehaviourExtended.LogFormatted("Unable to load Texture from GameDB:{0}", strIconPath);
                    }
                }
            }
            return(dictReturn);
        }
        private static Dictionary<String, Texture2D> LoadIconDictionary(String IconFolderName)
        {
            Dictionary<String, Texture2D> dictReturn = new Dictionary<string, Texture2D>();
            Texture2D texLoading;

            //Where are the Icons
            String strIconPath = string.Format("{0}/{1}", PathPlugin, IconFolderName);
            //String strIconDBPath = string.Format("{0}/{1}", DBPathPlugin, IconFolderName);

            if (Directory.Exists(strIconPath))
            {
                //get all the png and tga's
                FileInfo[] fileIconsPNG = new System.IO.DirectoryInfo(strIconPath).GetFiles("*.png");
                FileInfo[] fileIconsTGA = new System.IO.DirectoryInfo(strIconPath).GetFiles("*.tga");
                FileInfo[] fileIcons = fileIconsPNG.Concat(fileIconsTGA).ToArray();

                foreach (FileInfo fileIcon in fileIcons)
                {
                    try
                    {
                        //load the file from the GameDB
                        texLoading = new Texture2D(32, 16, TextureFormat.ARGB32, false);
                        if (LoadImageFromFile(ref texLoading, fileIcon.Name, strIconPath))
                            dictReturn.Add(fileIcon.Name.ToLower().Replace(".png", "").Replace(".tga", ""), texLoading);
                    }
                    catch (Exception)
                    {
                        MonoBehaviourExtended.LogFormatted("Unable to load Texture from GameDB:{0}", strIconPath);
                    }
                }
            }
            return dictReturn;
        }
        private StandaloneAzureBlobResultSegment FindFilesHierarchical(string prefix, int? maxResults, int numberToSkip)
        {
            var directories = new DirectoryInfo(_containerDirectory).EnumerateDirectories((prefix ?? "") + "*", SearchOption.TopDirectoryOnly)
                .Where(f => !f.Name.EndsWith(".meta"))
                .Select(f => (IAzureListBlobItem) new StandaloneAzureBlobDirectory(f.FullName));
            var files = new DirectoryInfo(_containerDirectory).EnumerateFiles((prefix ?? "") + "*", SearchOption.TopDirectoryOnly)
                .Where(f => !(f.DirectoryName ?? "").EndsWith(".meta"))
                .Select(f => (IAzureListBlobItem) new StandaloneAzureBlockBlob(new Uri(f.FullName)));

            var combined = directories.Concat(files)
                .Skip(numberToSkip)
                .Take(maxResults.HasValue ? maxResults.Value : Int32.MaxValue)
                .ToList();

            var resultSegment = new StandaloneAzureBlobResultSegment(
                combined,
                new BlobContinuationToken
                {
                    NextMarker = DetermineNextMarker(numberToSkip, combined.Count)
                });
            return resultSegment;
        }
Ejemplo n.º 7
0
        private void Initialize()
        {
#if(SILVERLIGHT)
            _assemblies = (from part in Deployment.Current.Parts
                          where ShouldAddAssembly(part.Source)
                          let info = Application.GetResourceStream(new Uri(part.Source, UriKind.Relative))
                          select part.Load(info.Stream)).ToArray();
#else
#if(NETFX_CORE)
            var folder = Windows.ApplicationModel.Package.Current.InstalledLocation;
            var assemblies = new List<Assembly>();

            IEnumerable<StorageFile>    files = null;

            var operation = folder.GetFilesAsync();
            operation.Completed = async (r, s) => {
                var result = await r;
                files = result;
            };

            while (files == null) ;

            foreach (var file in files)
            {
                if (file.FileType == ".dll" || file.FileType == ".exe")
                {
                    var name = new AssemblyName() { Name = System.IO.Path.GetFileNameWithoutExtension(file.Name) };
                    try
                    {
                        Assembly asm = Assembly.Load(name);
                        assemblies.Add(asm);
                    }
                    catch { }
                }
            }
            _assemblies = assemblies.ToArray();
#else

            var codeBase = Assembly.GetExecutingAssembly().CodeBase;
            var uri = new Uri(codeBase);
            var path = Path.GetDirectoryName(uri.LocalPath);

            var files = new DirectoryInfo(path).GetFiles("*.dll");
            files.Concat(new DirectoryInfo(path).GetFiles("*.exe"));

            var currentAssemblies = AppDomain.CurrentDomain.GetAssemblies().ToList();
            foreach (var file in files)
            {
                try
                {
                    var assemblyName = AssemblyName.GetAssemblyName(file.FullName);
                    if (!currentAssemblies.Any(assembly => Matches(assemblyName, assembly.GetName())))
                        currentAssemblies.Add(Assembly.Load(assemblyName));
                }
                catch (BadImageFormatException)
                {
                    //Just indicates this is not a .NET assembly
                }
            }
            _assemblies = currentAssemblies.Distinct(new AssemblyComparer()).ToArray();
#endif
#endif
        }