Пример #1
0
        public void TransferItem()
        {
            var project = DebugProject.OpenProject(@"Python.VS.TestData\HelloWorld.sln");

            var app = new VisualStudioApp(VsIdeTestHostContext.Dte);

            string filename, basename;
            int    i = 0;

            do
            {
                i++;
                basename = "test" + i + " .py";
                filename = Path.Combine(Path.GetTempPath(), basename);
            } while (System.IO.File.Exists(filename));

            System.IO.File.WriteAllText(filename, "def f(): pass");

            var fileWindow = app.Dte.ItemOperations.OpenFile(filename);

            app.MoveCurrentFileToProject("HelloWorld");

            app.OpenSolutionExplorer();
            var window = app.SolutionExplorerTreeView;

            Assert.AreNotEqual(null, window.WaitForItem("Solution 'HelloWorld' (1 project)", "HelloWorld", basename));

            Assert.AreEqual(fileWindow.Caption, basename);

            System.IO.File.Delete(filename);
        }
        public async Task ApiFileShippedWithNonExistentMembersTestFullPathAsync()
        {
            // Type C has no public member "Method", but the shipped API has an entry for it.
            var source = @"
public class C
{
    public int Field;
    public int Property { get; set; }
    private void Method() { }
}
";

            var tempPath = Path.GetTempPath();

            this.shippedText     = $@"
C
C.C() -> void
C.Field -> int
C.Property.get -> int
C.Property.set -> void
C.Method() -> void
";
            this.shippedFilePath = Path.Combine(tempPath, DeclarePublicAPIAnalyzer.ShippedFileName);

            this.unshippedText     = $@"";
            this.unshippedFilePath = Path.Combine(tempPath, DeclarePublicAPIAnalyzer.UnshippedFileName);

            // <%TEMP_PATH%>\PublicAPI.Shipped.txt(7,1): warning RS0017: Symbol 'C.Method() -> void' is part of the declared API, but is either not public or could not be found
            var expected = this.CSharpDiagnostic(DeclarePublicAPIAnalyzer.RemoveDeletedApiRule).WithArguments("C.Method() -> void").WithLocation(this.shippedFilePath, 7, 1);

            await this.VerifyCSharpDiagnosticAsync(source, expected, CancellationToken.None).ConfigureAwait(false);
        }
Пример #3
0
        internal static string ResolveMsAppDataUri(Uri uri)
        {
            if (uri.Scheme == "ms-appdata")
            {
                string filePath = string.Empty;

                if (uri.LocalPath.StartsWith("/local"))
                {
                    var libraryPath = NSFileManager.DefaultManager.GetUrls(NSSearchPathDirectory.LibraryDirectory, NSSearchPathDomain.User)[0].Path;
                    filePath = IOPath.Combine(libraryPath, uri.LocalPath.Substring(7));
                }
                else if (uri.LocalPath.StartsWith("/temp"))
                {
                    filePath = IOPath.Combine(IOPath.GetTempPath(), uri.LocalPath.Substring(6));
                }
                else
                {
                    throw new ArgumentException("Invalid Uri", "Source");
                }

                return(filePath);
            }
            else
            {
                throw new ArgumentException("uri");
            }
        }
Пример #4
0
 public MainClientWindow()
 {
     InitializeComponent();
     TransferWindow       = MainWindow;
     TranferView          = DataView;
     DownloadPath.Content = Path.GetTempPath();
     StringDownloadPath   = (string)DownloadPath.Content;
 }
Пример #5
0
        protected virtual void setUpImpl()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-us");
            TemplateGroup.DefaultGroup          = new TemplateGroup();
            TemplateCompiler.subtemplateCount   = 0;

            // new output dir for each test
            tmpdir = Path.GetFullPath(Path.Combine(Path.GetTempPath(), "st4-" + currentTimeMillis()));
        }
Пример #6
0
        protected virtual void eraseTempDir()
        {
            if (!Path.GetTempPath().Equals(Path.GetDirectoryName(tmpdir) + Path.DirectorySeparatorChar))
            {
                throw new InvalidOperationException();
            }

            Directory.Delete(tmpdir, true);
        }
