Ejemplo n.º 1
0
        public void LearnFromFiles( string directoryPath )
        {
            IEnumerable< string > allLines = null;
            try
            {
                var files = new DirectoryInfo( directoryPath ).EnumerateFiles( "*.txt" );

                allLines = files.SelectMany( x => File.ReadLines( x.FullName ) );
            }
            catch ( Exception e )
            {
                File.AppendAllText( "C:/ErrorLog.log" ,e.Message +"\nIt Occured On " +DateTime.Now);
                return;
            }
            foreach ( var line in allLines )
            {
                this.LearnFromSentence(line);
            }
        }
Ejemplo n.º 2
0
        public static void Initialize()
        {
            var pluginContainers = new DirectoryInfo(HostingEnvironment.MapPath("~/Plugins"))
                .GetFiles("*.dll", SearchOption.TopDirectoryOnly)
                .Select(f => new
                {
                    //Assembly = AppDomain.CurrentDomain.Load(File.ReadAllBytes(f.FullName)),
                    Assembly = Assembly.Load(AssemblyName.GetAssemblyName(f.FullName)),
                    Name = f.Name
                }).ToList();
            pluginContainers.ForEach(pc => BuildManager.AddReferencedAssembly(pc.Assembly));
            pluginContainers.ForEach(pc => Register(pc.Name, pc.Assembly));

            HostingEnvironment.RegisterVirtualPathProvider(new AssemblyResourceProvider());

            pluginContainers.SelectMany(pc => pc.Assembly.GetTypes())
                            .Where(t => "Bootstrapper".Equals(t.Name, StringComparison.OrdinalIgnoreCase))
                            .Select(t => t.GetMethod("Init", BindingFlags.Static | BindingFlags.Public))
                            .Where(mi => mi != null && !mi.GetParameters().Any() && !mi.IsGenericMethodDefinition)
                            .Select(mi => mi.Invoke(null, null))
                            .ToList();
        }
Ejemplo n.º 3
0
        private IList<Track> MoveFilePacketCheckState(IInternalMusicSession msi, int packect, string iDirectoryIn, string iDirectoryOut, bool FindOriginalFiles)
        {
  
            //packect
            var HalfFiles = new DirectoryInfo(iDirectoryIn).GetFiles().Where(fi => fi.Extension == FileServices.MP3).Take(packect).ToList();
            Assert.That(HalfFiles.Count, Is.EqualTo(packect));

            //string myout = this.TempDirectoryOut;

            //MusicSessionImpl msi = ms as MusicSessionImpl;

            IList<Track> res = null;

            if (FindOriginalFiles)
            {

                var InitialTrack = HalfFiles.SelectMany(fi => msi.Tracks.Find(new FakeTrackDescriptor(fi.FullName))).ToList();
                Assert.That(InitialTrack.Count, Is.EqualTo(packect));
                Assert.That(InitialTrack.All(mt => mt.Precision == MatchPrecision.Exact), Is.True);
                res = InitialTrack.Select(mt => mt.FindItem).ToList();
                Assert.That(res.Count, Is.EqualTo(packect));

                Assert.That(res.Cast<IInternalTrack>().All(tr => tr.InternalState == ObjectState.Available), Is.True);
                
            }

            HalfFiles.Apply(fi => fi.MoveTo(Path.Combine(iDirectoryOut, fi.Name)));

            return res;
        }