private async Task <SourceStatus> IndexSource(IStorageFeed feed, PackageName packageName, ISourceInfo sourceInfo) { var sourceStatus = new SourceStatus(new SourceName(Path.GetFileName(sourceInfo.OriginalPath), sourceInfo.Hash)); try { Debug.WriteLine("Indexing source {0}", sourceStatus.SourceName); await RequestOrSkip(string.Format("src/{0}", sourceStatus.SourceName), async() => { using (var stream = sourceInfo.File.GetStream()) using (var convertedStream = SourceConverter.Convert(stream)) await feed.GetSource(packageName, sourceStatus.SourceName).Put(convertedStream); }); sourceStatus.Stored = true; Debug.WriteLine("Stored source {0}", sourceStatus.SourceName); } catch (Exception e) { support.TrackException(e, new { packageName }); sourceStatus.Exception = new ExceptionStatus(e); } return(sourceStatus); }
private void SetHandView() { SourceConverter converter = new SourceConverter(); ImageButtonList = new List <ImageButton>(); MyGrid.Children.Clear(); MyGrid.ColumnDefinitions.Clear(); for (int i = 0; i < Hand.Count; i++) { ImageButton temp = new ImageButton(); MyGrid.ColumnSpacing = -30; temp.Clicked += new EventHandler(ImageButtonClicked); temp.Source = converter.Convert(Hand[i].Image, null, null, null).ToString(); temp.BackgroundColor = Color.Transparent; ImageButtonList.Add(temp); MyGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); MyGrid.Children.Add(temp, i, 0); MyGrid.Children[i].HorizontalOptions = LayoutOptions.FillAndExpand; MyGrid.Children[i].HeightRequest = MyGrid.Height; MyGrid.Children[i].WidthRequest = MyGrid.Children[i].Height / 1.9; } }
public void UpdateUi(Player p) { CurrentPlayer = p; BindingContext = Deck.LastOrDefault(); PassCardButton.Source = null; PassCardButton.Source = _converter.Convert(Deck.LastOrDefault().Image, null, null, null).ToString(); }
private void TestFromMemory(byte[] originalData, byte[] convertedExpected) { using (var originalStream = new MemoryStream(originalData)) using (var convertedStream = SourceConverter.Convert(originalStream)) { var convertedData = GetData(convertedStream); Compare(convertedData, convertedExpected); } }
private void TestFromFile(string name, byte[] originalExpected, byte[] convertedExpected) { using (var originalStream = GetStream(name)) { var originalData = GetData(originalStream); originalStream.Position = 0; using (var convertedStream = SourceConverter.Convert(originalStream)) { var convertedData = GetData(convertedStream); Compare(originalData, originalExpected); Compare(convertedData, convertedExpected); } } }
private void CreateJob(PackageProject metadata, byte[] data) { string directory = Path.Combine(metadata.Name, metadata.Version.Name); Directory.CreateDirectory(Path.Combine(configuration.DataPath, directory)); string file = Path.Combine(configuration.DataPath, directory, metadata.Name + ".symbols.zip"); File.WriteAllBytes(file, data); using (var zipMemoryStream = new MemoryStream(data)) using (var zipfile = ZipFile.Read(zipMemoryStream)) { var zipInfo = new TransformingWrapperPackageFile(new ZipPackageFile(zipfile), new UrlTransformation()); var addInfo = addInfoBuilder.Build(zipInfo); string binariesDirectory = Path.Combine(directory, "Binaries"); Directory.CreateDirectory(Path.Combine(configuration.DataPath, binariesDirectory)); string sourcesDirectory = Path.Combine(directory, "Sources"); Directory.CreateDirectory(Path.Combine(configuration.DataPath, sourcesDirectory)); foreach (var binaryInfo in addInfo.Binaries) { if (binaryInfo.SymbolInfo == null) { continue; } string binaryDirectory = Path.Combine(binariesDirectory, binaryInfo.Name, binaryInfo.SymbolHash); Directory.CreateDirectory(Path.Combine(configuration.DataPath, binaryDirectory)); using (var binaryInfoStream = binaryInfo.File.Stream) using (var binaryStream = File.OpenWrite(Path.Combine(configuration.DataPath, binaryDirectory, binaryInfo.Name + "." + binaryInfo.Type))) binaryInfoStream.CopyTo(binaryStream); using (var symbolInfoStream = binaryInfo.SymbolInfo.File.Stream) using (var symbolStream = File.OpenWrite(Path.Combine(configuration.DataPath, binaryDirectory, binaryInfo.Name + "." + binaryInfo.SymbolInfo.Type))) symbolInfoStream.CopyTo(symbolStream); string indexDirectory = Path.Combine(configuration.IndexPath, binaryInfo.Name); Directory.CreateDirectory(indexDirectory); File.AppendAllText(Path.Combine(indexDirectory, binaryInfo.SymbolHash + ".txt"), binaryDirectory + Environment.NewLine); var sourceIndex = new List <string>(); foreach (var sourceInfo in binaryInfo.SymbolInfo.SourceInfos.Where(info => info.ActualPath != null)) { string sourcePath = Path.Combine(sourcesDirectory, sourceInfo.KeyPath); Directory.CreateDirectory(Path.Combine(configuration.DataPath, Path.GetDirectoryName(sourcePath))); sourceIndex.Add(sourceInfo.OriginalPath + "|" + sourceInfo.KeyPath); using (var sourceInfoStream = sourceInfo.ActualPath.Stream) using (var convertedStream = SourceConverter.Convert(sourceInfoStream)) using (var sourceStream = File.OpenWrite(Path.Combine(configuration.DataPath, sourcePath))) convertedStream.CopyTo(sourceStream); File.WriteAllLines(Path.Combine(configuration.DataPath, binaryDirectory, binaryInfo.Name + ".txt"), sourceIndex); } } } File.Delete(file); }