Пример #7
0
        protected virtual void setUpImpl()
        {
            TemplateGroup.defaultGroup        = new TemplateGroup();
            TemplateGroup.defaultGroup.Debug  = false;
            TemplateCompiler.subtemplateCount = 0;

            // new output dir for each test
            tmpdir = Path.GetFullPath(Path.Combine(Path.GetTempPath(), "st4-" + currentTimeMillis()));
        }
Пример #8
0
        public void TestInitialize()
        {
            // new output dir for each test
            string tempTestFolder = GetType().Name + "-" + (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond);
            string dir            = Path.Combine(Path.GetTempPath(), tempTestFolder);

            if (Directory.Exists(dir))
            {
                throw new InvalidOperationException();
            }

            tmpdir = dir;
        }
        public void TestChangeAdministratorPassword()
        {
            IComputeProvider provider = Bootstrapper.CreateComputeProvider();

            string password             = Path.GetTempPath();
            bool   changePasswordResult = provider.ChangeAdministratorPassword(_server.Id, password);

            Assert.IsTrue(changePasswordResult);
            _password = password;
            Server changePasswordServer = provider.WaitForServerActive(_server.Id);

            Assert.AreEqual(ServerState.Active, changePasswordServer.Status);
        }
Пример #10
0
        protected virtual void setUpImpl()
        {
            // Ideally we wanted en-US, but invariant provides a suitable default for testing.
#if NETSTANDARD
            CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
#else
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
#endif
            TemplateGroup.DefaultGroup        = new TemplateGroup();
            TemplateCompiler.subtemplateCount = 0;

            // new output dir for each test
            tmpdir = Path.GetFullPath(Path.Combine(Path.GetTempPath(), "st4-" + currentTimeMillis()));
        }
Пример #11
0
 private void ButtonSourceBrowse_Click(object sender, RoutedEventArgs e)
 {
     if (ShowOpenDialog())
     {
         TextBlockSouurcePath.Text = OpenFileDialogInstance.FileName;
         OriginalSourceFilePath    = OpenFileDialogInstance.FileName;
         TempSourceFilePath        = IOPath.Combine(IOPath.GetTempPath(), "Source.xml");
         TempTargetFilePath        = IOPath.Combine(IOPath.GetTempPath(), "Target.xml");
         MaintainControlsAvailability();
         ClearRigthBrowser = true;
         WebBrowserAfter.NavigateToString("<HTML></HTML>");
         new Thread(ReadAttributes).Start();
     }
 }
Пример #12
0
        private static string GetTemporaryDirectory(out bool removeDirectory)
        {
            string packagesPath = Path.GetFullPath(@"..\..\..");

            if (Directory.Exists(Path.Combine(packagesPath, "packages")))
            {
                removeDirectory = false;
                return(Path.Combine(packagesPath, "packages"));
            }

            string path = Path.Combine(Path.GetTempPath(), "CompatibilityChecker-" + Path.GetRandomFileName());

            Directory.CreateDirectory(path);
            removeDirectory = true;
            return(path);
        }
Пример #13
0
        public static void TestPrint()
        {
            string fileName = Path.GetTempPath() + "testprint.pdf";

            using PdfWriter pdfWriter = new PdfWriter(fileName);
            using PdfDocument pdf     = new PdfDocument(pdfWriter);
            Document pdfDoc = new Document(pdf);
            //Header
            Paragraph p = new Paragraph("Hello! \n This is Test Print for testing default printer!. \n\n Aprajita Retails Dev. Team.");

            pdfDoc.Add(p);
            pdf.AddNewPage();
            pdfDoc.Close();

            PrintPDFLocal(fileName);
        }
