public async Task OpenFile()
        {
            if (ReferenceFile.IsReferenceFile(File))
            {
                ReferenceFile referenceFile = await ReferenceFile.GetFile(File);

                if (referenceFile.ReferencedFile == null)
                {
                    return;
                }

                await Launcher.LaunchFileAsync(referenceFile.ReferencedFile);
            }
            else
            {
                await Launcher.LaunchFileAsync(File);
            }
        }
        public async Task OpenContainingFolder(bool checkForReference)
        {
            IStorageFolder folder;
            IStorageFile   fileToSelect;

            if (checkForReference && ReferenceFile.IsReferenceFile(File))
            {
                ReferenceFile referenceFile = await ReferenceFile.GetFile(File);

                if (referenceFile.ReferencedFile == null)
                {
                    folder = await StorageHelpers.ToStorageItem <StorageFolder>(Path.GetDirectoryName(File.Path));

                    fileToSelect = File;
                }
                else
                {
                    folder = await StorageHelpers.ToStorageItem <StorageFolder>(Path.GetDirectoryName(referenceFile.ReferencedFile.Path));

                    fileToSelect = referenceFile.ReferencedFile;
                }
            }
            else
            {
                folder = await StorageHelpers.ToStorageItem <StorageFolder>(Path.GetDirectoryName(File.Path));

                fileToSelect = File;
            }

            if (folder != null)
            {
                FolderLauncherOptions launcherOptions = new FolderLauncherOptions();

                if (File != null)
                {
                    launcherOptions.ItemsToSelect.Add(fileToSelect);
                }

                await Launcher.LaunchFolderAsync(folder, launcherOptions);
            }
        }
