/// <summary>
        /// In the given path and all folders below it, load all valid projects, currently only .csproj files
        /// </summary>
        /// <param name="SearchPath"></param>
        /// <returns></returns>
        public ProjectList GetAllProjects()
        {
            //return list of projects
            ProjectList projects = new ProjectList();
            Console.WriteLine("start to fetch .csproj files");
            //get list of all csproj files below current directory
            string[] FilePaths = Directory.GetFiles(SearchPath, "*.csproj", SearchOption.AllDirectories);
            foreach (string FilePath in FilePaths)
            {
                if (!FilePath.ToLower().Contains("mainline") && MainLineOnly.ToUpper().Equals("T"))
                    continue;
                else
                {
                    string FileName = new FileInfo(FilePath).Name;

                    //if not a unit test (Test or UnitTest.csproj, then add it
                    //TODO: refactor to allow exclusions to be passed in?
                    if (!FileName.StartsWith("Test") && !FileName.StartsWith("UnitTest"))
                    {
                        Console.WriteLine(string.Format("Adding project {0} ...", FilePath));
                        projects.Add(new Project(FilePath));
                    }
                }
            }
            return projects;
        }
Beispiel #2
0
        public static void RemoveAssembliesFromGac(string searchPattern)
        {
            var assemblyPaths = GetGacAssemblyPaths(searchPattern);
            var backupPath = Path.Combine(Environment.CurrentDirectory, @"GAC_Backup");

            foreach (var assemblyPath in assemblyPaths)
            {
                // For safety, only allow files with a "MEDSEEK" or "Agatha" prefix to be removed from GAC
                var fileName = new FileInfo(assemblyPath).Name;

                if (fileName.StartsWith("MEDSEEK", StringComparison.OrdinalIgnoreCase) || fileName.StartsWith("Agatha", StringComparison.OrdinalIgnoreCase))
                {
                    LoggingUtils.WriteInfo(string.Format(CultureInfo.InvariantCulture, "Removing assembly ({0}) from GAC", fileName));

                    // Backup assembly
                    BackupAssembly(assemblyPath, backupPath);

                    // Remove assembly from GAC
                    var publisher = new System.EnterpriseServices.Internal.Publish();
                    publisher.GacRemove(assemblyPath);
                }
                else
                    LoggingUtils.WriteWarn(string.Format(CultureInfo.InvariantCulture, "Skipping removal of non-MEDSEEK assembly ({0}) from GAC", fileName));
            }

            LoggingUtils.WriteInfo(string.Format(CultureInfo.InvariantCulture, "GAC assemblies backed up to: ({0})", backupPath), ConsoleColor.Green);
        }
Beispiel #3
0
        static FilePaths()
        {
            _programDirectory = new FileInfo(Application.ResourceAssembly.Location).DirectoryName;

            string pfiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);
            _writeToAppData = _programDirectory.StartsWith(pfiles) || !CheckWritePermissions(Path.Combine(_programDirectory,"writecheck.txt"));

            _AppDataPath = System.IO.Path.GetFullPath(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\NanoTrans");

            CreateTemp();
        }
Beispiel #4
0
 public static string[] GetDatasets(string root)
 {
   var subdirs = Directory.GetDirectories(root);
   Array.Sort(subdirs, delegate(string name1, string name2)
   {
     var n1 = new FileInfo(name1).Name;
     var n2 = new FileInfo(name2).Name;
     if (n1.StartsWith("GSE") && n2.StartsWith("GSE"))
     {
       return int.Parse(n1.Substring(3)).CompareTo(int.Parse(n2.Substring(3)));
     }
     else
     {
       return name1.CompareTo(name2);
     }
   });
   return subdirs;
 }
