C# StreamReader.Equals的代码示例

通过代码示例来学习C# StreamReader.Equals方法

通过代码示例来学习编程是非常高效的。
1. 代码示例提供了一个具体而直观的学习环境,使初学者能够立即看到编程概念和语法的实际应用。
2. 通过分析和模仿现有的代码实例,初学者可以更好地理解编程逻辑和算法的工作原理。
3. 代码实例往往涵盖了多种编程技巧和最佳实践,通过学习和模仿这些实例,学习者可以逐步掌握如何编写高效、可读性强和可维护的代码。这对于初学者来说,是一种快速提升编程水平的有效途径。


StreamReader.Equals是C#的System.IO命名空间下中的一个方法, 小编为大家找了一些网络大拿们常见的代码示例,源码中的StreamReader.Equals() 已经帮大家高亮显示了,大家可以重点学习StreamReader.Equals() 方法的写法,从而快速掌握该方法的应用。

StreamReader.Equals的代码示例1 - ReadRegistry()

    using System.IO;

        public Dictionary ReadRegistry()
        {
            Dictionary allRepos = new Dictionary(GVFSPlatform.Instance.Constants.PathComparer);

            using (Stream stream = this.fileSystem.OpenFileStream(
                    Path.Combine(this.registryParentFolderPath, RegistryName),
                    FileMode.OpenOrCreate,
                    FileAccess.Read,
                    FileShare.Read,
                    callFlushFileBuffers: false))
            {
                using (StreamReader reader = new StreamReader(stream))
                {
                    string versionString = reader.ReadLine();
                    int version;
                    if (!int.TryParse(versionString, out version) ||
                        version > RegistryVersion)
                    {
                        if (versionString != null)
                        {
                            EventMetadata metadata = new EventMetadata();
                            metadata.Add("Area", EtwArea);
                            metadata.Add("OnDiskVersion", versionString);
                            metadata.Add("ExpectedVersion", versionString);
                            this.tracer.RelatedError(metadata, "ReadRegistry: Unsupported version");
                        }

                        return allRepos;
                    }

                    while (!reader.EndOfStream)
                    {
                        string entry = reader.ReadLine();
                        if (entry.Length > 0)
                        {
                            try
                            {
                                RepoRegistration registration = RepoRegistration.FromJson(entry);

                                string errorMessage;
                                string normalizedEnlistmentRootPath = registration.EnlistmentRoot;
                                if (this.fileSystem.TryGetNormalizedPath(registration.EnlistmentRoot, out normalizedEnlistmentRootPath, out errorMessage))
                                {
                                    if (!normalizedEnlistmentRootPath.Equals(registration.EnlistmentRoot, GVFSPlatform.Instance.Constants.PathComparison))
                                    {
                                        EventMetadata metadata = new EventMetadata();
                                        metadata.Add("registration.EnlistmentRoot", registration.EnlistmentRoot);
                                        metadata.Add(nameof(normalizedEnlistmentRootPath), normalizedEnlistmentRootPath);
                                        metadata.Add(TracingConstants.MessageKey.InfoMessage, $"{nameof(this.ReadRegistry)}: Mapping registered enlistment root to final path");
                                        this.tracer.RelatedEvent(EventLevel.Informational, $"{nameof(this.ReadRegistry)}_NormalizedPathMapping", metadata);
                                    }
                                }
                                else
                                {
                                    EventMetadata metadata = new EventMetadata();
                                    metadata.Add("registration.EnlistmentRoot", registration.EnlistmentRoot);
                                    metadata.Add("NormalizedEnlistmentRootPath", normalizedEnlistmentRootPath);
                                    metadata.Add("ErrorMessage", errorMessage);
                                    this.tracer.RelatedWarning(metadata, $"{nameof(this.ReadRegistry)}: Failed to get normalized path name for registed enlistment root");
                                }

                                if (normalizedEnlistmentRootPath != null)
                                {
                                    allRepos[normalizedEnlistmentRootPath] = registration;
                                }
                            }
                            catch (Exception e)
                            {
                                EventMetadata metadata = new EventMetadata();
                                metadata.Add("Area", EtwArea);
                                metadata.Add("entry", entry);
                                metadata.Add("Exception", e.ToString());
                                this.tracer.RelatedError(metadata, "ReadRegistry: Failed to read entry");
                            }
                        }
                    }
                }
            }

            return allRepos;
        }
    