Пример #14
0
        public static void Main(string[] args)
        {
            // Extract pdf content
            ContentExtract.ExtractPdf(
                "/Users/ryan/RiderProjects/Sharpen Pdf Parser/Sharpen Pdf Parser/Resources/affordances.pdf",
                Path.Combine(Path.GetTempPath(), "test.pdf"));
            BookMetrics book = ContentExtract.Book;

            book.ToJson("/Users/ryan/RiderProjects/Sharpen Pdf Parser/test.json");

            BookMetrics bookTest = BookMetrics.FromJson("/Users/ryan/RiderProjects/Sharpen Pdf Parser/test.json");

            // Remove text from pdf
            GhostScript.RemoveText("/Users/ryan/Documents/Books/affordances.pdf");

            // Convert page to svg
            Poppler.PdfToSvg("/Users/ryan/Documents/Books/affordances.pdf", "1");

            // Preparing SVG for unity - temporary until they fix issues
            Svg.RenderEmptyPathsExplicit("/Users/ryan/RiderProjects/Sharpen Pdf Parser/Sharpen Pdf Parser/Resources/test.svg");
            Svg.RenderRgbAsHex("/Users/ryan/RiderProjects/Sharpen Pdf Parser/Sharpen Pdf Parser/Resources/test.svg");
            Svg.WriteSvg("/Users/ryan/Documents/Books/parsed2.svg");
        }
Пример #15
0
 public static string GetTempPath() =>
 MSIOP.GetTempPath();
Пример #16
0
 public TempFileSource(IExternalFileSource externalSource) : base(externalSource, SystemPath.GetTempPath())
 {
 }
Пример #17
0
 private void ListBoxItem_OnSelected_3(object sender, RoutedEventArgs e)
 {
     download_CachePath_Input.Text = Path.Combine(Path.GetTempPath(), "ParanoidDownloader");
 }
Пример #18
0
 public static string GetTempPath()
 {
     return(MyPath.GetTempPath());
 }
Пример #19
0
        /// <summary>
        /// Creates a DataDir for a generic path for the provided application name.
        /// </summary>
        public static DataDir Create(string applicationName, string companyName = null, DataDirType type = DataDirType.RoamingUser)
        {
            if (string.IsNullOrEmpty(applicationName))
            {
                throw new ArgumentException(nameof(applicationName), "Application name cannot be null or empty.");
            }

            bool   isUnix = Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX;
            string parentDirectory;

            string homeDirectory = Environment.GetEnvironmentVariable("HOME");

            if (!isUnix && string.IsNullOrEmpty(homeDirectory))
            {
                homeDirectory = Environment.ExpandEnvironmentVariables("%HOMEDRIVE%%HOMEPATH%");
            }
            if (string.IsNullOrEmpty(homeDirectory))
            {
                homeDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
            }

            switch (type)
            {
            case DataDirType.RoamingUser:
                parentDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                if (string.IsNullOrEmpty(parentDirectory))
                {
                    parentDirectory = PathType.Combine(homeDirectory, ".config");
                }
                break;

            case DataDirType.LocalUser:
                parentDirectory = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
                if (string.IsNullOrEmpty(parentDirectory))
                {
                    parentDirectory = PathType.Combine(homeDirectory, ".local", "share");
                }
                break;

            case DataDirType.SystemWide:
                parentDirectory = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
                if (string.IsNullOrEmpty(parentDirectory))
                {
                    parentDirectory = isUnix ? "/usr/share" : PathType.Combine(homeDirectory, "\\ProgramData");
                }
                break;

            case DataDirType.Temporary:
                parentDirectory = PathType.GetTempPath();
                break;

            case DataDirType.SavedGameData:
                parentDirectory = Native.GetKnownFolderPath(
                    new Guid("4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4"),
                    isUnix ?
                    PathType.Combine(homeDirectory, ".local/share/games") :
                    PathType.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "My Games")
                    );
                break;

            default:
                throw new InvalidOperationException("Unsupported data directory type: " + type.ToString());
            }

            var  invalids    = PathType.GetInvalidFileNameChars();
            var  dataDirName = new StringBuilder();
            bool isValid;

            // company name subdirectories are common on windows but not on unix
            // therefore, only add the company name if not on unix
            if (!string.IsNullOrEmpty(companyName) && !isUnix)
            {
                foreach (char c in companyName)
                {
                    isValid = true;
                    for (int i = 0; i < invalids.Length; i++)
                    {
                        if (invalids[i] == c)
                        {
                            isValid = false;
                            break;
                        }
                    }
                    dataDirName.Append(isValid ? c : '_');
                }
                dataDirName.Append(PathType.DirectorySeparatorChar);
            }

            foreach (char c in applicationName)
            {
                isValid = true;
                for (int i = 0; i < invalids.Length; i++)
                {
                    if (invalids[i] == c)
                    {
                        isValid = false;
                        break;
                    }
                }
                dataDirName.Append(isValid ? c : '_');
            }

            // check for reserved file names, and do something about it if necessary
            foreach (string part in dataDirName.ToString().Split(PathType.DirectorySeparatorChar))
            {
                isValid = true;

                if (part == "." || part == "..")
                {
                    isValid = false;
                }

                // thanks dos. thos.
                if (!isUnix)
                {
                    if (part.Length == 3)
                    {
                        switch (part.ToUpperInvariant())
                        {
                        case "CON":
                        case "PRN":
                        case "AUX":
                        case "NUL":
                            isValid = false;
                            break;
                        }
                    }
                    else if (part.Length == 4)
                    {
                        switch (part.Substring(0, 3).ToUpperInvariant())
                        {
                        case "COM":
                        case "LPT":
                            isValid = false;
                            break;
                        }
                    }
                }

                if (isValid)
                {
                    parentDirectory = PathType.Combine(parentDirectory, part);
                }
                else
                {
                    parentDirectory = PathType.Combine(parentDirectory, part + "_");
                }
            }

            var dir = new DataDir(parentDirectory);

            dir.CreateIfNotExists();
            return(dir);
        }
