private String GetPhotoshopSupportFiles()
 {
     String localePath = Path.Combine(PhotoshopInstallmentBasePath(), @"Locales");
     DirectoryInfo[] languageDirectorys = new DirectoryInfo(localePath).GetDirectories();
     DirectoryInfo localLanguageDirectory = languageDirectorys.FirstOrDefault();
     return Path.Combine(localLanguageDirectory.FullName, @"Support Files");
 }
Example #2
0
        private void Configure(WidgetDefinition widget)
        {
            var files = new DirectoryInfo(Server.MapPath(widget.VirtualPath)).GetFiles();

            var iconFile = files.FirstOrDefault(f => f.Name.IgnoreCaseStartsWith("icon."));
            if (iconFile != null)
            {
                widget.IconUrl = UrlUtil.Combine(widget.VirtualPath, iconFile.Name);
            }

            widget.Editable = files.Any(f => f.Name.IgnoreCaseEquals("Editor.aspx"));

            var configFile = files.FirstOrDefault(f => f.Name.IgnoreCaseEquals("config.config"));
            if (configFile != null)
            {
                ApplyXmlConfig(widget, XDocument.Load(configFile.FullName).Root);
            }

            if (widget.DisplayName == null)
            {
                widget.DisplayName = new LocalizableText(String.Format("{{ Plugin={0}, Key={1} }}", widget.Plugin.Name, widget.Name));
            }
        }
Example #3
0
File: Main.cs Project: pluto92/Wox
        public void Init(PluginInitContext context)
        {
            //todo:move to common place
            var otherCompanyDlls = new DirectoryInfo(context.PluginMetadata.PluginDirecotry).GetFiles("*.dll");
            AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
                {
                    var dll = otherCompanyDlls.FirstOrDefault(fi =>
                        {
                            try
                            {
                                Assembly assembly = Assembly.LoadFile(fi.FullName);
                                return assembly.FullName == args.Name;
                            }
                            catch
                            {
                                return false;
                            }
                        });
                    if (dll == null)
                    {
                        return null;
                    }

                    return Assembly.LoadFile(dll.FullName);
                };

            docsetBasePath = context.PluginMetadata.PluginDirecotry + @"Docset";
            if (!Directory.Exists(docsetBasePath))
                Directory.CreateDirectory(docsetBasePath);

            foreach (string path in Directory.GetDirectories(docsetBasePath))
            {
                string name = path.Substring(path.LastIndexOf('\\') + 1);
                string dbPath = path + @"\Contents\Resources\docSet.dsidx";
                string dbType = CheckTableExists("searchIndex", dbPath) ? "DASH" : "ZDASH";
                docs.Add(new Doc
                {
                    Name = name,
                    DBPath = dbPath,
                    DBType = dbType,
                    IconPath = TryGetIcon(name, path)
                });
            }
        }
        protected FileSystemInfo GetImageFromLocation(string path, string filenameWithoutExtension)
        {
            try
            {
                var files = new DirectoryInfo(path)
                    .EnumerateFiles()
                    .Where(i =>
                    {
                        var fileName = Path.GetFileNameWithoutExtension(i.FullName);

                        if (!string.Equals(fileName, filenameWithoutExtension, StringComparison.OrdinalIgnoreCase))
                        {
                            return false;
                        }

                        var ext = i.Extension;

                        return !string.IsNullOrEmpty(ext) &&
                            BaseItem.SupportedImageExtensions.Contains(ext, StringComparer.OrdinalIgnoreCase);
                    })
                    .ToList();

                return BaseItem.SupportedImageExtensions
                    .Select(ext => files.FirstOrDefault(i => string.Equals(ext, i.Extension, StringComparison.OrdinalIgnoreCase)))
                    .FirstOrDefault(file => file != null);
            }
            catch (DirectoryNotFoundException)
            {
                return null;
            }
        }
        public IEnumerable<MediaSourceInfo> GetCachedChannelItemMediaSources(IChannelMediaItem item)
        {
            var filenamePrefix = item.Id.ToString("N");
            var parentPath = Path.Combine(ChannelDownloadPath, item.ChannelId);

            try
            {
                var files = new DirectoryInfo(parentPath).EnumerateFiles("*", SearchOption.TopDirectoryOnly);

                if (string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase))
                {
                    files = files.Where(i => EntityResolutionHelper.IsVideoFile(i.FullName));
                }
                else
                {
                    files = files.Where(i => EntityResolutionHelper.IsAudioFile(i.FullName));
                }

                var file = files
                    .FirstOrDefault(i => i.Name.StartsWith(filenamePrefix, StringComparison.OrdinalIgnoreCase));

                if (file != null)
                {
                    var cachedItem = _libraryManager.ResolvePath(file);

                    if (cachedItem != null)
                    {
                        var hasMediaSources = _libraryManager.GetItemById(cachedItem.Id) as IHasMediaSources;

                        if (hasMediaSources != null)
                        {
                            var source = hasMediaSources.GetMediaSources(true).FirstOrDefault();

                            if (source != null)
                            {
                                source.Type = MediaSourceType.Cache;
                                return new[] { source };
                            }
                        }
                    }
                }
            }
            catch (DirectoryNotFoundException)
            {

            }

            return new List<MediaSourceInfo>();
        }
Example #6
0
        public void AssertFolderContentsAreEqual(string folder1, string folder2)
        {
            if (folder1 == folder2)
            {
                Debug.WriteLine("folder1 and folder2 are the same folder.");
                return;
            }

            var folder1Files = new DirectoryInfo(folder1).GetFiles();
            var folder2Files = new DirectoryInfo(folder2).GetFiles();

            var filteredList = TableList.Except(new[] {"dbo.DatabaseLog"});


            foreach (var table in filteredList)
            {
                var fileName = string.Format("{0}.xml", table);
                var folder1File = folder1Files.FirstOrDefault(f1f => f1f.Name == fileName);
                Assert.IsNotNull(folder1File, string.Format("can't find {0} in folder {1}", fileName, folder1));
                var folder2File = folder2Files.FirstOrDefault(f2f => f2f.Name == fileName);
                Assert.IsNotNull(folder2File, string.Format("can't find {0} in folder {1}", fileName, folder2));
                Debug.WriteLine(string.Format("Comparing the contents of {0} to {1}...",
                    folder1File.FullName, folder2File.FullName));
                var folder1FileContents = File.ReadAllText(folder1File.FullName);
                var folder2FileContents = File.ReadAllText(folder2File.FullName);
                Assert.AreEqual(NormalizeText(folder1FileContents), NormalizeText(folder2FileContents));
            }
        }