本文整理汇总了C#中Trace类的典型用法代码示例。如果您正苦于以下问题:C# Trace类的具体用法?C# Trace怎么用?C# Trace使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Trace类属于命名空间,在下文中一共展示了Trace类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public int Run()
{
_trace = new Trace("ThrowInCatchTest", "0123456");
_trace.Write("0");
try
{
_trace.Write("1");
try
{
_trace.Write("2");
throw new Exception(".....");
}
catch(Exception e)
{
Console.WriteLine(e);
_trace.Write("3");
throw new Exception("5");
}
}
catch(Exception e)
{
Console.WriteLine(e);
_trace.Write("4");
_trace.Write(e.Message);
}
_trace.Write("6");
return _trace.Match();
}
示例2: initCreatedRefractTrace
public void initCreatedRefractTrace(Trace refractTrace, UnitVector surfaceNormal, Scientrace.Object3d fromObject3d, Scientrace.Object3d toObject3d)
{
double oldrefindex = fromObject3d.materialproperties.refractiveindex(this);
double newrefindex = toObject3d.materialproperties.refractiveindex(this);
//for definitions on the parameters below, check fullInternalReflects function.
UnitVector incoming_trace_direction = this.traceline.direction;
if (incoming_trace_direction.dotProduct(surfaceNormal) > 0) {
surfaceNormal = surfaceNormal.negative();
}
Scientrace.UnitVector nnorm = surfaceNormal.negative();
Scientrace.Vector incoming_normal_projection = nnorm*(incoming_trace_direction.dotProduct(nnorm));
Vector L1 = incoming_trace_direction-incoming_normal_projection;
double L2 = (oldrefindex/newrefindex)*L1.length;
if (incoming_trace_direction == incoming_normal_projection) {
//in case of normal incident light: do not refract.
refractTrace.traceline.direction = incoming_trace_direction;
return;
}
try {
refractTrace.traceline.direction = ((nnorm*Math.Sqrt(1 - Math.Pow(L2,2)))
+(L1.tryToUnitVector()*L2)).tryToUnitVector();
} catch (ZeroNonzeroVectorException) {
Console.WriteLine("WARNING: cannot define direction for refraction trace. Using surface normal instead. (L1: "+incoming_trace_direction.trico()+", L2:"+incoming_normal_projection.trico()+").");
refractTrace.traceline.direction = nnorm;
} //end try/catch
}
示例3: Run
public int Run()
{
_trace = new Trace("TryCatchInFinallyTest", "0123456");
_trace.Write("0");
try
{
_trace.Write("1");
}
finally
{
_trace.Write("2");
try
{
_trace.Write("3");
throw new InvalidProgramException();
}
catch(InvalidProgramException e)
{
Console.WriteLine(e);
_trace.Write("4");
}
_trace.Write("5");
}
_trace.Write("6");
return _trace.Match();
}
示例4: AssemblyTrace
public AssemblyTrace(Trace parent, CST.AssemblyDef assembly)
{
Parent = parent;
Assembly = assembly;
IncludeAssembly = false;
TypeMap = new Map<CST.TypeName, TypeTrace>();
}
示例5: Run
public int Run()
{
_trace = new Trace("GoryNativePastTest", "0123456");
_trace.Write("0");
try
{
try
{
foo();
}
catch(Exception e)
{
Console.WriteLine(e);
_trace.Write("4");
throw;
}
}
catch(Exception e)
{
_trace.Write("5");
_trace.Write(e.Message);
}
return _trace.Match();
}
示例6: OnTrace
public override void OnTrace(Trace t) {
lock (lockObj) {
Prepare();
Write(t);
file.Flush();
}
}
示例7: ParseResponse
public static void ParseResponse(Trace trace, HttpResponseMessage response)
{
try
{
var responseBody = response.Content;
trace.Response = responseBody.ReadAsStringAsync().Result;
trace.Status = ((int)response.StatusCode).ToString();
if (trace.Response.Length > 0 && !trace.Status.Equals("429"))
{
trace.ResponseBodyLength = responseBody.Headers.ContentLength;
var ad = response.RequestMessage.GetActionDescriptor();
if (ad != null)
{
var action = new ApiDescription
{
HttpMethod = response.RequestMessage.Method,
RelativePath = response.RequestMessage.RequestUri.PathAndQuery.Substring(1)
};
var fid = action.GetFriendlyId();
trace.FriendlyURI = APIUriList.FirstOrDefault(x => x.Equals(fid, StringComparison.OrdinalIgnoreCase));
if (string.IsNullOrWhiteSpace(trace.FriendlyURI))
trace.FriendlyURI = APIUriList.FirstOrDefault(x => x.StartsWith(fid, StringComparison.OrdinalIgnoreCase));
trace.Action = ad.ControllerDescriptor.ControllerName + " / " + ad.ActionName;
}
if (TraceList.Count >= 64)
TraceList.RemoveAt(0);
TraceList.Add(trace);
}
}
catch (Exception)
{
}
}
示例8: Run
public int Run()
{
_trace = new Trace("PendingTest", "0123401235");
try
{
f1();
}
catch(Exception e)
{
Console.WriteLine(e);
_trace.Write("4");
}
try
{
f1();
}
catch(Exception e)
{
Console.WriteLine(e);
_trace.Write("5");
}
return _trace.Match();
}
示例9: ComputeTraceLength
public float ComputeTraceLength(Trace trace, int fromPoint, int toPoint)
{
var noOfPoints = trace.Points.Count;
if ((fromPoint < 0 || fromPoint > (noOfPoints - 1))
|| (toPoint < 0 || toPoint > (noOfPoints - 1)))
{
//error
}
float xDiff, yDiff, pointDistance;
IList<float> xVec, yVec;
var outLength = 0f;
xVec = trace.ChannelX;
yVec = trace.ChannelY;
for (var i = fromPoint; i < toPoint; i++)
{
xDiff = xVec[i] - xVec[i + 1];
yDiff = yVec[i] - yVec[i + 1];
//distance between 2 points
pointDistance = (float)Math.Sqrt(xDiff * xDiff + yDiff * yDiff);
outLength += pointDistance;
}
return outLength;
}
示例10: TraceConstructorTest
public void TraceConstructorTest()
{
Guid id = Guid.NewGuid();
string contextId = "ContextID";
Trace target = new Trace(id, contextId);
Assert.AreEqual(id, target.Id);
Assert.AreEqual(contextId, target.ContextId);
}
示例11: ReadFromInkFile
public TraceGroup ReadFromInkFile(string path)
{
var outTraceGroup = new TraceGroup();
var input = new FileStream(path, FileMode.Open, FileAccess.Read);
var fileReader = new StreamReader(input);
var strLine = "";
char[] splitter = { ' ' };
var captureDevice = new CaptureDevice { SamplingRate = 100, Latency = 0f };
while(!fileReader.EndOfStream)
{
strLine = fileReader.ReadLine();
if (strLine == null) continue;
//Read header info
if (strLine.Contains(".X_POINTS_PER_INCH"))
{
var strToken = strLine.Split(splitter, StringSplitOptions.None);
captureDevice.XDpi = Convert.ToInt32(strToken[1]);
}
if (strLine.Contains(".Y_POINTS_PER_INCH"))
{
var strToken = strLine.Split(splitter, StringSplitOptions.None);
captureDevice.YDpi = Convert.ToInt32(strToken[1]);
}
if (strLine.Contains(".POINTS_PER_SECOND"))
{
var strToken = strLine.Split(splitter, StringSplitOptions.None);
//use later
}
if (!strLine.Trim().Equals(".PEN_DOWN")) continue;
var strCoord = "";
var trace = new Trace();
while(!(strCoord = fileReader.ReadLine()?? "").Trim().Equals(".PEN_UP") && !fileReader.EndOfStream)
{
var strToken = strCoord.Split(splitter, StringSplitOptions.None);
var x = Convert.ToInt32(strToken[0]);
var y = Convert.ToInt32(strToken[1]);
trace.Points.Add(new PenPoint{X=x, Y=y});
}
outTraceGroup.Traces.Add(trace);
}
fileReader.Close();
input.Close();
outTraceGroup.CaptureDevice = captureDevice;
return outTraceGroup;
}
示例12: Spot
public Spot(Scientrace.Location loc, Object3d object3d, double intensity, double intensityFraction, Scientrace.Trace trace)
{
this.loc = loc;
this.object3d = object3d;
this.object3d.spotted(intensity);
this.intensity = intensity;
this.intensityFraction = intensityFraction;
this.trace = trace;
this.fillPolVecs();
}
示例13: WordAnalysis
/// <summary>
/// Initializes a new instance of the <see cref="WordAnalysis"/> class.
/// </summary>
/// <param name="shape">The shape.</param>
/// <param name="curTrace">The current trace record.</param>
internal WordAnalysis(PhoneticShape shape, Stratum stratum, Trace curTrace)
{
m_shape = shape;
m_pos = new HCObjectSet<PartOfSpeech>();
m_mrules = new List<MorphologicalRule>();
m_mrulesUnapplied = new Dictionary<MorphologicalRule, int>();
m_rzFeatures = new FeatureValues();
m_stratum = stratum;
m_curTrace = curTrace;
}
示例14: intersects
public override Intersection intersects(Trace trace)
{
List<Scientrace.FlatShape2d> pgrams = new List<Scientrace.FlatShape2d>();
//first: add parallelogram circle2d surfaces
pgrams.Add(new Scientrace.Circle2d(this.loc, this.height, this.width, this.width.length));
pgrams.Add(new Scientrace.Circle2d(this.loc+this.length.toLocation(), this.height, this.width, this.width.length));
//TODO: second: add connecting surface
return this.intersectFlatShapes(trace, pgrams);
}
示例15: Dump
private static void Dump(Trace[] traces, int style)
{
foreach (var trace in traces)
{
Cout.WriteLine(trace.ToString(style));
if (trace.Children.Length > 0)
{
Dump(trace.Children, style);
}
}
}