Beispiel #5
0
        public void Invalidate(Selection selection)
        {
            savedSelection = selection;
            scrollView.Content.Nodes.Clear();
            if (RootWidget.Parent == null)
            {
                return;
            }
            if (selection == null || selection.Empty)
            {
                return;
            }
            var targetDir = new System.IO.FileInfo(selection.First()).Directory.FullName;

            if (Orange.The.Workspace.AssetsDirectory == null || !targetDir.StartsWith(Orange.The.Workspace.AssetsDirectory))
            {
                // We're somewhere outside the project directory
                return;
            }
            var t = Orange.CookingRulesBuilder.Build(new FileEnumerator(Orange.The.Workspace.AssetsDirectory, targetDir), activeTarget);

            foreach (var path in selection)
            {
                CreateEditingInterfaceForPath(t, path);
            }
            scrollView.Content.Presenter = new DelegatePresenter <Widget>((w) => {
                if (cachedZebraTexture == null)
                {
                    cachedZebraTexture = new Texture2D();
                    cachedZebraTexture.LoadImage(new[] { Theme.Colors.ZebraColor1, Theme.Colors.ZebraColor2 }, 1, 2);
                    cachedZebraTexture.TextureParams = new TextureParams {
                        WrapMode     = TextureWrapMode.Repeat,
                        MinMagFilter = TextureFilter.Nearest
                    };
                }

                w.PrepareRendererState();
                Renderer.DrawSprite(cachedZebraTexture, Color4.White, Vector2.Zero, w.Size, Vector2.Zero, w.Size / (Vector2)cachedZebraTexture.ImageSize / RowHeight);
            });
        }
        public static void SendFile(string path, HttpListenerContext context)
        {
            var ext = new FileInfo(path).Extension;
            if (ext.StartsWith("."))
                ext = ext.Remove(0, 1);
            context.Response.ContentType = getContentType(ext);

            byte[] buffer;

            if (context.Response.ContentType == "text/html" || context.Response.ContentType == "text/javascript" || context.Response.ContentType == "text/css")
            {
                using (var rdr = File.OpenText(path))
                {
                    var send = rdr.ReadToEnd();

                    if (ext == "php")
                    {
                        Process p = new Process();
                        p.StartInfo = new ProcessStartInfo("php\\php-cgi.exe", $"-f {path} {GetPhpArgumentQuery(context.Request.QueryString)}")
                        {
                            UseShellExecute = false,
                            RedirectStandardInput = true,
                            RedirectStandardOutput = true,
                            WindowStyle = ProcessWindowStyle.Hidden
                        };
                        p.Start();
                        send = p.StandardOutput.ReadToEnd();
                    }

                    foreach (var toReplace in replaceVars)
                    {
                        var tmp = String.Empty;
                        if (toReplace.Value.StartsWith("PATH"))
                        {
                            using (var r = File.OpenText(toReplace.Value.Split(':')[1]))
                                tmp = r.ReadToEnd();

                            send = send.Replace(toReplace.Key, tmp);
                        }
                        else if (toReplace.Value.StartsWith("PROPERTYCALL"))
                        {
                            var property = context.Request.GetType().GetProperty(toReplace.Value.Split(':')[1]);
                            if (property != null)
                                send = send.Replace(toReplace.Key, property.GetValue(context.Request).ToString());
                        }
                        else
                            send = send.Replace(toReplace.Key, toReplace.Value);
                    }
                    buffer = Encoding.UTF8.GetBytes(send);
                }
            }
            else
            {
                using (Stream s = File.OpenRead(path))
                {
                    buffer = new byte[s.Length];
                    var length = s.Read(buffer, 0, (int)s.Length);
                    Array.Resize(ref buffer, length);
                }
            }
            context.Response.StatusCode = 200;
            context.Response.StatusDescription = "OK";
            context.Response.ContentLength64 = buffer.Length;
            context.Response.OutputStream.Write(buffer, 0, buffer.Length);
        }
        internal string GenerateContent(string templateFilename, string targetFilename, NameValueCollection overrideArguments)
        {
            DTE vs = this.GetService<DTE>(true);

              string templateCode = string.Empty;
              if (templateFilename == null)
              {
            throw new ArgumentNullException("Template");
              }
              string templateBasePath = this.GetTemplateBasePath();
              if (!Path.IsPathRooted(templateFilename))
              {
            templateFilename = Path.Combine(templateBasePath, templateFilename);
              }
              if (!File.Exists(templateFilename))
              {
            throw new FileNotFoundException(templateFilename);
              }
              templateFilename = new FileInfo(templateFilename).FullName;
              if (!templateFilename.StartsWith(templateBasePath))
              {
            throw new ArgumentException("Starts not with " + templateBasePath);
              }
              templateCode = File.ReadAllText(templateFilename);

              //jetzt alle properties rein
              StringBuilder templateCodeLines = new StringBuilder();
              StringReader reader = new StringReader(templateCode);
              string line = "";
              bool firstlinefound = false;
              bool itemadded = false;
              while ((line = reader.ReadLine()) != null)
              {
            if (firstlinefound && !itemadded)
            {
              itemadded = true;
              AddTargetFileNameArgument(templateCodeLines, targetFilename);
              AddAllArguments(templateCodeLines, overrideArguments);
            }
            if (line.StartsWith("<#@ template language="))
            {
              firstlinefound = true;
            }
            templateCodeLines.AppendLine(line);
              }

              return this.Render(templateCodeLines.ToString(), templateFilename);
        }