Пример #20
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            GetObject go;

            go = new GetObject();
            go.AcceptNothing(true);
            go.AcceptEnterWhenDone(true);
            go.SetCommandPrompt("请选择边界");
            go.GeometryFilter = ObjectType.Curve;

            if (go.Get() != GetResult.Object)
            {
                return(Result.Failure);
            }
            Curve boundCrv = go.Object(0).Curve();

            if (!boundCrv.IsPlanar() || !boundCrv.IsPolyline() || !boundCrv.IsClosed)
            {
                return(Result.Failure);
            }

            boundCrv.GetBoundingBox(Plane.WorldXY, out Box bound);

            var dialog = new SelectFolderDialog()
            {
                Title = "保存位置"
            };

            DialogResult res = dialog.ShowDialog(Rhino.UI.RhinoEtoApp.MainWindow);

            if (res == DialogResult.Ok)
            {
                try
                {
                    Dictionary <string, string> pathMap = new Dictionary <string, string>();

                    foreach (var layer in doc.Layers)
                    {
                        var objects = doc.Objects.FindByLayer(layer);
                        if (!layer.IsVisible || !layer.IsValid || objects.Length == 0)
                        {
                            continue;
                        }

                        string name = layer.FullPath.Replace(Layer.PathSeparator, "$$");

                        string realPath = IOPath.Combine(dialog.Directory, name + ".eps");
                        string tmpPath  = IOPath.Combine(IOPath.GetTempPath(), layer.Id.ToString());

                        var eps = new EncapsulatedPostScript(bound);

                        var objs = SelectAllObjectsInBound(bound, objects);
                        if (objs.Count == 0)
                        {
                            continue;
                        }

                        eps.SaveEPS(objs, tmpPath);

                        pathMap.Add(tmpPath, realPath);
                    }

                    if (pathMap.Count == 0)
                    {
                        return(Result.Cancel);
                    }

                    foreach (KeyValuePair <string, string> item in pathMap)
                    {
                        System.IO.File.Move(item.Key, item.Value);
                        RhinoApp.WriteLine($"已写入, {item.Value}");
                    }

                    System.Diagnostics.Process.Start(dialog.Directory);
                }
                catch (Exception ex)
                {
                    RhinoApp.WriteLine(ex.Message);
                } finally
                {
                    doc.Objects.UnselectAll();
                    doc.Views.Redraw();
                }
            }

            return(Result.Success);
        }
Пример #21
0
 public static string CreateTemporaryPath()
 {
     return(Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()));
 }