/// <summary> /// Read file at path, split the contents in chunks and store them together with a StreamChunk. /// </summary> public static ChunkHash GenerateChunk(string path, Repo repo) { StreamChunk message = new StreamChunk (); using (Stream stream = new FileStream(path, FileMode.Open)) { BinaryReader br = new BinaryReader (stream); message.Size = (ulong)stream.Length; while (true) { byte[] data = br.ReadBytes (4096); if (data.Length == 0) break; Chunk c = new Chunk (data); ChunkHash ch = repo.WriteChunk (c); message.Chunks.Add (ch.bytes); } } byte[] messageBytes = StreamChunk.SerializeToBytes (message); Chunk messageChunk = new Chunk (messageBytes); ChunkHash messageHash = repo.WriteChunk (messageChunk); return messageHash; }
public static void Run(Repo localRepo) { Stream stdin = Console.OpenStandardInput (); Stream stdout = Console.OpenStandardOutput (); PipeServer s = new PipeServer (stdin, stdout, localRepo); s.Run (); }
public static ChunkHash GenerateChunk(string path, Repo repo) { string fullPath = Path.GetFullPath (path); TreeChunk tree = new TreeChunk (); //Subdirectories string[] dirs = Directory.GetDirectories (fullPath); foreach (string d in dirs) { TreeFile df = new TreeFile (); df.Name = Path.GetFileName (d); df.TreeChunkHash = TreeChunk.GenerateChunk (d, repo).bytes; tree.Directories.Add (df); } //Files string[] files = Directory.GetFiles (fullPath); foreach (string f in files) { TreeFile ff = new TreeFile (); ff.Name = Path.GetFileName (f); ff.TreeChunkHash = StreamChunk.GenerateChunk (f, repo).bytes; tree.Files.Add (ff); } Chunk treeChunk = new Chunk (TreeChunk.SerializeToBytes (tree)); ChunkHash ch = repo.WriteChunk (treeChunk); return ch; }
private static void OneSide(Repo repo, SyntaxTree local, SyntaxTree remote, SyntaxTree ancestor, string path) { //Fake a call te to GetRemoteChange() by placeing the remote and ancestor trees into the RemoteChangesData list repo.PullRequests.Clear(); repo.PullRequests.Add(new PullRequest { Updated = DateTime.Now, Files = new[] { new Core.RepoFile { BaseTree = ancestor, HeadTree = remote, Filename = path, Status = RepoFile.StatusEnum.Modified, } }, Title = "Fake Pull Request", Url = "http://github.com/example/repo", Number = 1, State = "open", LastWrite = DateTime.MinValue, Base = new PullRequest.HeadBase { Sha = "" }, Head = new PullRequest.HeadBase { Sha = "" }, }); var pr = repo.PullRequests.First(); pr.ParentRepo = repo; pr.ValidFiles.First().ParentPullRequst = pr; var res = Analysis.ForFalsePositive(repo, local); Assert.IsTrue(res.Any()); }
public static void Load(Repo repo) { var nasajpl = new FlickrUser { User = "******" }; repo.Insert (nasajpl); repo.Insert (new TwitterSearch { Search = "nasa" }); }
public static IEnumerable<string> Update(Repo[] repos, Ref[] allNewRefs) { Dictionary<Repo, Ref[]> updates = new Dictionary<Repo, Ref[]>(); var oldRefs = repos.SelectMany(r => r.Refs).ToArray(); foreach (var repo in repos) { var newRefs = allNewRefs.Where(r => r.Alias == repo.Alias).ToArray(); updates[repo] = newRefs; foreach (var r in newRefs) { /* determine what happened */ var existingRef = repo.Refs.FirstOrDefault(q => q.Name == r.Name); if (existingRef != null && existingRef.Sha == r.Sha) continue; yield return CharacterizeChange(existingRef, r, oldRefs); } foreach (var q in repo.Refs) if (!newRefs.Any(r => r.Name == q.Name)) yield return CharacterizeChange(q, null, oldRefs); } foreach (var repo in repos) repo.Refs = updates[repo]; }
public void TestInsert() { var repo = new Repo<Country>(new DbContextFactory()); var country = new Country { Name = "testCountry" }; country = repo.Insert(country); repo.Save(); var country1 = repo.Get(country.Id); Assert.AreEqual(country.Name, country1.Name); }
public static void TestInsert() { var r = new Repo<Country>(new DbContextFactory()); var c = new Country {Name = "Asaaa"}; r.Insert(c); r.Save(); var o = r.Get(c.Id); Assert.AreEqual(c.Name, o.Name); }
public static void ReserveRoom(string person, string roomNumber, DateTime enterTime, DateTime leaveTime) { dynamic repo = new Repo(); dynamic room = repo.GetRoomByNumber(roomNumber); dynamic customer = repo.GetPerson(person); if (customer == null) { customer = repo.AddPerson(person); } room.Reserve(customer, enterTime, leaveTime); }
public static void LoadTest(Repo repo) { Load(repo); repo.Insert(new Blog() { Url = "http://life-with-aspergers.blogspot.com/feeds/posts/default" }); repo.Insert(new Podcast() { Url = "blog.stackoverflow.com" }); repo.Insert(new Podcast() { Url = "noagendashow.com" }); repo.Insert(new FlickrTags() { Tags = "star trek" }); repo.Insert(new CraigslistForSale() { Search = "bike", List="seattle", MinPrice=100, MaxPrice=200 }); }
public static void TestRemove() { var repo = new Repo<Country>(new DbContextFactory()); var country = new Country { Name = "testCountry" }; country = repo.Insert(country); repo.Save(); repo.Delete(country); repo.Save(); var country1 = repo.Get(country.Id); Assert.IsTrue(country1.IsDeleted); }
public static void TestRemove() { var r = new Repo<Country>(new DbContextFactory()); var c = new Country {Name = "a"}; r.Insert(c); r.Save(); r.Delete(c); r.Save(); var o = r.Get(c.Id); Assert.IsTrue(o.IsDeleted); }
static void Main(string[] args) { Console.WriteLine("***\r\nBegin program - WITH logging\r\n"); IRepository<Customer> customerRepo = new Repo<Customer>(); IRepository<Customer> loggerRepo = new LoggerRepository<Customer>(customerRepo); var customer = new Customer { Id = 1, Name = "Tero Testaaja", Address = "Testikatu 1" }; loggerRepo.Add(customer); loggerRepo.Update(customer); loggerRepo.Delete(customer); Console.WriteLine("\r\nEnd program - WITH logging\r\n***"); Console.ReadLine(); }
public static void Extract(Repo store, ChunkHash cid, string targetPath) { Directory.CreateDirectory (targetPath); Chunk c = store.ReadChunk (cid); TreeChunk tree = TreeChunk.Deserialize (c.Data); foreach (TreeFile file in tree.Files) { StreamChunk.Extract (store, ChunkHash.FromHashBytes (file.TreeChunkHash), Path.Combine (targetPath, file.Name)); } foreach (TreeFile subdir in tree.Directories) { TreeChunk.Extract (store, ChunkHash.FromHashBytes (subdir.TreeChunkHash), Path.Combine (targetPath, subdir.Name)); } }
public static void Extract(Repo store, ChunkHash fileHash, string targetPath) { Chunk chunk = store.ReadChunk (fileHash); StreamChunk streamChunk = StreamChunk.Deserialize<StreamChunk> (chunk.Data); using (FileStream file = File.Open(targetPath, FileMode.Create)) { foreach (byte[] hashBytes in streamChunk.Chunks) { Chunk fc = store.ReadChunk (ChunkHash.FromHashBytes (hashBytes)); file.Write (fc.Data, 0, fc.Data.Length); } //Verify length if (file.Length != (long)streamChunk.Size) throw new InvalidDataException ("Invalid file length"); } }
public void IntsToEntities() { WindsorRegistrar.RegisterSingleton(typeof(IRepo<>), typeof(Repo<>)); WindsorRegistrar.RegisterSingleton(typeof(IDbContextFactory), typeof(DbContextFactory)); using (var scope = new TransactionScope()) { var repo = new Repo<cm.Product>(new DbContextFactory()); var product1 = new cm.Product { Name = "a" }; var product2 = new cm.Product { Name = "b" }; product1 = repo.Insert(product1); product2 = repo.Insert(product2); repo.Save(); var promotionInput = new PromotionInput { Products = new List<int> { product1.Id, product2.Id } }; var promotion = new cm.Promotion(); promotion.InjectFrom<IntsToEntities>(promotionInput); Assert.IsNotNull(promotion.Products); Assert.AreEqual(2, promotion.Products.Count); Assert.AreEqual(product1.Id, promotion.Products.First().Id); } }
public void IntsToEntities() { WindsorRegistrar.RegisterSingleton(typeof(IRepo<>), typeof(Repo<>)); WindsorRegistrar.RegisterSingleton(typeof(IDbContextFactory), typeof(DbContextFactory)); using (var scope = new TransactionScope()) { var repo = new Repo<Meal>(new DbContextFactory()); var meal1 = new Meal { Name = "a" }; var meal2 = new Meal { Name = "b" }; meal1 = repo.Insert(meal1); meal2 = repo.Insert(meal2); repo.Save(); var dinnerInput = new DinnerInput { Meals = new List<int> { meal1.Id, meal2.Id } }; var dinner = new Dinner(); dinner.InjectFrom<IntsToEntities>(dinnerInput); Assert.IsNotNull(dinner.Meals); Assert.AreEqual(2, dinner.Meals.Count); Assert.AreEqual(meal1.Id, dinner.Meals.First().Id); } }
public IActionResult GetPreferences() => Repo .GetPreferences() .ToActionResult(x => ToGetPrefReply(x));
public void OneTest() { Repo reposit = new Repo(); reposit.BuildDataList(); }
public void TypeOfToList() { var meta = Repo.GetTypeMeta <Pages>(); var pages = Repo.TypeOf <Pages>().ToList(); }
protected TreeBaseViewModel(Repo repo) : base(repo) { }
public IActionResult Create(OrgRequest r) => Repo .Create(r.ToModel()) .ToActionResult(x => new { x.Value.Id, Message = "Organization created" });
public IActionResult Update(int orgId, OrgRequest r) => Repo .Update(r.ToModel(orgId)) .RefreshToken(ActualUser) .ToActionResult(x => new { Message = "Organization updated", x.Value.Bag.Token });
public JawboneController(Repo.Interfaces.IJawboneRepository repo) { _repo = repo; }
public IActionResult AddMember(int orgId, OrgMembersRequest r) => Repo .AddMember(orgId, r.LoginOrEmail, r.Role) .RevokeToken() .ToActionResult(x => new { Message = "User added to organization" });
public IActionResult UpdateMember(int orgId, int userId, OrgMemberUpdateRequest r) => Repo .UpdateMember(orgId, userId, r.Role.Value) .RevokeToken() .ToActionResult(x => new { Message = "Organization user updated" });
public PartialViewResult Add(int siteID) { var r = Repo.Add(siteID); return(PartialView("View", r)); }
public void Copy_SourceDoesNotExist_ThrowsMercurialExecutionException() { Repo.Init(); Assert.Throws <MercurialExecutionException>(() => Repo.Copy("test1.txt", "test2.txt")); }
public void Copy_NoRepository_ThrowsMercurialExecutionException() { Assert.Throws <MercurialExecutionException>(() => Repo.Copy("test1.txt", "test2.txt")); }
public IActionResult UpdatePreferences(OrgPreferencesRequest r) => Repo .UpdatePreferences(r.ToModel(ActualUser.OrgId)) .RefreshPreferences(ActualUser, DataContext) .RefreshToken(true) .ToActionResult(x => new { Message = "Preferences updated", x.Value.Bag.Token });
public IActionResult GetMembersLookup() => Repo .GetMembers(ActualUser.OrgId) .ToActionResult(x => ToMembersLookupReply(x));
public IActionResult GetMembers(int orgId) => Repo .GetMembers(orgId) .ToActionResult(x => ToMembersReply(x, orgId));
public PipeServer(Stream sin, Stream sout, Repo localRepo) { this.input = sin; this.output = sout; this.localRepo = localRepo; }
public IQueryable <Category> GetAll() { return(Repo.GetAll <Category>()); }
public OpenPgpRepo(Repo backendRepo) : base(backendRepo) { this.Recipients = new List<PgpPublicKey> (); }
private UserMaster GetUserMasterDetails() { var isOperationSuccessful = Getemail(out var email); return(!isOperationSuccessful ? null : Repo.GetUserMaster(email)); }
public RouteRepo(Repo backendRepo) : base(backendRepo) { this.RouteMessage = new RouteMessage (); }
public TreeViewModel(Repo repo) : base(repo) { }
/// <summary> /// Encrypts all chunks before sending them to the backend repo /// </summary> /// <param name="backendRepo"> /// This is where the encrypted chunks are sent /// </param> /// <param name="keyStorage"> /// If decrypting, this is where we look for private keys /// </param> public EncryptedRepo(Repo backendRepo, KeyStorage keyStorage) : base(backendRepo) { this.keyStorage = keyStorage; }
public ActionResult Index() { var repo = new Repo(); return(View(model: repo.Get())); }
public void ReadTree(Tree tree, Repo repo) { ReadTree ("", tree, repo); }
public void GetTypeMetaAll() { var meta = Repo.GetTypeMetaAll(); }
public void ReadTree(string prefix, Tree tree, Repo repo) { TreeEntry[] treeEntries = tree.Entries; foreach (TreeEntry te in treeEntries) { string name; if (!String.IsNullOrEmpty (prefix)) name = String.Format ("{0}/{1}", prefix, te.Name); else name = te.Name; // if (te.IsTree (repo)) // ReadTree (name, tree, repo); } }
public GitHubAuthTest() { var repoLoc = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), nameof(SemDiff),"semdiffdotnet", repository); Directory.CreateDirectory(repoLoc); repo = new Repo(repoLoc, owner, repository); }
public IActionResult RemoveMember(int orgId, int userId) => Repo .RemoveMember(orgId, userId) .RevokeToken() .ToActionResult(x => new { Message = "User removed from organization" });
public void SaveDemo(string sr) { var result = ZedDemo(sr); var thing = new Repo(); _repo.Add(thing); }
public void LastSessionLocalFiles() { repo.AssertRateLimit(); var requests = repo.GetPullRequestsAsync().Result; repo.UpdateLocalSavedList(); var newRepo = new Repo(repo.LocalGitDirectory, repo.Owner, repo.RepoName); newRepo.GetCurrentSaved(); Assert.IsNotNull(newRepo.PullRequests); }
public static CommandRaisesEvent Instance(Repo repo) => new CommandRaisesEvent(repo);
private void Update() { Repo.Modificar(Sala); }
public void TestInit() { repo = GetDummyRepo(nameof(RepoTests), owner, repository); }
public CommandRaisesEvent(Repo repo) { _repo = repo; }