Beispiel #8
0
        static void RegisterFile(string path)
        {
            var      fileName = new System.IO.FileInfo(path).Name;
            string   animName;
            bool     hasAlphaKey;
            AnimType animType;

            if (fileName.StartsWith("build_char_"))
            {
                animType = AnimType.Build;
                var nameWithExtension = fileName.Substring(15);
                animName = nameWithExtension.Substring(0, nameWithExtension.IndexOf('.'));
            }
            else if (fileName.StartsWith("char_"))
            {
                animType = AnimType.Fight;
                var nameWithExtension = fileName.Substring(9);
                animName = nameWithExtension.Substring(0, nameWithExtension.IndexOf('.'));
            }
            else
            {
                return;
            }

            hasAlphaKey = animName.Contains("[alpha]");
            animName    = animName.Replace("[alpha]", "");
            if (animName.IndexOf('#') >= 0)
            {
                animName = animName.Substring(0, animName.IndexOf('#'));
            }
            animName = animName.Replace(" ", "");

            if (!_fileDictionary.ContainsKey(animName))
            {
                _fileDictionary[animName] = new List <FileInfo>();
            }

            var fileExtensions = path.Split('.');


            if (fileExtensions[fileExtensions.Length - 1] == "png")
            {
                _fileDictionary[animName].Add(new FileInfo {
                    path = path, fileType = hasAlphaKey ? FileType.AlphaImage : FileType.Image, animType = animType
                });
            }
            else if (fileExtensions[fileExtensions.Length - 1] == "txt")
            {
                if (fileExtensions[fileExtensions.Length - 2].StartsWith("skel"))
                {
                    _fileDictionary[animName].Add(new FileInfo {
                        path = path, fileType = FileType.Skel, animType = animType
                    });
                }
                else if (fileExtensions[fileExtensions.Length - 2].StartsWith("atlas"))
                {
                    _fileDictionary[animName].Add(new FileInfo {
                        path = path, fileType = FileType.Atlas, animType = animType
                    });
                }
            }
        }
 // Methods
 public override void Execute()
 {
     if (!String.IsNullOrEmpty(this.templateExpression))
     {
         this.Template = (string)ExpressionEvaluationHelper.EvaluateExpression(
                         (IDictionaryService)GetService(typeof(IDictionaryService)),
                         this.templateExpression);
     }
     string path = this.Template;
     string templateCode = string.Empty;
     if (path == null)
     {
         throw new ArgumentNullException("Template");
     }
     string templateBasePath = base.GetTemplateBasePath();
     if (!Path.IsPathRooted(path))
     {
         path = Path.Combine(templateBasePath, path);
     }
     path = new FileInfo(path).FullName;
     if (!path.StartsWith(templateBasePath))
     {
         throw new ArgumentException(string.Format(CultureInfo.CurrentCulture,Resources.TemplateNotFoundMessage));
     }
     templateCode = File.ReadAllText(path);
     this.Content = base.Render(templateCode, path);
 }
        private void CreateStore()
        {
            string template = @"Text\Store.js.t4";
            string templateBasePath = GetTemplateBasePath();
            if (!Path.IsPathRooted(template))
            {
                template = Path.Combine(templateBasePath, template);
            }
            template = new FileInfo(template).FullName;
            if (!template.StartsWith(templateBasePath))
            {
                throw new ArgumentException("Template Not found");
            }
            string templateCode = File.ReadAllText(template);

            var addProjectItemAction = new AddProjectItemAction();
            addProjectItemAction.Content = Render(templateCode, template).ToString();
            addProjectItemAction.IsValid = true;
            addProjectItemAction.TargetFileName = ModelClassName + "s.js";
            addProjectItemAction.Project = CurrentProject;
            addProjectItemAction.Execute(DteHelper.FindInCollection(CurrentProject.ProjectItems, TemplateConfiguration.GetConfiguration().ExtRootFolderName + "\\Store"));
        }