예제 #3
0
        /// <summary>
        /// Checks "WrongReferences" condition.
        /// </summary>
        public static void CheckWrongReferences()
        {
            StringBuilder message  = new StringBuilder();
            List <string> projects = ProjectHelper.GetProjectReferences();

            if (Arguments.ProjectType != ProjectType.Azure)
            {
                foreach (string project in projects)
                {
                    message.AppendLine(
                        Strings.DontUseProjectReference
                        .Display(project));
                }
            }

            List <Reference> references = ProjectHelper.GetBinaryReferences();

            CheckReferenceProperties(references, message);

            List <ReferenceFile> allExternals  = ReferenceFolder.GetAllFiles(Arguments.ExternalReferencesPath);
            List <ReferenceFile> allInternals  = ReferenceFolder.GetAllFiles(Arguments.InternalReferencesPath);
            List <ReferenceFile> usedExternals = new List <ReferenceFile>();
            List <ReferenceFile> usedInternals = new List <ReferenceFile>();
            List <Reference>     usedGac       = new List <Reference>();

            foreach (Reference reference in references)
            {
                ReferenceFile usedExternal = allExternals.Where(file => file.AssemblyName == reference.Name).FirstOrDefault();
                ReferenceFile usedInternal = allInternals.Where(file => file.AssemblyName == reference.Name).FirstOrDefault();

                if (usedExternal != null)
                {
                    usedExternals.Add(usedExternal);
                }
                else if (usedInternal != null)
                {
                    usedInternals.Add(usedInternal);
                }
                else
                {
                    usedGac.Add(reference);
                }
            }

            foreach (string project in projects)
            {
                ReferenceFile usedInternal = allInternals
                                             .Where(file => file.AssemblyName == Path.GetFileNameWithoutExtension(project))
                                             .FirstOrDefault();

                if (usedInternal != null)
                {
                    usedInternals.Add(usedInternal);
                }
            }

            ReferenceMark.SetupActual(
                ReferenceType.External,
                Arguments.ReferencesDirectory,
                usedExternals.Select(item => item.ProjectName).Distinct());

            ReferenceMark.SetupActual(
                ReferenceType.Internal,
                Arguments.ReferencesDirectory,
                usedInternals.Select(item => item.ProjectName).Distinct());

            List <string> requiredGac = new List <string>();
            List <string> allowedGac  = new List <string>();

            allowedGac.Add("envdte");
            allowedGac.Add("envdte80");
            allowedGac.Add("Microsoft.Contracts");
            allowedGac.Add("Microsoft.CSharp");
            allowedGac.Add("Microsoft.JScript");
            allowedGac.Add("Microsoft.mshtml");
            allowedGac.Add("Microsoft.ReportViewer.Common");
            allowedGac.Add("Microsoft.ReportViewer.WebForms");
            allowedGac.Add("Microsoft.Synchronization");
            allowedGac.Add("Microsoft.Synchronization.Data");
            allowedGac.Add("Microsoft.Synchronization.Data.SqlServer");
            allowedGac.Add("Microsoft.VisualBasic.Compatibility.Data");
            allowedGac.Add("Microsoft.VisualStudio.QualityTools.UnitTestFramework");
            allowedGac.Add("PresentationCore");
            allowedGac.Add("PresentationFramework");
            allowedGac.Add("System");
            allowedGac.Add("System.Core");
            allowedGac.Add("System.ComponentModel.DataAnnotations");
            allowedGac.Add("System.Configuration");
            allowedGac.Add("System.configuration");
            allowedGac.Add("System.Configuration.Install");
            allowedGac.Add("System.Data");
            allowedGac.Add("System.Data.DataSetExtensions");
            allowedGac.Add("System.Data.Entity");
            allowedGac.Add("System.Data.Linq");
            allowedGac.Add("System.Data.Services");
            allowedGac.Add("System.Data.Services.Client");
            allowedGac.Add("System.Deployment");
            allowedGac.Add("System.Design");
            allowedGac.Add("System.Drawing");
            allowedGac.Add("System.EnterpriseServices");
            allowedGac.Add("System.IdentityModel");
            allowedGac.Add("System.IdentityModel.Selectors");
            allowedGac.Add("System.Management");
            allowedGac.Add("System.Messaging");
            allowedGac.Add("System.Runtime.Remoting");
            allowedGac.Add("System.Runtime.Serialization");
            allowedGac.Add("System.Runtime.Serialization.Formatters.Soap");
            allowedGac.Add("System.Security");
            allowedGac.Add("System.ServiceModel");
            allowedGac.Add("System.ServiceModel.Web");
            allowedGac.Add("System.ServiceModel.DomainServices.EntityFramework");
            allowedGac.Add("System.ServiceModel.DomainServices.Hosting");
            allowedGac.Add("System.ServiceModel.DomainServices.Server");
            allowedGac.Add("System.ServiceProcess");
            allowedGac.Add("System.Transactions");
            allowedGac.Add("System.Web");
            allowedGac.Add("System.Web.Abstractions");
            allowedGac.Add("System.Web.ApplicationServices");
            allowedGac.Add("System.Web.DynamicData");
            allowedGac.Add("System.Web.Entity");
            allowedGac.Add("System.Web.Extensions");
            allowedGac.Add("System.Web.Extensions.Design");
            allowedGac.Add("System.Web.Helpers");
            allowedGac.Add("System.Web.Mobile");
            allowedGac.Add("System.Web.Routing");
            allowedGac.Add("System.Web.Services");
            allowedGac.Add("System.Web.WebPages");
            allowedGac.Add("System.Windows.Forms");
            allowedGac.Add("System.Xaml");
            allowedGac.Add("System.XML");
            allowedGac.Add("System.Xml");
            allowedGac.Add("System.Xml.Linq");
            allowedGac.Add("WindowsBase");

            string description;

            if (!ValidationHelper.CheckEntries(
                    usedGac.Select(reference => reference.Name).ToList(),
                    requiredGac,
                    allowedGac,
                    out description))
            {
                message.Append(description);
            }

            if (message.Length == 0)
            {
                return;
            }

            RaiseError.WrongReferences(message.ToString());
        }
        public static async Task <BasePastedContentTypeDataModel> GetContentType(IStorageItem item, BasePastedContentTypeDataModel contentType)
        {
            if (contentType is InvalidContentTypeDataModel invalidContentType)
            {
                if (!invalidContentType.needsReinitialization)
                {
                    return(invalidContentType);
                }
            }

            if (contentType != null)
            {
                return(contentType);
            }

            if (item is StorageFile file)
            {
                string ext = Path.GetExtension(file.Path);

                if (ReferenceFile.IsReferenceFile(file))
                {
                    // Reference File, get the destination file extension
                    ReferenceFile referenceFile = await ReferenceFile.GetFile(file);

                    if (referenceFile.ReferencedFile == null)
                    {
                        return(new InvalidContentTypeDataModel(referenceFile.LastError, false));
                    }

                    file = referenceFile.ReferencedFile;
                    ext  = Path.GetExtension(file.Path);
                }

                // Image
                if (ImageCanvasViewModel.Extensions.Contains(ext))
                {
                    return(new ImageContentType());
                }

                // Text
                if (TextCanvasViewModel.Extensions.Contains(ext))
                {
                    return(new TextContentType());
                }

                // Media
                if (MediaCanvasViewModel.Extensions.Contains(ext))
                {
                    return(new MediaContentType());
                }

                // WebView
                if (WebViewCanvasViewModel.Extensions.Contains(ext))
                {
                    if (ext == Constants.FileSystem.WEBSITE_LINK_FILE_EXTENSION)
                    {
                        return(new WebViewContentType(WebViewCanvasMode.ReadWebsite));
                    }

                    return(new WebViewContentType(WebViewCanvasMode.ReadHtml));
                }

                // Markdown
                if (MarkdownCanvasViewModel.Extensions.Contains(ext))
                {
                    return(new MarkdownContentType());
                }

                // Default, try as text
                if (await TextCanvasViewModel.CanLoadAsText(file))
                {
                    // Text
                    return(new TextContentType());
                }

                // Use fallback
                return(new FallbackContentType());
            }
            else if (item is StorageFolder folder)
            {
                // TODO: Handle also folders
                return(new InvalidContentTypeDataModel(new SafeWrapperResult(OperationErrorCode.InvalidOperation, new InvalidOperationException(), "Displaying content for folders is not yet supported."), false));
            }

            return(new InvalidContentTypeDataModel(new SafeWrapperResult(OperationErrorCode.InvalidOperation, new InvalidOperationException(), "Couldn't display content for this file"), false));
        }