Пример #1
0
        // Arkii: Why did you choose ini Dax :<
        public void ReadFromIni(TextReader reader)
        {
            InstalledFilesList = new List<string>();
            RemoveFilesList = new List<string>();
            IngoreFileList = new List<string>();
            IngoreFileList.Add("melder_info.ini");
            bool isMultilineDesc = false;

            while (reader.Peek() != -1)
            {
                string line = reader.ReadLine();
                int sep = line.IndexOf('=');
                if (sep != -1)
                {
                    string name = line.Substring(0, sep).Trim().ToLower();
                    string value = line.Substring(sep + 1).Trim();
                    isMultilineDesc = false;

                    switch (name)
                    {
                        case "title":
                            Name = value;
                            break;
                        case "author":
                            Author = value;
                            break;
                        case "version":
                            Version = value;
                            break;
                        case "compatible":
                        case "patch":
                            Patch = value;
                            break;
                        case "url":
                            AddonPage = value;
                            break;
                        case "source":
                            Source = value;
                            break;
                        case "updateurl":
                            UpdateURL = value;
                            break;
                        case "desc":
                        case "description":
                            isMultilineDesc = true;
                            Description = value;
                            break;
                        case "dest":
                        case "destination":
                            Destination = value;
                            break;
                        case "providertype":
                            try { ProviderType = (AddonProviderType)Enum.Parse(typeof(AddonProviderType), value, true); }
                            catch (Exception) { ProviderType = AddonProviderType.FirefallForums; }
                            break;
                        case "installed":
                            InstalledFilesList.Add(value);
                            break;
                        case "remove":
                            RemoveFilesList.Add(value);
                            break;
                        case "ignore":
                            IngoreFileList.Add(value);
                            break;
                    }
                }
                else if (isMultilineDesc)
                {
                    Description += "\n" + line;
                }
            }

            // Fix up some old addons or misconfigured ones
            if (Destination != null && Statics.FixPathSlashes(Destination).Contains(Statics.DefaultAddonLocation) || Destination == "" )
            {
                Destination = null;
            }

            if (Destination != null && Destination.ToLower().StartsWith("addons/"))
                Destination = Destination.Substring(6);
        }
Пример #2
0
        // Arkii: Why did you choose ini Dax :<
        public void ReadFromIni(TextReader reader)
        {
            InstalledFilesList = new List <string>();
            RemoveFilesList    = new List <string>();
            IngoreFileList     = new List <string>();
            IngoreFileList.Add("melder_info.ini");
            bool isMultilineDesc = false;

            while (reader.Peek() != -1)
            {
                string line = reader.ReadLine();
                int    sep  = line.IndexOf('=');
                if (sep != -1)
                {
                    string name  = line.Substring(0, sep).Trim().ToLower();
                    string value = line.Substring(sep + 1).Trim();
                    isMultilineDesc = false;

                    switch (name)
                    {
                    case "title":
                        Name = value;
                        break;

                    case "author":
                        Author = value;
                        break;

                    case "version":
                        Version = value;
                        break;

                    case "compatible":
                    case "patch":
                        Patch = value;
                        break;

                    case "url":
                        AddonPage = value;
                        // Valadate it
                        Uri  uriResult;
                        bool isValidUrl = Uri.TryCreate(AddonPage, UriKind.Absolute, out uriResult) && (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps);
                        if (!isValidUrl)
                        {
                            AddonPage = "";
                            //Debug.Assert(false);
                        }
                        break;

                    case "source":
                        Source = value;
                        break;

                    case "updateurl":
                        UpdateURL = value;
                        break;

                    case "desc":
                    case "description":
                        isMultilineDesc = true;
                        Description     = value;
                        break;

                    case "dest":
                    case "destination":
                        Destination = value;
                        break;

                    case "providertype":
                        try { ProviderType = (AddonProviderType)Enum.Parse(typeof(AddonProviderType), value, true); }
                        catch (Exception) { ProviderType = AddonProviderType.FirefallForums; }
                        break;

                    case "installed":
                        InstalledFilesList.Add(value);
                        break;

                    case "remove":
                        RemoveFilesList.Add(value);
                        break;

                    case "ignore":
                        IngoreFileList.Add(value);
                        break;
                    }
                }
                else if (isMultilineDesc)
                {
                    Description += "\n" + line;
                }
            }

            // Fix up some old addons or misconfigured ones
            if (Destination != null && Statics.FixPathSlashes(Destination).Contains(Statics.DefaultAddonLocation) || Destination == "")
            {
                Destination = null;
                Debug.WriteLine("Fixed dest in addon/mod: " + Name);
            }

            if (Destination != null && Destination.ToLower().StartsWith("addons/"))
            {
                Destination = Destination.Substring(6);
            }

            Debug.WriteLine(Name + " Dest: " + Destination);
        }