本文整理汇总了C#中Metadata类的典型用法代码示例。如果您正苦于以下问题:C# Metadata类的具体用法?C# Metadata怎么用?C# Metadata使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Metadata类属于命名空间,在下文中一共展示了Metadata类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateStorageProviderItem
private static StorageProviderItem CreateStorageProviderItem(StorageProviderItem parent, Metadata item)
{
var result = new StorageProviderItem
{
Name = item.Name,
Id = Path.Combine(parent.Id, item.PathLower),
ParentReferenceId = parent.Id
};
if (item.IsFile)
{
result.Type = StorageProviderItemType.File;
// result.Id = item.AsFile.Id; // Path.Combine(parent.Id, item.PathLower)
result.LastModifiedDateTime = item.AsFile.ServerModified;
}
else if (item.IsFolder)
{
result.Type = StorageProviderItemType.Folder;
// result.Id = item.AsFolder.Id; // Path.Combine(parent.Id, item.PathLower);
}
else
{
result.Type = StorageProviderItemType.Unknown;
}
return result;
}
示例2: PdbInfo
public unsafe PdbInfo(IO.FileStream inputStream, Metadata.Reader reader)
{
this.reader = reader;
this.pdbFunctionMap = PdbFile.LoadFunctionMap(inputStream, out tokenToSourceMapping, out sourceServerData, reader);
//inputStream.Seek(0L, IO.SeekOrigin.Begin);
//this.remapTable = PdbFile.LoadRemapTable(inputStream);
}
示例3: Asset
public Asset (string name, string desc, Model[] models, Metadata data, Location location) {
this.name = name;
this.desc = desc;
this.models = models;
this.data = data;
this.location = location;
}
示例4: Extract
public TextExtractionResult Extract(Func<Metadata, InputStream> streamFactory)
{
try
{
var parser = new AutoDetectParser();
var metadata = new Metadata();
var outputWriter = new StringWriter();
var parseContext = new ParseContext();
//use the base class type for the key or parts of Tika won't find a usable parser
parseContext.set(typeof(org.apache.tika.parser.Parser), parser);
using (var inputStream = streamFactory(metadata))
{
try
{
parser.parse(inputStream, getTransformerHandler(outputWriter), metadata, parseContext);
}
finally
{
inputStream.close();
}
}
return assembleExtractionResult(outputWriter.ToString(), metadata);
}
catch (Exception ex)
{
throw new TextExtractionException("Extraction failed.", ex);
}
}
示例5: GetMetadataMapping
/// <summary>
/// The order mapping is a file named order in the same virtual path.
/// </summary>
private static Func<string, Metadata> GetMetadataMapping(string virtualPath) {
var vpp = HostingEnvironment.VirtualPathProvider;
string metadataFile = VirtualPathUtility.AppendTrailingSlash(virtualPath) + MetadataFile;
var mapping = new Dictionary<string, Metadata>();
int index = 0;
if (vpp.FileExists(metadataFile)) {
VirtualFile file = vpp.GetFile(metadataFile);
Stream stream = file.Open();
using (var reader = new StreamReader(stream)) {
string line = null;
while ((line = reader.ReadLine()) != null) {
mapping[Normalize(line)] = new Metadata {
Order = index++
};
}
}
}
return title => {
Metadata metadata;
if (mapping.TryGetValue(title, out metadata)) {
return metadata;
}
return Metadata.Empty;
};
}
示例6: Should_Schedule_Reconnections_In_The_Background
public void Should_Schedule_Reconnections_In_The_Background()
{
var lbp = new RoundRobinPolicy();
var config = new Configuration(
new Cassandra.Policies(lbp, new ConstantReconnectionPolicy(1000), FallthroughRetryPolicy.Instance),
new ProtocolOptions(),
null,
new SocketOptions(),
new ClientOptions(),
NoneAuthProvider.Instance,
null,
new QueryOptions(),
new DefaultAddressTranslator());
var testCluster = TestClusterManager.GetNonShareableTestCluster(1, DefaultMaxClusterCreateRetries, true, false);
var metadata = new Metadata(config);
metadata.AddHost(new IPEndPoint(IPAddress.Parse(testCluster.InitialContactPoint), ProtocolOptions.DefaultPort));
var clusterMock = new Mock<ICluster>();
clusterMock.Setup(c => c.AllHosts()).Returns(() => metadata.Hosts.ToCollection());
lbp.Initialize(clusterMock.Object);
using (var cc = NewInstance(testCluster, config, metadata))
{
cc.Init();
var host = metadata.Hosts.First();
testCluster.Stop(1);
host.SetDown();
Thread.Sleep(2000);
Assert.False(host.IsUp);
testCluster.Start(1);
host.BringUpIfDown();
//Should reconnect using timer
Thread.Sleep(5000);
Assert.DoesNotThrow(() => cc.Query("SELECT key FROM system.local", false));
}
testCluster.ShutDown();
}
示例7: SaveData
public async Task<Metadata> SaveData(StoreLocation location, Metadata metadata, UpdateAuditInfo audit, Func<IWriteAsyncStream, Task<long?>> savingFunc, CancellationToken token)
{
var current = await GetMetadata(location).ConfigureAwait(false);
var info = current == null ? new AuditInfo() : current.Audit;
info.UpdatedBy = audit == null ? "0" : audit.UpdatedBy;
info.UpdatedByName = audit == null ? string.Empty : audit.UpdatedByName;
info.UpdatedOn = DateTime.UtcNow;
info.CreatedBy = info.CreatedBy ?? info.UpdatedBy;
info.CreatedByName = info.CreatedByName ?? info.UpdatedByName;
info.CreatedOn = info.CreatedOn ?? info.UpdatedOn;
metadata = metadata ?? new Metadata();
metadata.Audit = info;
var key = GetObjectKey(location);
long? length = null;
using(var stream = new AmazonMultiUploadStream(_client, _bucket, key, metadata))
{
length = await savingFunc(stream).ConfigureAwait(false);
await stream.Complete(token).ConfigureAwait(false);
metadata.Snapshot = stream.VersionId;
}
if (length.HasValue && (metadata == null || !metadata.ContentLength.HasValue))
{
metadata[MetadataConstants.ContentLengthMetadataKey] = length.Value.ToString(CultureInfo.InvariantCulture);
// Save the length straight away before the snapshot...
metadata = await SaveMetadata(location, metadata).ConfigureAwait(false);
}
return metadata;
}
示例8: TestConstructFromDictionary1
public void TestConstructFromDictionary1()
{
string owner = "Washington State University Libraries";
string ownerGroup = "Washington State University";
string[] coOwners = { "CoOwner1", "CoOwner2" };
long created = DateTime.Now.ToBinary();
long updated = DateTime.Now.AddDays(1).ToBinary();
string target = "http://wsulibs.wsu.edu/";
string status = Metadata.MetadataStatus.Public;
IDictionary<string, string> map = new Dictionary<string, string>();
map.Add(Metadata.MetadataKeys.Owner, owner);
map.Add(Metadata.MetadataKeys.OwnerGroup, ownerGroup);
map.Add(Metadata.MetadataKeys.CoOwners, string.Join(";", coOwners));
map.Add(Metadata.MetadataKeys.Created, created.ToString());
map.Add(Metadata.MetadataKeys.Updated, updated.ToString());
map.Add(Metadata.MetadataKeys.Target, target);
map.Add(Metadata.MetadataKeys.Status, status);
Metadata metadata = new Metadata(map);
Assert.IsTrue(metadata.Owner == owner);
Assert.IsTrue(metadata.OwnerGroup == ownerGroup);
Assert.IsTrue(metadata.CoOwners.Count == coOwners.Length);
Assert.IsTrue(metadata.CoOwners[0] == coOwners[0]);
Assert.IsTrue(metadata.CoOwners[1] == coOwners[1]);
Assert.IsTrue(metadata.Created == created);
Assert.IsTrue(metadata.Updated == updated);
Assert.IsTrue(metadata.Target == target);
Assert.IsTrue(metadata.Status == status);
}
示例9: ReadHeader
public static List<IWriteFile> ReadHeader(string path)
{
List<IWriteFile> subfiles = null;
using (BinaryReader reader = new BinaryReader(File.OpenRead(path)))
{
if (!VerifyHeader(path))
throw new InvalidDataException("The supplied file is not a PP archive.");
byte[] versionHeader = reader.ReadBytes(8);
int version = BitConverter.ToInt32(DecryptHeaderBytes(reader.ReadBytes(4)), 0);
DecryptHeaderBytes(reader.ReadBytes(1)); // first byte
int numFiles = BitConverter.ToInt32(DecryptHeaderBytes(reader.ReadBytes(4)), 0);
byte[] buf = DecryptHeaderBytes(reader.ReadBytes(numFiles * 288));
subfiles = new List<IWriteFile>(numFiles);
for (int i = 0; i < numFiles; i++)
{
int offset = i * 288;
ppSubfile subfile = new ppSubfile(path);
subfile.Name = Utility.EncodingShiftJIS.GetString(buf, offset, 260).TrimEnd(new char[] { '\0' });
subfile.size = BitConverter.ToUInt32(buf, offset + 260);
subfile.offset = BitConverter.ToUInt32(buf, offset + 264);
Metadata metadata = new Metadata();
metadata.LastBytes = new byte[20];
System.Array.Copy(buf, offset + 268, metadata.LastBytes, 0, 20);
subfile.Metadata = metadata;
subfiles.Add(subfile);
}
}
return subfiles;
}
示例10: DashStringDoesNotSplitAtNonmatchingDashes
public void DashStringDoesNotSplitAtNonmatchingDashes()
{
// Given
Engine engine = new Engine();
Metadata metadata = new Metadata(engine);
Pipeline pipeline = new Pipeline("Pipeline", engine, null);
IExecutionContext context = new ExecutionContext(engine, pipeline);
IDocument[] inputs = { new Document(metadata).Clone(@"FM1
FM2
---
Content1
Content2") };
bool executed = false;
FrontMatter frontMatter = new FrontMatter("-", new Execute(x =>
{
executed = true;
return new[] { x };
}));
// When
IEnumerable<IDocument> documents = frontMatter.Execute(inputs, context);
// Then
Assert.AreEqual(1, documents.Count());
Assert.IsFalse(executed);
Assert.AreEqual(@"FM1
FM2
---
Content1
Content2", documents.First().Content);
}
示例11: UpdateMetadataRequest
/// <summary>
/// Initializes a new instance of the <see cref="UpdateMetadataRequest"/> class
/// with the given metadata.
/// </summary>
/// <param name="metadata">The metadata.</param>
/// <exception cref="ArgumentNullException">If <paramref name="metadata"/> is <c>null</c>.</exception>
public UpdateMetadataRequest(Metadata metadata)
{
if (metadata == null)
throw new ArgumentNullException("metadata");
Metadata = metadata;
}
示例12: AmazonMultiUploadStream
public AmazonMultiUploadStream(AmazonS3Client client, string bucket, string key, Metadata metadata)
{
_client = client;
_bucket = bucket;
_key = key;
_metadata = metadata;
}
示例13: Extract
public TextExtractionResult Extract(Func<Metadata, InputStream> streamFactory)
{
try
{
var parser = new AutoDetectParser();
var metadata = new Metadata();
var parseContext = new ParseContext();
//use the base class type for the key or parts of Tika won't find a usable parser
parseContext.set(typeof(Parser), parser);
var content = new System.IO.StringWriter();
var contentHandlerResult = new TextExtractorContentHandler(content);
using (var inputStream = streamFactory(metadata))
{
try
{
parser.parse(inputStream, contentHandlerResult, metadata, parseContext);
}
finally
{
inputStream.close();
}
}
return AssembleExtractionResult(content.ToString(), metadata);
}
catch (Exception ex)
{
throw new TextExtractionException("Extraction failed.", ex);
}
}
示例14: UpdatePeersInfoModifiesPool
public void UpdatePeersInfoModifiesPool()
{
var metadata = new Metadata(new Configuration());
var cc = NewInstance(metadata);
cc.Host = TestHelper.CreateHost("127.0.0.1");
metadata.AddHost(cc.Host.Address);
var hostAddress2 = IPAddress.Parse("127.0.0.2");
var hostAddress3 = IPAddress.Parse("127.0.0.3");
var rows = TestHelper.CreateRows(new List<Dictionary<string, object>>
{
new Dictionary<string, object>{{"rpc_address", hostAddress2}, {"peer", null}, { "data_center", "ut-dc2" }, { "rack", "ut-rack2" }, {"tokens", null}},
new Dictionary<string, object>{{"rpc_address", IPAddress.Parse("0.0.0.0")}, {"peer", hostAddress3}, { "data_center", "ut-dc3" }, { "rack", "ut-rack3" }, {"tokens", null}}
});
cc.UpdatePeersInfo(rows);
Assert.AreEqual(3, metadata.AllHosts().Count);
//using rpc_address
var host2 = metadata.GetHost(new IPEndPoint(hostAddress2, ProtocolOptions.DefaultPort));
Assert.NotNull(host2);
Assert.AreEqual("ut-dc2", host2.Datacenter);
Assert.AreEqual("ut-rack2", host2.Rack);
//with rpc_address = 0.0.0.0, use peer
var host3 = metadata.GetHost(new IPEndPoint(hostAddress3, ProtocolOptions.DefaultPort));
Assert.NotNull(host3);
Assert.AreEqual("ut-dc3", host3.Datacenter);
Assert.AreEqual("ut-rack3", host3.Rack);
}
示例15: SetMetadata
public static void SetMetadata(this NetInfo prefab, Metadata metadata)
{
if (metadata.info != prefab)
{
throw new Exception("NoPillars: wrong metadata!");
}
prefab.m_canCollide = metadata.collide;
var r2 = prefab.m_netAI as RoadAI;
if (r2 != null)
{
r2.m_enableZoning = metadata.zoning;
}
if (Pillars.networkSkinsEnabled)
{
return;
}
var ta = prefab.m_netAI as TrainTrackBridgeAI;
if (ta != null)
{
ta.m_bridgePillarInfo = metadata.bpi;
ta.m_middlePillarInfo = metadata.bmi;
}
var ra = prefab.m_netAI as RoadBridgeAI;
if (ra != null)
{
ra.m_bridgePillarInfo = metadata.bpi;
ra.m_middlePillarInfo = metadata.bmi;
}
var pa = prefab.m_netAI as PedestrianBridgeAI;
if (pa != null)
{
pa.m_bridgePillarInfo = metadata.bpi;
}
}