當前位置: 首頁>>代碼示例>>C#>>正文


C# Reference.RemoveOriginal方法代碼示例

本文整理匯總了C#中System.Reference.RemoveOriginal方法的典型用法代碼示例。如果您正苦於以下問題:C# Reference.RemoveOriginal方法的具體用法?C# Reference.RemoveOriginal怎麽用?C# Reference.RemoveOriginal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Reference的用法示例。


在下文中一共展示了Reference.RemoveOriginal方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Convert

        public bool Convert()
        {
            try {
                richTextBox1.Text = "Core loaded! adding references." + Environment.NewLine;
                reference = new Reference(csproj);
                reference.RemoveOriginal("fNbt");
                reference.RemoveReference("fNbt");
                reference.CreateReference("fNbt", ReferencePaths.FnbtPath);

                reference.RemoveOriginal("System.Threading");
                reference.RemoveReference("System.Threading");
                reference.CreateReference("System.Threading", ReferencePaths.ThreadingPath);

                reference.RemoveOriginal("System.Tuples");
                reference.RemoveReference("System.Tuples");
                reference.CreateReference("System.Tuples", ReferencePaths.TuplePath);

                reference.RemoveOriginal("Newtonsoft.Json");
                reference.RemoveReference("Newtonsoft.Json");
                reference.CreateReference("Newtonsoft.Json", ReferencePaths.NewtonsoftPath);

                reference.ChangeFramework();

                richTextBox1.Text += reference.Status;
                var list = new List<string>();
                DirSearch(list, Path.GetDirectoryName(csproj));

                foreach (string path in list)
                {
                    if (path.Contains(".csproj"))
                    {
                        continue;
                    }

                    StringBuilder builder = new StringBuilder();
                    bool needsTuple = false;
                    foreach (var line in File.ReadAllLines(path))
                    {
                        builder.AppendLine(line);

                        if (line.Contains("using System.Tuples;"))
                        {
                            break;
                        }
                        else if (line.Contains("Tuple"))
                        {
                            needsTuple = true;
                        }
                    }

                    builder.Replace(".Item1", ".Element1");
                    builder.Replace(".Item2", ".Element2");
                    builder.Replace(".Item3", ".Element3");
                    builder.Replace("Tuple.Create", "Tuple.New");
                    string val = Environment.ExpandEnvironmentVariables("%USERPROFILE%").Replace("\\", "/");
                    builder.Replace("Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)", "\"" + val + "\"");
                    builder.Replace("\".truecraft\", \"settings.json\"", "\".truecraft/settings.json\"");

                    if (needsTuple)
                    {
                        File.WriteAllText(path, "using System.Tuples;" + Environment.NewLine + builder.ToString());
                        builder.Clear(); // clear builder to save memeory
                    }
                    else
                    {
                        File.WriteAllText(path, builder.ToString());
                        builder.Clear(); // clear builder to save memeory
                    }
                }
                return true;
            } catch (Exception e)
            {
                richTextBox1.Text += "Converting Core failed!" + Environment.NewLine + e.Message;
                return false;
            }
        }
開發者ID:whalleyboi,項目名稱:TrueCraft-To-.NET-3.5,代碼行數:76,代碼來源:TrueCraft.Core.cs