开发者ID:microsoft,项目名称:VFSForGit,代码行数:83,代码来源:RepoRegistry.cs

在ReadRegistry()方法中,StreamReader的代码示例类中的Equals的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞

StreamReader.Equals的代码示例2 - Read()

    using System.IO;

        public void Read(string fname)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

            StreamReader reader = File.OpenText(fname);
            string line;

            string current = "";

            Bones = new STSkeleton();
            Dictionary BoneList = new Dictionary();

            int time = 0;
            while ((line = reader.ReadLine()) != null)
            {
                line = Regex.Replace(line, @"\s+", " ");
                string[] args = line.Replace(";", "").TrimStart().Split(' ');

                if (args[0].Equals("triangles") || args[0].Equals("end") || args[0].Equals("skeleton") || args[0].Equals("nodes"))
                {
                    current = args[0];
                    continue;
                }

                if (current.Equals("nodes"))
                {
                    int id = int.Parse(args[0]);
                    STBone b = new STBone(Bones);
                    b.Text = args[1].Replace('"', ' ').Trim();
                    int s = 2;
                    while (args[s].Contains("\""))
                        b.Text += args[s++];
                    b.parentIndex = int.Parse(args[s]);
                    BoneList.Add(id, b);
                }

                if (current.Equals("skeleton"))
                {
                    if (args[0].Contains("time"))
                        time = int.Parse(args[1]);
                    else
                    {
                        if (time == 0)
                        {
                            STBone b = BoneList[int.Parse(args[0])];
                            b.Position = new Vector3(
                                float.Parse(args[1]),
                                float.Parse(args[2]),
                                float.Parse(args[3]));
                            b.EulerRotation = new Vector3(
                                float.Parse(args[4]),
                                float.Parse(args[5]),
                                float.Parse(args[6]));
                            b.Scale = Vector3.One;

                            b.pos = new Vector3(float.Parse(args[1]), float.Parse(args[2]), float.Parse(args[3]));
                            b.rot = STSkeleton.FromEulerAngles(float.Parse(args[6]), float.Parse(args[5]), float.Parse(args[4]));

                            Bones.bones.Add(b);

                            if (b.parentIndex != -1)
                                b.parentIndex = Bones.bones.IndexOf(BoneList[b.parentIndex]);
                        }
                    }
                }
            }
            Bones.reset();

            Thread.CurrentThread.CurrentCulture = CultureInfo.DefaultThreadCurrentCulture;
        }
    

开发者ID:KillzXGaming,项目名称:Switch-Toolbox,代码行数:72,代码来源:SMD.cs

在Read()方法中,StreamReader的代码示例类中的Equals的代码示例方法一共出现了2次, 见黄色背景高亮显示的地方,欢迎大家点赞

