本文整理汇总了C#中Blob类的典型用法代码示例。如果您正苦于以下问题:C# Blob类的具体用法?C# Blob怎么用?C# Blob使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Blob类属于命名空间,在下文中一共展示了Blob类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PutAsync
public async Task<Hash> PutAsync(long id, SemanticVersion version, IPackage package)
{
#region Preconditions
if (package == null) throw new ArgumentNullException(nameof(package));
#endregion
var key = id.ToString() + "/" + version.ToString();
using (var ms = new MemoryStream())
{
await package.ZipToStreamAsync(ms).ConfigureAwait(false);
var hash = Hash.ComputeSHA256(ms, leaveOpen: true);
var blob = new Blob(ms) {
ContentType = "application/zip"
};
await bucket.PutAsync(key, blob).ConfigureAwait(false);
return hash;
}
}
示例2: EncryptedContent
/// <summary>
/// Create an EncryptedContent where all the values are unspecified.
/// </summary>
///
public EncryptedContent()
{
this.algorithmType_ = net.named_data.jndn.encrypt.algo.EncryptAlgorithmType.NONE;
this.keyLocator_ = new KeyLocator();
this.initialVector_ = new Blob();
this.payload_ = new Blob();
}
示例3: ComputeGrid
public bool[][] ComputeGrid(Blob[] blobs)
{
int sizeX = (int)(_gridBound.rect.width / GridStep) + 1;
int sizeY = (int)(_gridBound.rect.height / GridStep) + 1;
var grid = new bool[sizeY][];
for (int i = 0; i < sizeY; i++)
grid[i] = new bool[sizeX];
for (int i = 0; i < sizeY; i++)
for (int j = 0; j < sizeX; j++)
{
float y = _gridBound.offsetMin.y + i * GridStep;
float x = _gridBound.offsetMin.x + j * GridStep;
var pos = new Vector2(x, y);
float totalWeigth = 0;
foreach (Blob blob in blobs)
{
float distance = Vector2.Distance(pos, blob.transform.position);
float weight = blob.WeightFunction(distance);
if (weight < 0)
weight = 0;
totalWeigth += weight;
}
grid[i][j] = totalWeigth > WeightThreshold;
}
return grid;
}
示例4: testData
public static void testData() {
byte[] origData = new byte[1024];
for (int i = 0; i < origData.Length; i++) {
origData[i] = (byte)i;
}
{
Blob blob = new Blob(origData, "application/octet-stream");
Debug.Assert(origData.Length == blob.getSize());
for (int i = 0; i < origData.Length; i++) {
Debug.Assert(origData[i] == blob.getData()[i]);
}
}
Data data = new Data(origData, "application/octet-stream");
Blob blob2 = data.getBinary();
byte[] newData = blob2.getData();
if (newData.Length == origData.Length);
for (int i = 0; i < origData.Length; i++) {
Debug.Assert(newData[i] == origData[i]);
}
}
示例5: VenueMapNotFoundViewModel
public VenueMapNotFoundViewModel(Blob blob, FourOhFourReason reason)
{
Reason = reason;
Blob = blob;
Month = string.Empty;
Year = DateTime.Now.Year.ToString();
}
示例6: ToGitObject
public IStorableObject ToGitObject(Repository repo, string sha)
{
using (GitObjectReader objectReader = new GitObjectReader(Content))
{
IStorableObject obj;
switch (Type)
{
case ObjectType.Commit:
obj = new Commit(repo, sha);
break;
case ObjectType.Tree:
obj = new Tree(repo, sha);
break;
case ObjectType.Blob:
obj = new Blob(repo, sha);
break;
case ObjectType.Tag:
obj = new Tag(repo, sha);
break;
default:
throw new NotImplementedException();
}
obj.Deserialize(objectReader);
return obj;
}
}
示例7: GetWithPrefix
public HashSet<string> GetWithPrefix(string prefix, int maxSize)
{
Blob<HashSet<KeyValuePair<string, string>>> rootBlob = new Blob<HashSet<KeyValuePair<string, string>>>(dir.GetBlobReference("root"));
HashSet<KeyValuePair<string, string>> set = rootBlob.Get();
set.RemoveWhere((p) => p.Key.StartsWith(prefix));
return new HashSet<string>(set.Select((p) => p.Value));
}
示例8: ListFilesInSpecificFolder
//List all files in a specific folder(for example, folder name: a/b/c). return the list of blob info.
public List<Blob> ListFilesInSpecificFolder(string container, string folderName)
{
BlobStorage blobStorage = new BlobStorage(container);
//Add prefix before listing all files
string blobPrefix = folderName + "/";
if (string.IsNullOrEmpty(folderName) || string.IsNullOrWhiteSpace(folderName))
{
blobPrefix = null;
}
//Not to list the files in subfolder
bool useFlatBlobListing = false;
var blobs = blobStorage.Container.ListBlobs(blobPrefix, useFlatBlobListing, BlobListingDetails.None);
//To get all files
var files = blobs.Where(b => b as CloudBlobDirectory == null).ToList();
var list = new List<Blob>();
foreach (var file in files)
{
var blob = new Blob();
//To get blob info
blob.Name = Path.GetFileName(file.Uri.ToString());
blob.Uri = file.Uri.ToString();
list.Add(blob);
}
return list;
}
示例9: ListFoldersInRootOfContainer
//List all foders in the root of the container
public List<Blob> ListFoldersInRootOfContainer(string container)
{
BlobStorage blobStorage = new BlobStorage(container);
string blobPrefix = null;
//Not to list the files in subfolder
bool useFlatBlobListing = false;
var blobs = blobStorage.Container.ListBlobs(blobPrefix, useFlatBlobListing, BlobListingDetails.None);
//To get all the directory
var folders = blobs.Where(b => b as CloudBlobDirectory != null).ToList();
var list = new List<Blob>();
string folderName;
foreach (var folder in folders)
{
var blob = new Blob();
//Get the folder name
folderName = folder.Uri.ToString();
folderName = folderName.Substring(0, folderName.Length - 1);
folderName = folderName.Substring(folderName.LastIndexOf("/") + 1);
//Assign the folder name and Uri
blob.Name = folderName;
blob.Uri = folder.Uri.ToString();
list.Add(blob);
}
//Return the list
return list;
}
示例10: BlobStream
internal BlobStream(ConnectPackageCreationParameters connectPackageParameters, Blob blob)
{
_connectPackageParameters = connectPackageParameters;
_blob = blob;
_length = blob.ContentLength;
_canWrite = true;
}
示例11: AttachBlobs
public void AttachBlobs()
{
Blob blob = new Blob(IOHelper.CreateTempFile("This is just a note.")).SetFilename("note1.txt");
Entity result = client.Operation("Blob.Attach")
.SetInput(blob)
.SetParameter("document", blobContainer.Path)
.Execute()
.Result;
Assert.True(result is Blob);
Assert.Equal("This is just a note.", IOHelper.ReadText(((Blob)result).File));
BlobList blobs = new BlobList();
blobs.Add(new Blob(IOHelper.CreateTempFile("This is another note.")).SetFilename("note2.txt"));
blobs.Add(Blob.FromFile("Puppy.docx"));
result = client.Operation("Blob.Attach")
.SetInput(blobs)
.SetParameter("document", blobContainer.Path)
.SetParameter("xpath", "files:files")
.Execute()
.Result;
Assert.True(result is BlobList);
Assert.Equal(2, blobs.Count);
Assert.Equal("This is another note.", IOHelper.ReadText(blobs[0].File));
Assert.True(IOHelper.AreFilesEqual("Puppy.docx", blobs[1].File.FullName));
}
示例12: FourOhFourViewModel
public FourOhFourViewModel(FourOhFourReason reason, Blob blob)
{
Reason = reason;
Blob = blob;
Month = string.Empty;
Year = DateTime.Now.Year.ToString();
}
示例13: Equals
public override bool Equals(Blob blob)
{
var sb = blob as StreamBlob;
if (sb != null)
{
if (_stream == sb._stream) return true;
var fsa = _stream as FileStream;
if (fsa == null) return false;
var fsb = sb._stream as FileStream;
if (fsb == null) return false;
try
{
return fsa.Name.Equals(fsb.Name);
}
catch
{
return false;
}
}
var fb = blob as FileBlob;
if (fb == null) return false;
var fs = _stream as FileStream;
if (fs == null) return false;
try
{
return fb.Filename.Equals(fs.Name);
}
catch
{
return false;
}
}
示例14: WritePEImage
private static void WritePEImage(
Stream peStream,
MetadataBuilder metadataBuilder,
BlobBuilder ilBuilder,
MethodDefinitionHandle entryPointHandle,
Blob mvidFixup = default(Blob),
byte[] privateKeyOpt = null)
{
var peBuilder = new ManagedPEBuilder(
entryPointHandle.IsNil ? PEHeaderBuilder.CreateLibraryHeader() : PEHeaderBuilder.CreateExecutableHeader(),
new MetadataRootBuilder(metadataBuilder),
ilBuilder,
entryPoint: entryPointHandle,
flags: CorFlags.ILOnly | (privateKeyOpt != null ? CorFlags.StrongNameSigned : 0),
deterministicIdProvider: content => s_contentId);
var peBlob = new BlobBuilder();
var contentId = peBuilder.Serialize(peBlob);
if (!mvidFixup.IsDefault)
{
new BlobWriter(mvidFixup).WriteGuid(contentId.Guid);
}
if (privateKeyOpt != null)
{
peBuilder.Sign(peBlob, content => SigningUtilities.CalculateRsaSignature(content, privateKeyOpt));
}
peBlob.WriteContentTo(peStream);
}
示例15: EndTurnAction
public void EndTurnAction(Blob blob)
{
if (blob.Damage >= blob.InitialDamage + DamageReducedEveryTurn)
{
blob.Damage -= DamageReducedEveryTurn;
}
}