示例2: Convert

        public bool Convert()
        {
            try
            {
                richTextBox1.Text = "API loaded! adding references." + Environment.NewLine;
                reference = new Reference(csproj);
                reference.RemoveOriginal("fNbt");
                reference.RemoveReference("fNbt");
                reference.CreateReference("fNbt", ReferencePaths.FnbtPath);

                reference.RemoveOriginal("System.Threading");
                reference.RemoveReference("System.Threading");
                reference.CreateReference("System.Threading", ReferencePaths.ThreadingPath);

                reference.RemoveOriginal("System.Tuples");
                reference.RemoveReference("System.Tuples");
                reference.CreateReference("System.Tuples", ReferencePaths.TuplePath);

                reference.RemoveOriginal("YamlDotNet");
                reference.RemoveReference("YamlDotNet");
                reference.CreateReference("YamlDotNet", ReferencePaths.YamlPath);

                reference.ChangeFramework();

                richTextBox1.Text += reference.Status;

                var list = new List<string>();
                DirSearch(list, Path.GetDirectoryName(csproj));

                foreach (string path in list)
                {
                    if (path.Contains(".csproj"))
                    {
                        continue;
                    }

                    StringBuilder builder = new StringBuilder();
                    bool needsTuple = false;
                    foreach (var line in File.ReadAllLines(path))
                    {
                        builder.AppendLine(line);

                        if (line.Contains("using System.Tuples;"))
                        {
                            break;
                        }
                        else if (line.Contains("Tuple"))
                        {
                            needsTuple = true;
                        }
                    }

                    if (needsTuple)
                    {
                        File.WriteAllText(path, "using System.Tuples;" + Environment.NewLine + builder.ToString());
                        builder.Clear(); // clear builder to save memeory
                    }

                    bool modifiedAgain = false;
                    /// Pass #2 for fixes.
                    foreach (var line in File.ReadAllLines(path))
                    {
                        builder.AppendLine(line);
                        if (line.Contains(".Item1"))
                        {
                            builder.Replace(".Item1", ".Element1");
                            modifiedAgain = true;
                        }
                        else if (line.Contains(".Item2"))
                        {
                            builder.Replace(".Item2", ".Element2");
                            modifiedAgain = true;
                        }
                        else if (line.Contains(".Item3"))
                        {
                            builder.Replace(".Item3", ".Element3");
                            modifiedAgain = true;
                        }

                        if (line.Contains("Tuple.Create"))
                        {
                            builder.Replace("Tuple.Create", "Tuple.New");
                            modifiedAgain = true;
                        }
                    }

                    if (modifiedAgain)
                    {
                        File.WriteAllText(path, builder.ToString());
                        builder.Clear(); // clear builder to save memeory
                    }
                }
                return true;
            }
            catch (Exception e)
            {
                richTextBox1.Text += "Converting API failed!" + Environment.NewLine + e.Message;
                return false;
            }
        }
開發者ID:whalleyboi,項目名稱:TrueCraft-To-.NET-3.5,代碼行數:100,代碼來源:TrueCraftAPI.cs

示例3: Convert

        public bool Convert()
        {
            try
            {
                richTextBox1.Text = "Server loaded! adding references." + Environment.NewLine;
                reference = new Reference(csproj);
                reference.RemoveOriginal("fNbt");
                reference.RemoveReference("fNbt");
                reference.CreateReference("fNbt", ReferencePaths.FnbtPath);

                reference.RemoveOriginal("System.Threading");
                reference.RemoveReference("System.Threading");
                reference.CreateReference("System.Threading", ReferencePaths.ThreadingPath);

                reference.RemoveOriginal("System.Tuples");
                reference.RemoveReference("System.Tuples");
                reference.CreateReference("System.Tuples", ReferencePaths.TuplePath);

                reference.RemoveReference("YamlDotNet");
                reference.CreateReference("YamlDotNet", ReferencePaths.YamlPath);
                reference.ChangeFramework();

                richTextBox1.Text += reference.Status;
                var list = new List<string>();
                DirSearch(list, Path.GetDirectoryName(csproj));

                foreach (string path in list)
                {
                    if (path.Contains(".csproj"))
                    {
                        continue;
                    }

                    StringBuilder builder = new StringBuilder();
                    bool needsTuple = false;
                    foreach (var line in File.ReadAllLines(path))
                    {
                        builder.AppendLine(line);

                        if (line.Contains("using System.Tuples;"))
                        {
                            break;
                        }
                        else if (line.Contains("Tuple"))
                        {
                            needsTuple = true;
                        }
                    }

                    builder.Replace(".Item1", ".Element1");
                    builder.Replace(".Item2", ".Element2");
                    builder.Replace(".Item3", ".Element3");
                    builder.Replace("Tuple.Create", "Tuple.New");
                    builder.Replace("Directory.GetCurrentDirectory(), \"players\"", "(Directory.GetCurrentDirectory() + \"/players\")");
                    builder.Replace("new NbtList(\"inventory\", Inventory.GetSlots().Select(s => s.ToNbt())),", "new NbtList(\"inventory\", Inventory.GetSlots().Select(s => (NbtTag)s.ToNbt())),");
                    if (needsTuple)
                    {
                        File.WriteAllText(path, "using System.Tuples;" + Environment.NewLine + builder.ToString());
                        builder.Clear(); // clear builder to save memeory
                    }
                    else
                    {
                        File.WriteAllText(path, builder.ToString());
                        builder.Clear(); // clear builder to save memeory
                    }
                }
                return true;
            }
            catch (Exception e)
            {
                richTextBox1.Text += "Converting API failed!" + Environment.NewLine + e.Message;
                return false;
            }
        }
開發者ID:whalleyboi,項目名稱:TrueCraft-To-.NET-3.5,代碼行數:74,代碼來源:TrueCraft.Server.cs


注:本文中的System.Reference.RemoveOriginal方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。