Ejemplo n.º 1
0
        public static Credentials Load(SourceReader source)
        {
            using (source)
            {
                var reader = source.GetReader();
                var tokens = new Credentials();

                string line = null;

                while ((line = reader.ReadLine()) != null)
                {
                    try
                    {
                        if (String.IsNullOrWhiteSpace(line))
                        {
                            continue;
                        }
                        if (line.TrimStart().StartsWith("#"))
                        {
                            continue;
                        }

                        var parts = line.Split(' ');
                        if (parts.Length != 2)
                        {
                            Console.WriteLine("Token de autorização mal formado: " + line);
                            continue;
                        }

                        var uri           = parts[0];
                        var encryptedData = parts[1];

                        var token = new Credential();
                        token.SetEncriptedData(encryptedData);

                        tokens.Add(uri, token);
                    }
                    catch (Exception ex)
                    {
                        throw new PackDmException(
                                  "Falhou a tentativa de interpretar o arquivo de configuração.\nPróximo de:\n  " + line,
                                  ex);
                    }
                }

                return(tokens);
            }
        }
Ejemplo n.º 2
0
        public static Model.Index Load(SourceReader source)
        {
            using (source)
            {
                var reader = source.GetReader();
                var index  = new Model.Index();

                Artifact artifact = null;

                string line = null;
                while ((line = reader.ReadLine()) != null)
                {
                    line = line.Trim();

                    if (String.IsNullOrEmpty(line))
                    {
                        continue;
                    }
                    if (line.StartsWith("#"))
                    {
                        continue;
                    }

                    var isDependency = line.StartsWith("+");
                    if (isDependency)
                    {
                        Artifact dependency = line.Split('+').Last().Trim();
                        index.RegisterConstraint(artifact, dependency);
                    }
                    else
                    {
                        artifact = line;
                        index.Add(artifact);
                    }
                }

                return(index);
            }
        }
Ejemplo n.º 3
0
        public SchemaFile Deserialize(SourceReader source)
        {
            using (source)
            {
                var file   = new SchemaFile();
                var reader = source.GetReader();

                string line = null;
                while ((line = reader.ReadLine()) != null)
                {
                    if (line.TrimStart().StartsWith("#"))
                    {
                        var text = line.Trim();
                        text = text.Substring(1);
                        file.AddComment(text);
                    }
                    else if (line.Trim().Length == 0)
                    {
                        file.AddEmptyLine();
                    }
                    else if (line.StartsWith(" "))
                    {
                        var value = line.Trim();
                        if (value == "(null)")
                        {
                            value = null;
                        }
                        file.AddValue(value);
                    }
                    else
                    {
                        file.AddProperty(line.Trim());
                    }
                }

                return(file);
            }
        }