/// <summary>
 /// Loads this instance.
 /// </summary>
 /// <returns>The current plugin list</returns>
 public static PluginList Load()
 {
     string FileLocation = HttpContext.Current != null ? HttpContext.Current.Server.MapPath("~/App_Data/PluginList.txt") : AppDomain.CurrentDomain.BaseDirectory + "/App_Data/PluginList.txt";
     if (!new System.IO.FileInfo(FileLocation).Exists)
         return new PluginList();
     using (StreamReader Reader = new System.IO.FileInfo(FileLocation).OpenText())
     {
         return Deserialize(Reader.ReadToEnd());
     }
 }
        public void WriteLine_Nothing()
        {
            csvReaderWriter.Open(TestOutputFile, CSVReaderWriter.Mode.Write);
            csvReaderWriter.WriteLine();
            csvReaderWriter.Close();

            StreamReader reader = new FileInfo(TestOutputFile).OpenText();
            Assert.That(reader.ReadToEnd(), Is.EqualTo("\r\n"));
            reader.Close();
        }
Example #3
0
 public string ReadFileUTF8(string filePath)
 {
     string ret;
     using (var stream = new FileInfo(filePath).OpenText())
     {
         ret = stream.ReadToEnd();
         stream.Close();
     }
     return ret;
 }
Example #4
0
        public Runner(IRunnerSettings settings, ILogger logger = null)
        {
            if (settings == null)
                throw new ArgumentNullException("settings");

            _settings = settings;
            _logger = logger ?? new NullLogger();
            var configPath = Path.Combine(Directory.GetCurrentDirectory(), "config.json");

            using (var reader = new FileInfo(configPath).OpenText())
                _config = JsonConvert.DeserializeObject<ScriptDeployerConfig>(reader.ReadToEnd());
        }
Example #5
0
        public Map( string _SourceFileName )
        {
            // Setup base directory for files rebasing
            ms_BaseDirectory = Path.GetDirectoryName( _SourceFileName );

            // Parse entities, models & materials
            m_Entities.Clear();
            using ( StreamReader R = new FileInfo( _SourceFileName ).OpenText() ) {
                string	Content = R.ReadToEnd();
                Parse( Content );
            }
        }
Example #6
0
        public override IEnumerable<object[]> GetData(MethodInfo methodUnderTest,
                                                      Type[] parameterTypes)
        {
            if (null == methodUnderTest)
            {
                throw new ArgumentNullException("methodUnderTest");
            }

            if (null == parameterTypes)
            {
                throw new ArgumentNullException("parameterTypes");
            }

#if NET20
            if (Cavity.Collections.IEnumerableExtensionMethods.Count(Files) != parameterTypes.Length)
            {
                throw new InvalidOperationException(StringExtensionMethods.FormatWith(Resources.Attribute_CountsDiffer, Cavity.Collections.IEnumerableExtensionMethods.Count(Files), parameterTypes.Length));
            }
#else
            if (Files.Count() != parameterTypes.Length)
            {
                throw new InvalidOperationException(Resources.Attribute_CountsDiffer.FormatWith(Files.Count(), parameterTypes.Length));
            }

#endif

            var list = new List<object>();
            var index = -1;
            foreach (var file in Files)
            {
                var info = new FileInfo(file);
#if NET20
                var value = FileInfoExtensionMethods.ReadToEnd(info);
#else
                var value = info.ReadToEnd();
#endif
                index++;
                if (parameterTypes[index] == typeof(JObject))
                {
                    list.Add(JObject.Parse(value));
                    continue;
                }

                list.Add(JsonConvert.DeserializeObject(value, parameterTypes[index]));
            }

            yield return list.ToArray();
        }
        public void WriteAllText()
        {
            // Type
            var @this = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Examples_System_IO_FileInfo_WriteAllText.txt"));

            // Intialization
            using (FileStream stream = @this.Create())
            {
            }

            // Examples
            @this.WriteAllText("Fizz" + Environment.NewLine + "Buzz");

            // Unit Test
            Assert.AreEqual("Fizz" + Environment.NewLine + "Buzz", @this.ReadToEnd());
        }
        public void ReadToEnd()
        {
            // Type
            var @this = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Examples_System_IO_FileInfo_ReadToEnd.txt"));

            // Intialization
            using (FileStream stream = @this.Create())
            {
                byte[] byteToWrites = Encoding.Default.GetBytes("Fizz" + Environment.NewLine + "Buzz");
                stream.Write(byteToWrites, 0, byteToWrites.Length);
            }

            // Examples
            string result = @this.ReadToEnd(); // return "Fizz" + Environment.NewLine + "Buzz";

            // Unit Test
            Assert.AreEqual("Fizz" + Environment.NewLine + "Buzz", result);
        }
        /// <summary>
        /// Creates the processor that belongs to this data.
        /// </summary>
        /// <returns></returns>
        public override ProcessorBase CreateProcessor()
        {
            // parse geojson file.
            using(var geoJSONFile = new FileInfo(this.GeoJSONFile).OpenText())
            {
                string geoJson = geoJSONFile.ReadToEnd();
                var geoJsonReader = new GeoJsonReader();

                var featureCollection = geoJsonReader.Read<FeatureCollection>(geoJson) as FeatureCollection;

                foreach (var feature in featureCollection.Features)
                {
                    return new ProcessorFeedFilter()
                    { // create a bounding box filter.
                        Filter = new GTFS.Filters.GTFSFeedStopsFilter((s) =>
                        {
                            return feature.Geometry.Covers(new Point(new Coordinate(s.Longitude, s.Latitude)));
                        })
                    };
                }
            }
            throw new Exception("No geometries found in GeoJSON");
        }
