GetSectionValuesAsList() public method

Gets all of the values in a section as a list.
/// is a null reference (Nothing in VB) ///
public GetSectionValuesAsList ( string sectionName ) : string>>.List
sectionName string /// Name of the section to retrieve values from. ///
return string>>.List
示例#1
0
        private void FinishedGettingTRE(IAsyncResult theResult)
        {
            CustomeTreCallObject          theObject     = theResult.AsyncState as CustomeTreCallObject;
            List <LauncherData.CustomTre> lstCustomTres = theObject.TheClient.EndGetCustomTre(theResult);

            if (PatchStepFired != null)
            {
                PatchStepFired(this, new PatchingEventArgs(myVariables.Found + " " + lstCustomTres.Count.ToString(), false));
                PatchStepFired(this, new PatchingEventArgs(myVariables.CustomServerDir, true));
            }


            //does our directory even exist?
            if (!Directory.Exists(SWGANHPAth + theObject.Server.SafeFolderName))
            {
                if (PatchStepFired != null)
                {
                    PatchStepFired(this, new PatchingEventArgs(myVariables.NotFound, false));
                }
                CopyRequiredFiles(theObject.Server);
            }
            else
            {
                if (PatchStepFired != null)
                {
                    PatchStepFired(this, new PatchingEventArgs(myVariables.Found, false));
                }
            }

            if (PatchStepFired != null)
            {
                PatchStepFired(this, new PatchingEventArgs(myVariables.ValidatingFiles, true));
            }
            //now to check the files are correctly patched

            IniFiles myFiles = new IniFiles(SWGANHPAth + "\\swg2uu_live.cfg");
            List <KeyValuePair <string, string> > lstStandardFiles = myFiles.GetSectionValuesAsList("SharedFile");


            if (PatchStepFired != null)
            {
                PatchStepFired(this, new PatchingEventArgs(myVariables.Found + " " + lstStandardFiles.Count.ToString(), false));
            }

            bool blnSuccess = true;

            foreach (KeyValuePair <string, string> thePair in lstStandardFiles)
            {
                //prepare the filename
                string strFileName = thePair.Value.Substring(1, thePair.Value.Length - 2);

                //is it a file?
                if (File.Exists(strFileName))
                {
                    using (FileStream fileIn = new FileStream(strFileName, FileMode.Open, FileAccess.Read))
                    {
                        byte[] arMD5Bytes = hashmd5.ComputeHash(fileIn);

                        //find the file in the Standard List
                        StandardTre theCurrentFile = myUserPreferences.CachedStandardTre.Find(st => st.Filename.Equals(Path.GetFileName(strFileName), StringComparison.InvariantCultureIgnoreCase));

                        if (theCurrentFile != null)
                        {
                            if (PatchStepFired != null)
                            {
                                PatchStepFired(this, new PatchingEventArgs(myVariables.Validating + " " + Path.GetFileName(strFileName), true));

                                if (BitConverter.ToString(arMD5Bytes).Replace("-", "") == theCurrentFile.MD5Hash)
                                {
                                    PatchStepFired(this, new PatchingEventArgs(myVariables.Passed, false));
                                }
                                else
                                {
                                    PatchStepFired(this, new PatchingEventArgs(myVariables.Failed, false));

                                    //something failed
                                    blnSuccess = false;
                                }
                            }
                        }
                    }
                }
            }

            if (PatchFunctionComplete != null)
            {
                string strPatchCompleteMessage = myVariables.ClientUpToDate;
                if (!blnSuccess)
                {
                    strPatchCompleteMessage = myVariables.ClientOutOfDate + Environment.NewLine + myVariables.PatchFromSWG;
                }
                PatchFunctionComplete(this, new PatchFunctionCompleteEventArgs(strPatchCompleteMessage, blnSuccess));
            }
        }
        private void FinishedGettingTRE(IAsyncResult theResult)
        {
            CustomeTreCallObject theObject =  theResult.AsyncState as CustomeTreCallObject;
            List<LauncherData.CustomTre> lstCustomTres = theObject.TheClient.EndGetCustomTre(theResult);

            if (PatchStepFired != null)
            {
                PatchStepFired(this, new PatchingEventArgs(myVariables.Found + " " + lstCustomTres.Count.ToString(), false));
                PatchStepFired(this, new PatchingEventArgs(myVariables.CustomServerDir, true));
            }

            //does our directory even exist?
            if (!Directory.Exists(SWGANHPAth + theObject.Server.SafeFolderName))
            {
                if (PatchStepFired != null)
                {
                    PatchStepFired(this, new PatchingEventArgs(myVariables.NotFound, false));
                }
                CopyRequiredFiles(theObject.Server);
            }
            else
            {
                if (PatchStepFired != null)
                {
                    PatchStepFired(this, new PatchingEventArgs(myVariables.Found, false));
                }
            }

            if (PatchStepFired != null)
            {
                PatchStepFired(this, new PatchingEventArgs(myVariables.ValidatingFiles, true));
            }
            //now to check the files are correctly patched

            IniFiles myFiles = new IniFiles(SWGANHPAth + "\\swg2uu_live.cfg");
            List<KeyValuePair<string,string>> lstStandardFiles = myFiles.GetSectionValuesAsList("SharedFile");

            if (PatchStepFired != null)
            {
                PatchStepFired(this, new PatchingEventArgs(myVariables.Found + " " + lstStandardFiles.Count.ToString(), false));
            }

            bool blnSuccess = true;
            foreach (KeyValuePair<string,string> thePair in lstStandardFiles)
            {
                //prepare the filename
                string strFileName = thePair.Value.Substring(1, thePair.Value.Length - 2);

                //is it a file?
                if (File.Exists(strFileName))
                {
                    using (FileStream fileIn = new FileStream(strFileName, FileMode.Open, FileAccess.Read))
                    {
                        byte[] arMD5Bytes = hashmd5.ComputeHash(fileIn);

                        //find the file in the Standard List
                        StandardTre theCurrentFile = myUserPreferences.CachedStandardTre.Find(st => st.Filename.Equals(Path.GetFileName(strFileName), StringComparison.InvariantCultureIgnoreCase));

                        if (theCurrentFile != null)
                        {
                            if (PatchStepFired != null)
                            {
                                PatchStepFired(this, new PatchingEventArgs(myVariables.Validating + " " + Path.GetFileName(strFileName), true));

                                if (BitConverter.ToString(arMD5Bytes).Replace("-", "") == theCurrentFile.MD5Hash)
                                {
                                    PatchStepFired(this, new PatchingEventArgs(myVariables.Passed, false));
                                }
                                else
                                {
                                    PatchStepFired(this, new PatchingEventArgs(myVariables.Failed, false));

                                    //something failed
                                    blnSuccess = false;
                                }
                            }
                        }
                    }
                }
            }

            if (PatchFunctionComplete != null)
            {
                string strPatchCompleteMessage = myVariables.ClientUpToDate;
                if(!blnSuccess)
                {
                    strPatchCompleteMessage = myVariables.ClientOutOfDate + Environment.NewLine + myVariables.PatchFromSWG;
                }
                PatchFunctionComplete(this, new PatchFunctionCompleteEventArgs(strPatchCompleteMessage, blnSuccess));
            }
        }