StreamReader.Equals的代码示例3 - ExtractProjectsFromSolution()

    using System.IO;

        /// 
        /// Extract all project files from the given Visual Studio solution file
        /// 
        /// The Visual Studio solution from which to extract the projects.
        /// The configuration to use
        /// The platform to use
        /// An enumerable list of project configurations that were extracted from the solution
        private static IEnumerable ExtractProjectsFromSolution(string solutionFile,
          string configuration, string platform)
        {
            string solutionContent, folder = Path.GetDirectoryName(solutionFile);

            using(StreamReader sr = new StreamReader(solutionFile))
            {
                solutionContent = sr.ReadToEnd();
            }

            // Only add projects that are likely to contain assemblies
            MatchCollection projects = reExtractProjectGuids.Matches(solutionContent);

            foreach(Match solutionMatch in projects)
            {
                // See if the project is included in the build and get the configuration and platform
                var reIsInBuild = new Regex(String.Format(CultureInfo.InvariantCulture,
                    @"\{{{0}\}}\.{1}\|{2}\.Build\.0\s*=\s*(?.*?)\|(?.*)",
                    solutionMatch.Groups["GUID"].Value, configuration, platform), RegexOptions.IgnoreCase);

                var buildMatch = reIsInBuild.Match(solutionContent);

                // If the platform is "AnyCPU" and it didn't match, try "Any CPU" (with a space)
                if(!buildMatch.Success && platform.Equals("AnyCPU", StringComparison.OrdinalIgnoreCase))
                {
                    reIsInBuild = new Regex(String.Format(CultureInfo.InvariantCulture,
                        @"\{{{0}\}}\.{1}\|Any CPU\.Build\.0\s*=\s*(?.*?)\|(?.*)",
                        solutionMatch.Groups["GUID"].Value, configuration), RegexOptions.IgnoreCase);

                    buildMatch = reIsInBuild.Match(solutionContent);
                }

                if(buildMatch.Success)
                    yield return new ProjectFileConfiguration(Path.Combine(folder, solutionMatch.Groups["Path"].Value))
                    {
                        Configuration = buildMatch.Groups["Configuration"].Value.Trim(),
                        Platform = buildMatch.Groups["Platform"].Value.Trim()
                    };
            }
        }
    

开发者ID:EWSoftware,项目名称:SHFB,代码行数:49,代码来源:DocumentationSource.cs

在ExtractProjectsFromSolution()方法中,StreamReader的代码示例类中的Equals的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞

StreamReader.Equals的代码示例4 - ExtractPackage()

    using System.IO;

        public static string ExtractPackage(string packageFilePath, string destination)
        {
            string configJson = null;

            if (!string.IsNullOrEmpty(packageFilePath) && File.Exists(packageFilePath) && !string.IsNullOrEmpty(destination))
            {
                ZipManager.Extract(packageFilePath, destination, true, entry =>
                {
                    if (FileHelpers.IsImageFile(entry.Name))
                    {
                        return true;
                    }

                    if (configJson == null && entry.FullName.Equals(ConfigFileName, StringComparison.OrdinalIgnoreCase))
                    {
                        using (Stream stream = entry.Open())
                        using (StreamReader streamReader = new StreamReader(stream, Encoding.UTF8))
                        {
                            configJson = streamReader.ReadToEnd();
                        }
                    }

                    return false;
                }, 100_000_000);
            }

            return configJson;
        }
    

开发者ID:ShareX,项目名称:ShareX,代码行数:30,代码来源:ImageEffectPackager.cs

在ExtractPackage()方法中,StreamReader的代码示例类中的Equals的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞

StreamReader.Equals的代码示例5 - Read()

    using System.IO;

    public bool Read (string filename) {
      if (Chapters.Count > 0)
        return false;
      using (var ism = new StreamReader (filename)) {
        int i = 0;
        while (!ism.EndOfStream) {
          string s = ism.ReadLine ().Trim ();
          if (s.StartsWith ("[")) {
            terminateChapter ();
            if (s.Equals (CHAPTER, StringComparison.InvariantCultureIgnoreCase)) {
              _timebase = new TimeBase ();
              _chapter = new Chapter ();
              i = 0;
            }
          } else
            parseChapter (s, ref i);

        }
        terminateChapter ();
      }
      return true;
    }
    

开发者ID:audiamus,项目名称:AaxAudioConverter,代码行数:24,代码来源:FFMetaData.cs

在Read()方法中,StreamReader的代码示例类中的Equals的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞

本文中的StreamReader.Equals方法示例由csref.cn整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。