Example #10
0
        void OpenFile(string name)
        {
            _name = name;
            // Open and read the file
            try {
                TextReader reader = new FileInfo(name).OpenText();
                var text = reader.ReadToEnd();
                reader.Dispose();
                var lines = text.Split(new[] {"\r\n"}, StringSplitOptions.RemoveEmptyEntries);

                // Create a new model and solver, and add event listeners
                if (_model != null) {
                    _model.ModelChanged -= HandleModelModelChanged;
                    _solver.ScanFinished -= HandleSolverScanFinished;
                    _solver.Finished -= HandleSolverFinished;
                }
                _model = new SudokuModel(lines.Length);
                _solver = new Solver(_model);
                _model.ModelChanged += HandleModelModelChanged;
                _solver.ScanFinished += HandleSolverScanFinished;
                _solver.Finished += HandleSolverFinished;

                // Update the screen
                _grid.Model = _model;
                _txtProgress.Clear();

                // Load data into the model
                for (var row = 0; row < lines.Length; ++row) {
                    var cells = lines[row].Split(',');
                    for (var col = 0; col < lines.Length; ++col) {
                        if (!string.IsNullOrEmpty(cells[col])) {
                            _model.SetValue(col, row, cells[col][0] - 'A');
                        }
                    }
                }
            } catch (FileNotFoundException) {}
        }
Example #11
0
        public override IEnumerable<object[]> GetData(MethodInfo methodUnderTest,
                                                      Type[] parameterTypes)
        {
            if (null == methodUnderTest)
            {
                throw new ArgumentNullException("methodUnderTest");
            }

            if (null == parameterTypes)
            {
                throw new ArgumentNullException("parameterTypes");
            }

            if (0 == parameterTypes.Length)
            {
                throw new InvalidOperationException("A parameter is required.");
            }

            if (1 != parameterTypes.Length)
            {
                throw new InvalidOperationException("Only one parameter is permitted.");
            }

            var list = new List<object>();
            var info = new FileInfo(File);

            if (parameterTypes[0] == typeof(HttpRequest))
            {
                list.Add(HttpRequest.FromString(info.ReadToEnd()));
            }
            else
            {
                throw new InvalidOperationException("Only Http Request is supported as a parameter type.");
            }

            yield return list.ToArray();
        }
 private void Loadtion(KeyValuePair<String, Script> script)
 {
     var f = new FileInfo(script.Value.sourceFile);
     using (TextReader tr = f.OpenText())
     {
         _sauce = tr.ReadToEnd();
         _name = script.Key;
     }
     if (!String.IsNullOrEmpty(script.Value.refFile))
     {
         using (TextReader trr = new FileInfo(script.Value.refFile).OpenText())
         {
             _refs = trr.ReadToEnd();
         }
     }
 }
