예제 #1
0
        private static void ProcessFile(string type, Node n, string dirToSave, string dataToInsert)
        {
            Identify i = new Identify();

            IFormat inputFormat = i.GetFormat(n);

            // Compressed file
            if (inputFormat.ToString() == FORMATPREFIX + "DSCP")
            {
                BinaryFormat binary = Utils.Lzss(new BinaryFormat(n.Stream), "-d");
                n           = new Node(n.Name, binary);
                inputFormat = i.GetFormat(n);
            }

            log.Info("IFormat detected: " + inputFormat.ToString());

            switch (type)
            {// inputFilename - dirtosave - (dir/file to insert)
            case "-e":
                Export(inputFormat.ToString(), n, dirToSave);
                break;

            case "-i":
                Import(inputFormat.ToString(), n, dirToSave, dataToInsert);
                break;
            }
        }
예제 #2
0
 private static void VerifySupportedFormat <TCarrier>(IFormat <TCarrier> format)
 {
     if (format != BuiltinFormats.HttpHeaders && format != BuiltinFormats.TextMap)
     {
         throw new InvalidOperationException("Format " + format.ToString() + " not supported");
     }
 }
예제 #3
0
        public void AddCodec <TCarrier>(IFormat <TCarrier> format, IInjector injector, IExtractor extractor)
        {
            var formatString = format.ToString();

            _injectors[formatString]  = injector;
            _extractors[formatString] = extractor;
        }
예제 #4
0
        public global::OpenTracing.ISpanContext Extract <TCarrier>(IFormat <TCarrier> format, TCarrier carrier)
        {
            _codecs.TryGetValue(format.ToString(), out ICodec codec);

            if (codec != null)
            {
                return(codec.Extract(carrier));
            }

            throw new NotSupportedException($"Tracer.Extract is not implemented for {format} by SignalFx.Tracing");
        }
예제 #5
0
        public ISpanContext Extract <TCarrier>(IFormat <TCarrier> format, TCarrier carrier)
        {
            var formatString = format.ToString();

            if (_extractors.ContainsKey(formatString))
            {
                return(_extractors[formatString].Extract(carrier));
            }

            throw new ArgumentException($"{formatString} is not a supported extraction format", nameof(format));
        }
 public ISpanContext Extract <TCarrier>(IFormat <TCarrier> format, TCarrier carrier)
 {
     _codecs.TryGetValue(format.ToString(), out ICodec codec);
     if (codec != null)
     {
         return(codec.Extract(carrier));
     }
     else
     {
         throw new NotSupportedException($"Tracer.Extract is not implemented for {format} by Datadog.Trace");
     }
 }
예제 #7
0
        public void Inject <TCarrier>(ISpanContext spanContext, IFormat <TCarrier> format, TCarrier carrier)
        {
            var formatString = format.ToString();

            if (_injectors.ContainsKey(formatString))
            {
                _injectors[formatString].Inject(spanContext, carrier);
                return;
            }

            throw new ArgumentException($"{formatString} is not a supported injection format", nameof(format));
        }
예제 #8
0
        public void Inject <TCarrier>(global::OpenTracing.ISpanContext spanContext, IFormat <TCarrier> format, TCarrier carrier)
        {
            _codecs.TryGetValue(format.ToString(), out ICodec codec);

            if (codec != null)
            {
                codec.Inject(spanContext, carrier);
            }
            else
            {
                throw new NotSupportedException($"Tracer.Inject is not implemented for {format} by SignalFx.Tracing");
            }
        }
        public void Inject <TCarrier>(ISpanContext spanContext, IFormat <TCarrier> format, TCarrier carrier)
        {
            _codecs.TryGetValue(format.ToString(), out ICodec codec);
            if (codec != null)
            {
                var ddSpanContext = spanContext as OpenTracingSpanContext;
                if (ddSpanContext == null)
                {
                    throw new ArgumentException("Inject should be called with a Datadog.Trace.OpenTracing.OpenTracingSpanContext argument");
                }

                codec.Inject(ddSpanContext, carrier);
            }
            else
            {
                throw new NotSupportedException($"Tracer.Inject is not implemented for {format} by Datadog.Trace");
            }
        }
예제 #10
0
        private static void ProcessDig(string type, string outputFolder, string inputFolder)
        {
            foreach (Node d in NodeFactory.FromDirectory(inputFolder, "*.dig").Children)
            {
                Identify i           = new Identify();
                IFormat  inputFormat = i.GetFormat(d);
                Node     dig         = d;

                // Compressed file
                if (inputFormat.ToString() == FORMATPREFIX + "DSCP")
                {
                    BinaryFormat binary = Utils.Lzss(new BinaryFormat(dig.Stream), "-d");
                    dig = new Node(dig.Name, binary);
                }

                Node atm = NodeFactory.FromDirectory(inputFolder, "*.atm")
                           .Children[Path.GetFileNameWithoutExtension(dig.Name) + ".atm"];

                if (atm == null)
                {
                    throw new Exception("ATM not found: " +
                                        Path.GetFileNameWithoutExtension(dig.Name) + ".atm");
                }
                if (type == "-exportdig")
                {
                    ExportDig(dig, atm, outputFolder);
                }
                else
                {
                    Node png = NodeFactory.FromDirectory(inputFolder, "*.png")
                               .Children[Path.GetFileNameWithoutExtension(dig.Name) + ".png"];
                    if (png != null)
                    {
                        ImportDig(dig, atm, png, outputFolder);
                    }
                }
            }
        }