本文整理汇总了C#中Microsoft.ApplicationInsights.DataContracts.TelemetryContext.Initialize方法的典型用法代码示例。如果您正苦于以下问题:C# TelemetryContext.Initialize方法的具体用法?C# TelemetryContext.Initialize怎么用?C# TelemetryContext.Initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.ApplicationInsights.DataContracts.TelemetryContext
的用法示例。
在下文中一共展示了TelemetryContext.Initialize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeSetsTelemetryInstrumentationKeyFromArgument
public void InitializeSetsTelemetryInstrumentationKeyFromArgument()
{
var source = new TelemetryContext { InstrumentationKey = "TestValue" };
var target = new TelemetryContext();
target.Initialize(source, "OtherTestValue");
Assert.Equal("OtherTestValue", target.InstrumentationKey);
}
示例2: InitializeDoesNotOverrideTelemetryInstrumentationKey
public void InitializeDoesNotOverrideTelemetryInstrumentationKey()
{
var source = new TelemetryContext { InstrumentationKey = "SourceValue" };
var target = new TelemetryContext { InstrumentationKey = "TargetValue" };
target.Initialize(source, source.InstrumentationKey);
Assert.Equal("TargetValue", target.InstrumentationKey);
}
示例3: InitializeDoesNotOverwriteTags
public void InitializeDoesNotOverwriteTags()
{
string tagName = "TestTag";
var source = new TelemetryContext { Tags = { { tagName, "Source Value" } } };
var target = new TelemetryContext { Tags = { { tagName, "Target Value" } } };
target.Initialize(source, source.InstrumentationKey);
Assert.Equal("Target Value", target.Tags[tagName]);
}
示例4: InitializeCopiesTags
public void InitializeCopiesTags()
{
string tagName = "TestTag";
string tagValue = "TestValue";
var source = new TelemetryContext { Tags = { { tagName, tagValue } } };
var target = new TelemetryContext();
target.Initialize(source, source.InstrumentationKey);
Assert.Equal(tagValue, target.Tags[tagName]);
}
示例5: CopyAndSerialize
private static string CopyAndSerialize(TelemetryContext source)
{
// Create a copy of the source context to verify that Serialize writes property values stored in tags
// dictionary even if their context objects (User, Location, etc) haven't been initialized yet.
var target = new TelemetryContext();
target.Initialize(source, source.InstrumentationKey);
using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture))
{
Telemetry.WriteTelemetryContext(new JsonWriter(stringWriter), source);
return stringWriter.ToString();
}
}