Example #13
0
 public void Read(string projectPath)
 {
     try
     {
         LoadedProjectPath = projectPath;
         using(StreamReader reader=new FileInfo(projectPath).OpenText())
             FileContent = reader.ReadToEnd();
     }
     catch (Exception e)
     {
         LastError = e.Message;
     }
 }
        /* Metodo para crear las tablas en la base de datos seleccionada*/
        private bool createDatabase()
        {
            NpgsqlConnection connection;
            NpgsqlCommand command;

            try
            {
                connection = new NpgsqlConnection(connectionString.ToString());

                StreamReader fsSQL = new FileInfo(myNode.Addin.GetFilePath("subscription.sql")).OpenText();
                string SQL_Script = fsSQL.ReadToEnd();
                fsSQL.Close();
                command = new NpgsqlCommand(SQL_Script, connection);

                connection.Open();

                if(command.ExecuteNonQuery() == 0)
                {
                    connection.Close();
                    MessageDialog md = new MessageDialog(null, DialogFlags.Modal, MessageType.Error, ButtonsType.Close, "Error connection");
               		md.Run();
               		md.Destroy();
                    connection.Close();
                    return false;
                }
            }
            catch(NpgsqlException ex)
            {
                MessageDialog md = new MessageDialog(null, DialogFlags.Modal, MessageType.Error, ButtonsType.Close, "Error connection: " + ex.Message);
               	md.Run();
               	md.Destroy();
                connection.Close();
            }

            return true;
        }
Example #15
0
        public override IEnumerable<object[]> GetData(MethodInfo methodUnderTest,
                                                      Type[] parameterTypes)
        {
            if (null == methodUnderTest)
            {
                throw new ArgumentNullException("methodUnderTest");
            }

            if (null == parameterTypes)
            {
                throw new ArgumentNullException("parameterTypes");
            }

#if NET20
            if (Cavity.Collections.IEnumerableExtensionMethods.Count(Files) != parameterTypes.Length)
            {
                throw new InvalidOperationException(StringExtensionMethods.FormatWith(Resources.Attribute_CountsDiffer, Cavity.Collections.IEnumerableExtensionMethods.Count(Files), parameterTypes.Length));
            }
#else
            if (Files.Count() != parameterTypes.Length)
            {
                throw new InvalidOperationException(Resources.Attribute_CountsDiffer.FormatWith(Files.Count(), parameterTypes.Length));
            }
#endif

            var list = new List<object>();
            var index = -1;
            foreach (var file in Files)
            {
                var info = new FileInfo(file);
                index++;

                if (parameterTypes[index] == typeof(DataSet))
                {
                    var data = new DataSet();
                    data.ReadXml(info.FullName, XmlReadMode.Auto);

                    list.Add(data);
                    continue;
                }

                if (parameterTypes[index] == typeof(XmlDocument) || parameterTypes[index] == typeof(IXPathNavigable))
                {
                    var xml = new XmlDocument();
                    xml.Load(info.FullName);

                    list.Add(xml);
                    continue;
                }

                if (parameterTypes[index] == typeof(XPathNavigator))
                {
                    var xml = new XmlDocument();
                    xml.Load(info.FullName);

                    list.Add(xml.CreateNavigator());
                    continue;
                }

#if !NET20
                if (parameterTypes[index] == typeof(XDocument))
                {
                    list.Add(XDocument.Load(info.FullName));
                    continue;
                }
#endif

#if NET20
                list.Add(StringExtensionMethods.XmlDeserialize(FileInfoExtensionMethods.ReadToEnd(info), parameterTypes[index]));
#else
                list.Add(info.ReadToEnd().XmlDeserialize(parameterTypes[index]));
#endif
            }

            yield return list.ToArray();
        }
Example #16
0
        private void Parse( string _Content )
        {
            Parser	P = new Parser( _Content );

            List<Entity>	Entities = new List<Entity>();

            P.ConsumeString( "Version" );
            int	Version = P.ReadInteger();
            if ( Version != 4 )
                P.Error( "Unsupported file version!" );

            while ( P.OK ) {
                P.ConsumeString( "entity" );
                string	Block = P.ReadBlock();

                Entity	E = new Entity( this );
                if ( E.Parse( Block ) ) {
                    Entities.Add( E );
                }

                P.SkipSpaces();
            }

            m_Entities.AddRange( Entities );

            // Parse all refmaps
            foreach ( Entity E in Entities )
                if ( E.m_Type == Entity.TYPE.REF_MAP ) {
                    using ( StreamReader R = new FileInfo( E.m_RefMapName ).OpenText() ) {
                        string	Content = R.ReadToEnd();
                        Parse( Content );
                    }
                }
        }