Ejemplo n.º 1
0
        public TracerShim(Trace.Tracer tracer, ITextFormat textFormat)
        {
            this.tracer     = tracer ?? throw new ArgumentNullException(nameof(tracer));
            this.textFormat = textFormat ?? throw new ArgumentNullException(nameof(textFormat));

            this.ScopeManager = new ScopeManagerShim(this.tracer);
        }
Ejemplo n.º 2
0
        private TracerFactory(TracerBuilder builder)
        {
            this.sampler = builder.Sampler ?? Samplers.AlwaysSample;

            // TODO separate sampler from options
            this.configurationOptions =
                builder.TracerConfigurationOptions ?? new TracerConfiguration(this.sampler);

            // TODO log warning (or throw?) if there is no exporter
            this.exporter = builder.SpanExporter ?? new NoopSpanExporter();

            this.spanProcessor = builder.ProcessorFactory != null?
                                 builder.ProcessorFactory(this.exporter) :
                                     new BatchingSpanProcessor(this.exporter);

            this.binaryFormat = builder.BinaryFormat ?? new BinaryFormat();
            this.textFormat   = builder.TextFormat ?? new TraceContextFormat();

            this.defaultTracer = new Tracer(
                this.spanProcessor,
                this.configurationOptions,
                this.binaryFormat,
                this.textFormat,
                Resource.Empty);
        }
Ejemplo n.º 3
0
 public Tracer(IRandomGenerator randomGenerator, IStartEndHandler startEndHandler, ITraceConfig traceConfig, IExportComponent exportComponent, IBinaryFormat binaryFormat, ITextFormat textFormat)
 {
     this.spanBuilderOptions = new SpanBuilderOptions(randomGenerator, startEndHandler, traceConfig);
     this.binaryFormat       = binaryFormat ?? new BinaryFormat();
     this.textFormat         = textFormat ?? new TraceContextFormat();
     this.exportComponent    = exportComponent;
 }
Ejemplo n.º 4
0
 public TracerFactory(SpanProcessor spanProcessor = null, TracerConfiguration tracerConfiguration = null, ITextFormat textFormat = null, IBinaryFormat binaryFormat = null)
 {
     this.spanProcessor       = spanProcessor ?? Tracing.SpanProcessor;
     this.tracerConfiguration = tracerConfiguration ?? Tracing.TracerConfiguration;
     this.textFormat          = textFormat ?? new TraceContextFormat();
     this.binaryFormat        = binaryFormat ?? new BinaryFormat();
     this.defaultTracer       = new Tracer(this.spanProcessor, this.tracerConfiguration, this.binaryFormat, this.textFormat, Resource.Empty);
 }
Ejemplo n.º 5
0
		public ConceptObjectBaseCore(IConceptObject concept,
				ICodelistObjectBase representation0) : base(concept) {
			this._representation = representation0;
			if (concept.CoreRepresentation != null) {
				this._textFormat = concept.CoreRepresentation.TextFormat;
			}
			this._builtFrom = concept;
		}
Ejemplo n.º 6
0
 internal static FormattedText AsFormattedText(double value, ITextFormat textFormat, Typeface typeface)
 {
     var formattedText = new FormattedText(
         value.ToString(textFormat.ContentStringFormat, CultureInfo.CurrentUICulture),
         CultureInfo.CurrentUICulture,
         FlowDirection.LeftToRight,
         typeface,
         textFormat.FontSize,
         textFormat.Foreground);
     return formattedText;
 }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM MUTABLE OBJECT                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////    
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="LevelCore"/> class.
        /// </summary>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <param name="levelMutable">
        /// The level mutable. 
        /// </param>
        public LevelCore(IIdentifiableObject parent, ILevelMutableObject levelMutable)
            : base(levelMutable, parent)
        {
            if (levelMutable.CodingFormat != null)
            {
                this.textFormat = new TextFormatObjectCore(levelMutable.CodingFormat, this);
            }

            if (levelMutable.ChildLevel != null)
            {
                this.childLevel = new LevelCore(this, levelMutable.ChildLevel);
            }
        }
Ejemplo n.º 8
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM MUTABLE OBJECT                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="RepresentationCore"/> class.
        /// </summary>
        /// <param name="representationMutableObject">
        /// The sdmxObject. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        public RepresentationCore(IRepresentationMutableObject representationMutableObject, IIdentifiableObject parent)
            : base(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.LocalRepresentation), parent)
        {
            if (representationMutableObject.TextFormat != null)
            {
                this.textFormat = new TextFormatObjectCore(representationMutableObject.TextFormat, this);
            }

            if (representationMutableObject.Representation != null)
            {
                this.representation = new CrossReferenceImpl(this, representationMutableObject.Representation);
            }

            this.Validate();
        }
Ejemplo n.º 9
0
        private TracerFactory(TracerBuilder builder)
        {
            this.sampler         = builder.Sampler ?? Samplers.AlwaysSample;
            this.defaultResource = builder.Resource;

            this.configurationOptions =
                builder.TracerConfigurationOptions ?? new TracerConfiguration();

            if (builder.ProcessingPipelines == null || !builder.ProcessingPipelines.Any())
            {
                // if there are no pipelines are configured, use noop processor
                this.spanProcessor = new NoopSpanProcessor();
            }
            else if (builder.ProcessingPipelines.Count == 1)
            {
                // if there is only one pipeline - use it's outer processor as a
                // single processor on the tracer.
                var processorFactory = builder.ProcessingPipelines[0];
                this.spanProcessor = processorFactory.Build();
            }
            else
            {
                // if there are more pipelines, use processor that will broadcast to all pipelines
                var processors = new SpanProcessor[builder.ProcessingPipelines.Count];

                for (int i = 0; i < builder.ProcessingPipelines.Count; i++)
                {
                    processors[i] = builder.ProcessingPipelines[i].Build();
                }

                this.spanProcessor = new BroadcastProcessor(processors);
            }

            this.binaryFormat = builder.BinaryFormat ?? new BinaryFormat();
            this.textFormat   = builder.TextFormat ?? new TraceContextFormat();

            this.defaultTracer = new Tracer(
                this.spanProcessor,
                this.sampler,
                this.configurationOptions,
                this.binaryFormat,
                this.textFormat,
                this.defaultResource);
        }
Ejemplo n.º 10
0
        public void DrawText(ITextFormat formattedText, Point origin)
        {
            var fe = formattedText.LowObject as FrameworkElement;

            if (fe == null)
            {
                fe = new TextBlock()
                {
                    Text          = formattedText.Content,
                    FontFamily    = formattedText.FontFamily,
                    FontStretch   = formattedText.Stretch,
                    FontStyle     = formattedText.Style,
                    FontWeight    = formattedText.Weight,
                    FontSize      = formattedText.FontSize,
                    Foreground    = formattedText.Foreground,
                    TextAlignment = formattedText.TextAlignment,
                    TextTrimming  = formattedText.TextTrimming
                };
            }

            SetPosition(fe, origin);

            ApplyOperations(fe);
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Creates an instance of <see cref="Tracer"/>.
 /// </summary>
 /// <param name="spanProcessor">Span processor.</param>
 /// <param name="traceConfig">Trace configuration.</param>
 /// <param name="binaryFormat">Binary format context propagator.</param>
 /// <param name="textFormat">Text format context propagator.</param>
 public Tracer(SpanProcessor spanProcessor, TraceConfig traceConfig, IBinaryFormat binaryFormat, ITextFormat textFormat)
 {
     this.spanProcessor     = spanProcessor ?? new SimpleSpanProcessor(new NoopSpanExporter());
     this.ActiveTraceConfig = traceConfig;
     this.BinaryFormat      = binaryFormat ?? new BinaryFormat();
     this.TextFormat        = textFormat ?? new TraceContextFormat();
 }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="LevelCore"/> class.
        /// </summary>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <param name="levels">
        /// The levels. 
        /// </param>
        /// <param name="pos">
        /// The pos. 
        /// </param>
        public LevelCore(IIdentifiableObject parent, IList<LevelType> levels, int pos)
            : base(
                GetLevel(levels, pos), 
                SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Level), 
                GetLevel(levels, pos).id, 
                null, 
                GetLevel(levels, pos).Name, 
                GetLevel(levels, pos).Description, 
                GetLevel(levels, pos).Annotations, 
                parent)
        {
            LevelType level = GetLevel(levels, pos);
            if (level.CodingType != null)
            {
                this.textFormat = new TextFormatObjectCore(level.CodingType, this);
            }

            if (levels.Count > pos + 1)
            {
                this.childLevel = new LevelCore(this, levels, ++pos);
            }
        }
Ejemplo n.º 13
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2.1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="RepresentationCore"/> class.
        /// </summary>
        /// <param name="conceptRepresentation">
        /// The sdmxObject. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        public RepresentationCore(ConceptRepresentation conceptRepresentation, IIdentifiableObject parent)
            : base(_localRepresentation, parent)
        {
            if (conceptRepresentation.TextFormat != null)
            {
                this.textFormat = new TextFormatObjectCore(conceptRepresentation.TextFormat, this);
            }

            if (conceptRepresentation.Enumeration != null)
            {
                this.representation = RefUtil.CreateReference(this, conceptRepresentation.Enumeration);
                if (conceptRepresentation.EnumerationFormat != null)
                {
                    this.textFormat = new TextFormatObjectCore(conceptRepresentation.EnumerationFormat, this);
                }
            }

            this.Validate();
        }
Ejemplo n.º 14
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="RepresentationCore"/> class.
        /// </summary>
        /// <param name="textFormat0">
        /// The text format 0. 
        /// </param>
        /// <param name="codelistAgency">
        /// The codelist agency. 
        /// </param>
        /// <param name="codelistId">
        /// The codelist id. 
        /// </param>
        /// <param name="codelistVersion">
        /// The codelist version. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        public RepresentationCore(
            TextFormatType textFormat0, 
            string codelistAgency, 
            string codelistId, 
            string codelistVersion, 
            IIdentifiableObject parent)
            : base(_localRepresentation, parent)
        {
            if (textFormat0 != null)
            {
                this.textFormat = new TextFormatObjectCore(textFormat0, this);
            }

            if (ObjectUtil.ValidOneString(codelistAgency, codelistId, codelistVersion))
            {
                if (string.IsNullOrWhiteSpace(codelistAgency))
                {
                    codelistAgency = this.MaintainableParent.AgencyId;
                }

                SdmxStructureType structureType = SdmxStructureType.GetFromEnum(SdmxStructureEnumType.CodeList);
                if (parent.MaintainableParent is ICrossSectionalDataStructureObject)
                {
                    if (parent is IDimension)
                    {
                        if (((IDimension)parent).MeasureDimension)
                        {
                            structureType = SdmxStructureType.GetFromEnum(SdmxStructureEnumType.ConceptScheme);
                        }
                    }
                }

                this.representation = new CrossReferenceImpl(
                    this, codelistAgency, codelistId, codelistVersion, structureType);
            }

            this.Validate();
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TextFormatMutableCore"/> class.
        /// </summary>
        /// <param name="textFormat">
        /// The itxt. 
        /// </param>
        public TextFormatMutableCore(ITextFormat textFormat)
            : base(textFormat)
        {
            this.textType = textFormat.TextType;
            this.isSequence = textFormat.Sequence;
            this.maxLength = textFormat.MaxLength;
            this.minLength = textFormat.MinLength;
            this.startValue = textFormat.StartValue;
            this.endValue = textFormat.EndValue;
            this.interval = textFormat.Interval;
            this.maxValue = textFormat.MaxValue;
            this.minValue = textFormat.MinValue;
            this.isMultilingual = textFormat.Multilingual;
            if (textFormat.TimeInterval != null)
            {
                this.timeInterval = textFormat.TimeInterval;
            }

            this.decimals = textFormat.Decimals;
            this.pattern = textFormat.Pattern;
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Creates an instance of <see cref="TracerSdk"/>.
 /// </summary>
 /// <param name="spanProcessor">Span processor.</param>
 /// <param name="sampler">Sampler to use.</param>
 /// <param name="tracerConfiguration">Trace configuration.</param>
 /// <param name="binaryFormat">Binary format context propagator.</param>
 /// <param name="textFormat">Text format context propagator.</param>
 /// <param name="libraryResource">Resource describing the instrumentation library.</param>
 internal TracerSdk(SpanProcessor spanProcessor, Sampler sampler, TracerConfiguration tracerConfiguration, IBinaryFormat binaryFormat, ITextFormat textFormat, Resource libraryResource)
 {
     this.spanProcessor       = spanProcessor ?? throw new ArgumentNullException(nameof(spanProcessor));
     this.tracerConfiguration = tracerConfiguration ?? throw new ArgumentNullException(nameof(tracerConfiguration));
     this.BinaryFormat        = binaryFormat ?? throw new ArgumentNullException(nameof(binaryFormat));
     this.TextFormat          = textFormat ?? throw new ArgumentNullException(nameof(textFormat));
     this.LibraryResource     = libraryResource ?? throw new ArgumentNullException(nameof(libraryResource));
     this.sampler             = sampler ?? throw new ArgumentNullException(nameof(sampler));
 }
Ejemplo n.º 17
0
 public void DrawText(ITextFormat formattedText, Point origin)
 {
     drawingContext.DrawText(formattedText.LowObject as FormattedText, origin);
 }
Ejemplo n.º 18
0
        /// <summary>
        /// The populate text format type.
        /// </summary>
        /// <param name="textFormatType">
        /// The text format type.
        /// </param>
        /// <param name="textFormat">
        /// The text format.
        /// </param>
        internal void PopulateTextFormatType(TextFormatType textFormatType, ITextFormat textFormat)
        {
            if (textFormat.MaxLength != null)
            {
                textFormatType.length = textFormat.MaxLength;
            }

            if (textFormat.Decimals != null)
            {
                textFormatType.decimals = textFormat.Decimals;
            }

            if (textFormat.TextType != null)
            {
                switch (textFormat.TextType.EnumType)
                {
                    case TextEnumType.BigInteger:
                        textFormatType.TextType = TextTypeConstants.Num;
                        break;
                    case TextEnumType.Boolean:
                        LoggingUtil.Warn(
                            log, "can not map text type BOOLEAN to SDMX version 1.0 schema instance, property ignored ");
                        break;
                    case TextEnumType.Count:
                        LoggingUtil.Warn(
                            log, "can not map text type COUNT to SDMX version 1.0 schema instance, property ignored ");
                        break;
                    case TextEnumType.Date:
                        LoggingUtil.Warn(
                            log, "can not map text type DATE to SDMX version 1.0 schema instance, property ignored ");
                        break;
                    case TextEnumType.DateTime:
                        LoggingUtil.Warn(
                            log, 
                            "can not map text type DATE TIME to SDMX version 1.0 schema instance, property ignored ");
                        break;
                    case TextEnumType.Day:
                        LoggingUtil.Warn(
                            log, "can not map text type DAY to SDMX version 1.0 schema instance, property ignored ");
                        break;
                    case TextEnumType.Decimal:
                        textFormatType.TextType = TextTypeConstants.Num;
                        break;
                    case TextEnumType.Double:
                        textFormatType.TextType = TextTypeConstants.Num;
                        break;
                    case TextEnumType.Duration:
                        LoggingUtil.Warn(
                            log, "can not map text type DURATION to SDMX version 1.0 schema instance, property ignored ");
                        break;
                    case TextEnumType.ExclusiveValueRange:
                        LoggingUtil.Warn(
                            log, 
                            "can not map text type EXCLUSIVE VALUE RANGE to SDMX version 1.0 schema instance, property ignored ");
                        break;
                    case TextEnumType.Float:
                        textFormatType.TextType = TextTypeConstants.Num;
                        break;
                    case TextEnumType.InclusiveValueRange:
                        LoggingUtil.Warn(
                            log, 
                            "can not map text type INCLUSIVE VALUE RANGE to SDMX version 1.0 schema instance, property ignored ");
                        break;
                    case TextEnumType.Incremental:
                        LoggingUtil.Warn(
                            log, 
                            "can not map text type INCREMENTAL to SDMX version 1.0 schema instance, property ignored ");
                        break;
                    case TextEnumType.Long:
                        textFormatType.TextType = TextTypeConstants.Num;
                        break;
                    case TextEnumType.Month:
                        LoggingUtil.Warn(
                            log, "can not map text type MONTH to SDMX version 1.0 schema instance, property ignored ");
                        break;
                    case TextEnumType.MonthDay:
                        LoggingUtil.Warn(
                            log, 
                            "can not map text type MONTH DAY to SDMX version 1.0 schema instance, property ignored ");
                        break;
                    case TextEnumType.ObservationalTimePeriod:
                        LoggingUtil.Warn(
                            log, 
                            "can not map text type OBSERVATIONAL TIME PERIOD to SDMX version 1.0 schema instance, property ignored ");
                        break;
                    case TextEnumType.Short:
                        textFormatType.TextType = TextTypeConstants.Num;
                        break;
                    case TextEnumType.String:
                        textFormatType.TextType = TextTypeConstants.Alpha;
                        break;
                    case TextEnumType.Time:
                        LoggingUtil.Warn(
                            log, "can not map text type TIME to SDMX version 1.0 schema instance, property ignored ");
                        break;
                    case TextEnumType.Timespan:
                        LoggingUtil.Warn(
                            log, "can not map text type TIMESPAN to SDMX version 1.0 schema instance, property ignored ");
                        break;
                    case TextEnumType.Uri:
                        LoggingUtil.Warn(
                            log, "can not map text type URI to SDMX version 1.0 schema instance, property ignored ");
                        break;
                    case TextEnumType.Year:
                        LoggingUtil.Warn(
                            log, "can not map text type YEAR to SDMX version 1.0 schema instance, property ignored ");
                        break;
                    case TextEnumType.YearMonth:
                        LoggingUtil.Warn(
                            log, 
                            "can not map text type YEAR MONTH to SDMX version 1.0 schema instance, property ignored ");
                        break;
                }
            }
        }
Ejemplo n.º 19
0
 public void Print(ITextFormat formatter)
 {
     Console.WriteLine(formatter.Format("Printing Term Paper"));
 }
 public ITextFormatObject(ITextFormat ITextFormatinstance)
 {
     ITextFormatInstance = ITextFormatinstance;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="RepresentationMapRefCore"/> class.
        /// </summary>
        /// <param name="xref">
        /// The xref. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.
        /// </exception>
        protected internal RepresentationMapRefCore(IRepresentationMapRefMutableObject xref, ISdmxStructure parent)
            : base(xref, parent)
        {
            this.valueMappings = new DictionaryOfSets<string, string>();
            if (xref.CodelistMap != null)
            {
                this.codelistMap = new CrossReferenceImpl(this, xref.CodelistMap);
            }

            if (xref.ToTextFormat != null)
            {
                this.toTextFormat = new TextFormatObjectCore(xref.ToTextFormat, this);
            }

            if (xref.ValueMappings != null)
            {
                this.valueMappings = new DictionaryOfSets<string, string>(xref.ValueMappings);
            }

            this.toValueType = xref.ToValueType;
            try
            {
                this.Validate();
            }
            catch (SdmxSemmanticException ex)
            {
                throw new SdmxSemmanticException(ex, ExceptionCode.ObjectStructureConstructionError, this);
            }
            catch (Exception th)
            {
                throw new SdmxException(th, ExceptionCode.ObjectStructureConstructionError, this);
            }
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="RepresentationMapRefCore"/> class.
        /// </summary>
        /// <param name="textFormatType">
        /// The text format type. 
        /// </param>
        /// <param name="toValueType">
        /// The to value type. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        public RepresentationMapRefCore(TextFormatType textFormatType, string toValueType, ISdmxStructure parent)
            : base(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.RepresentationMap), parent)
        {
            this.valueMappings = new DictionaryOfSets<string, string>();
            this.toTextFormat = new TextFormatObjectCore(textFormatType, this);
            if (toValueType != null)
            {
                switch (toValueType)
                {
                    case Org.Sdmx.Resources.SdmxMl.Schemas.V20.structure.ToValueTypeTypeConstants.Description:
                        this.toValueType = ToValue.Description;
                        break;
                    case Org.Sdmx.Resources.SdmxMl.Schemas.V20.structure.ToValueTypeTypeConstants.Name:
                        this.toValueType = ToValue.Name;
                        break;
                    case Org.Sdmx.Resources.SdmxMl.Schemas.V20.structure.ToValueTypeTypeConstants.Value:
                        this.toValueType = ToValue.Value;
                        break;
                }
            }

            this.Validate();
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM MUTABLE OBJECTS             //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V21 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="RepresentationMapRefCore"/> class.
        /// </summary>
        /// <param name="representationMapType">
        /// The iref. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.
        /// </exception>
        public RepresentationMapRefCore(RepresentationMapType representationMapType, ISdmxStructure parent)
            : base(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.RepresentationMap), parent)
        {
            this.valueMappings = new DictionaryOfSets<string, string>();

            if (representationMapType.CodelistMap != null)
            {
                // Local Reference
                string agencyId = this.MaintainableParent.AgencyId;
                string maintainableId = this.MaintainableParent.Id;
                string version = this.MaintainableParent.Version;
                this.codelistMap = new CrossReferenceImpl(
                    this, agencyId, maintainableId, version, SdmxStructureEnumType.CodeListMap, representationMapType.CodelistMap.GetTypedRef<LocalCodelistMapRefType>().id);
            }

            if (representationMapType.ToTextFormat != null)
            {
                this.toTextFormat = new TextFormatObjectCore(representationMapType.ToTextFormat, this);
            }

            if (representationMapType.ToValueType != null)
            {
                switch (representationMapType.ToValueType)
                {
                    case ToValueTypeTypeConstants.Description:
                        this.toValueType = ToValue.Description;
                        break;
                    case ToValueTypeTypeConstants.Name:
                        this.toValueType = ToValue.Name;
                        break;
                    case ToValueTypeTypeConstants.Value:
                        this.toValueType = ToValue.Value;
                        break;
                }
            }

            if (representationMapType.ValueMap != null)
            {
                foreach (ValueMappingType vmt in representationMapType.ValueMap.ValueMapping)
                {
                    ISet<string> mappings = valueMappings[vmt.source];
                    if (mappings==null)
                    {
                        mappings = new HashSet<string>();
                        valueMappings.Add(vmt.source, mappings);
                    }
                    mappings.Add(vmt.target);
                }
            }

            try
            {
                this.Validate();
            }
            catch (SdmxSemmanticException ex)
            {
                throw new SdmxSemmanticException(ex, ExceptionCode.ObjectStructureConstructionError, this);
            }
            catch (Exception th)
            {
                throw new SdmxException(th, ExceptionCode.ObjectStructureConstructionError, this);
            }
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2.1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="LevelCore"/> class.
        /// </summary>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <param name="level">
        /// The level. 
        /// </param>
        public LevelCore(IIdentifiableObject parent, Org.Sdmx.Resources.SdmxMl.Schemas.V21.Structure.LevelType level)
            : base(level, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Level), parent)
        {
            if (level.CodingFormat != null)
            {
                this.textFormat = new TextFormatObjectCore(level.CodingFormat, this);
            }

            if (level.Level != null)
            {
                this.childLevel = new LevelCore(this, level.Level);
            }
        }
Ejemplo n.º 25
0
 /// <summary>
 /// Configures <see cref="ITextFormat"/> on the tracerSdk.
 /// </summary>
 /// <param name="textFormat"><see cref="ITextFormat"/> implementation class instance.</param>
 public TracerBuilder SetTextFormat(ITextFormat textFormat)
 {
     this.TextFormat = textFormat ?? throw new ArgumentNullException(nameof(textFormat));
     return(this);
 }
Ejemplo n.º 26
0
 public void Print(ITextFormat formatter)
 {
     Console.WriteLine(formatter.Format("Print FAQ"));
 }
Ejemplo n.º 27
0
 public unsafe static ITextLayout CreateTextLayout(this IFactory factory, ReadOnlySpan <char> text, ITextFormat textFormat, SizeF maxSize)
 {
     fixed(char *c = &MemoryMarshal.GetReference(text))
     {
         return(factory.CreateTextLayout(c, (uint)text.Length, textFormat, maxSize.Width, maxSize.Height));
     }
 }
Ejemplo n.º 28
0
 /// <summary>
 /// Creates an instance of <see cref="ITracer"/>.
 /// </summary>
 /// <param name="startEndHandler">Start/end event handler.</param>
 /// <param name="traceConfig">Trace configuration.</param>
 /// <param name="spanExporter">Exporter for span.</param>
 /// <param name="binaryFormat">Binary format context propagator.</param>
 /// <param name="textFormat">Text format context propagator.</param>
 public Tracer(IStartEndHandler startEndHandler, ITraceConfig traceConfig, SpanExporter spanExporter, IBinaryFormat binaryFormat, ITextFormat textFormat)
 {
     this.spanBuilderOptions = new SpanBuilderOptions(startEndHandler, traceConfig);
     this.spanExporter       = spanExporter ?? (SpanExporter)SpanExporter.Create(ExporterBufferSize, ExporterScheduleDelay);
     this.BinaryFormat       = binaryFormat ?? new BinaryFormat();
     this.TextFormat         = textFormat ?? new TraceContextFormat();
 }
Ejemplo n.º 29
0
 public virtual void Print(ITextFormat formatter)
 {
     Console.WriteLine(formatter.Format("Print Book"));
     Console.WriteLine();
 }
Ejemplo n.º 30
0
 public ITextLayout CreateTextLayout(string text, ITextFormat textFormat, float maxWidth, float maxHeight) =>
 base.innerRefT.CreateTextLayout(text, textFormat, maxWidth, maxHeight);
Ejemplo n.º 31
0
 public IInlineObject CreateEllipsisTrimmingSign(ITextFormat textFormat) =>
 base.innerRefT.CreateEllipsisTrimmingSign(textFormat);
Ejemplo n.º 32
0
 public ITextLayout CreateGdiCompatibleTextLayout(string text, ITextFormat textFormat, float layoutWidth, float layoutHeight, float pixelsPerDip, Matrix3x2Float?transform, bool useGdiNatural) =>
 base.innerRefT.CreateGdiCompatibleTextLayout(text, textFormat, layoutWidth, layoutHeight, pixelsPerDip, transform, useGdiNatural);
        /// <summary>
        /// The populate text format type.
        /// </summary>
        /// <param name="textFormatType">
        /// The text format type.
        /// </param>
        /// <param name="textFormat">
        /// The text format.
        /// </param>
        internal void PopulateTextFormatType(TextFormatType textFormatType, ITextFormat textFormat)
        {
            if (textFormat.TextType != null)
            {
                switch (textFormat.TextType.EnumType)
                {
                    case TextEnumType.BigInteger:
                        textFormatType.textType = TextTypeTypeConstants.BigInteger;
                        break;
                    case TextEnumType.Boolean:
                        textFormatType.textType = TextTypeTypeConstants.Boolean;
                        break;
                    case TextEnumType.Count:
                        textFormatType.textType = TextTypeTypeConstants.Count;
                        break;
                    case TextEnumType.Date:
                        textFormatType.textType = TextTypeTypeConstants.Date;
                        break;
                    case TextEnumType.DateTime:
                        textFormatType.textType = TextTypeTypeConstants.DateTime;
                        break;
                    case TextEnumType.Day:
                        textFormatType.textType = TextTypeTypeConstants.Day;
                        break;
                    case TextEnumType.Decimal:
                        textFormatType.textType = TextTypeTypeConstants.Decimal;
                        break;
                    case TextEnumType.Double:
                        textFormatType.textType = TextTypeTypeConstants.Double;
                        break;
                    case TextEnumType.Duration:
                        textFormatType.textType = TextTypeTypeConstants.Duration;
                        break;
                    case TextEnumType.ExclusiveValueRange:
                        textFormatType.textType = TextTypeTypeConstants.ExclusiveValueRange;
                        break;
                    case TextEnumType.Float:
                        textFormatType.textType = TextTypeTypeConstants.Float;
                        break;
                    case TextEnumType.InclusiveValueRange:
                        textFormatType.textType = TextTypeTypeConstants.InclusiveValueRange;
                        break;
                    case TextEnumType.Incremental:
                        textFormatType.textType = TextTypeTypeConstants.Incremental;
                        break;
                    case TextEnumType.Integer:
                        textFormatType.textType = TextTypeTypeConstants.Integer;
                        break;
                    case TextEnumType.Long:
                        textFormatType.textType = TextTypeTypeConstants.Long;
                        break;
                    case TextEnumType.Month:
                        textFormatType.textType = TextTypeTypeConstants.Month;
                        break;
                    case TextEnumType.MonthDay:
                        textFormatType.textType = TextTypeTypeConstants.MonthDay;
                        break;
                    case TextEnumType.ObservationalTimePeriod:
                        textFormatType.textType = TextTypeTypeConstants.ObservationalTimePeriod;
                        break;
                    case TextEnumType.Short:
                        textFormatType.textType = TextTypeTypeConstants.Short;
                        break;
                    case TextEnumType.String:
                        textFormatType.textType = TextTypeTypeConstants.String;
                        break;
                    case TextEnumType.Time:
                        textFormatType.textType = TextTypeTypeConstants.Time;
                        break;
                    case TextEnumType.Timespan:
                        textFormatType.textType = TextTypeTypeConstants.Timespan;
                        break;
                    case TextEnumType.Uri:
                        textFormatType.textType = TextTypeTypeConstants.URI;
                        break;
                    case TextEnumType.Year:
                        textFormatType.textType = TextTypeTypeConstants.Year;
                        break;
                    case TextEnumType.YearMonth:
                        textFormatType.textType = TextTypeTypeConstants.YearMonth;
                        break;
                }
            }

            string str0 = textFormat.Pattern;
            if (!string.IsNullOrWhiteSpace(str0))
            {
                textFormatType.pattern = textFormat.Pattern;
            }

            TimeSpan result;
            string str1 = textFormat.TimeInterval;
            if (!string.IsNullOrWhiteSpace(str1) && TimeSpan.TryParse(textFormat.TimeInterval, out result))
            {
                textFormatType.timeInterval = result;
            }

            if (textFormat.Decimals != null)
            {
                textFormatType.decimals = textFormat.Decimals;
            }

            if (textFormat.EndValue != null)
            {
                textFormatType.endValue = Convert.ToDouble(textFormat.EndValue);
            }

            if (textFormat.Interval != null)
            {
                textFormatType.interval = Convert.ToDouble(textFormat.Interval);
            }

            if (textFormat.MaxLength != null)
            {
                textFormatType.maxLength = textFormat.MaxLength;
            }

            if (textFormat.MinLength != null)
            {
                textFormatType.minLength = textFormat.MinLength;
            }

            if (textFormat.StartValue != null)
            {
                textFormatType.startValue = Convert.ToDouble(textFormat.StartValue);
            }

            if (textFormat.Sequence.IsSet())
            {
                textFormatType.isSequence = textFormat.Sequence.IsTrue;
            }
        }
Ejemplo n.º 34
0
 public void DrawText(string text, ITextFormat textFormat, RectFloat layoutRect, IBrush defaultForegroundBrush, DrawTextOptions options, TextMeasuringMode measuringMode)
 {
     base.innerRefT.DrawText(text, textFormat, layoutRect, defaultForegroundBrush, options, measuringMode);
 }
 public static ITextFormat CreateRef(this ITextFormat objectRef) =>
 ((ITextFormat)objectRef.CreateRef(typeof(ITextFormat)));
Ejemplo n.º 36
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RepresentationCore"/> class.
        /// </summary>
        /// <param name="representationType">
        /// The sdmxObject. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        public RepresentationCore(RepresentationType representationType, IIdentifiableObject parent)
            : base(_localRepresentation, parent)
        {
            if (representationType.TextFormat != null)
            {
                this.textFormat = new TextFormatObjectCore(representationType.TextFormat, this);
            }

            ItemSchemeReferenceBaseType reference;
            if (representationType.CodelistEnumeration != null)
            {
                reference = representationType.CodelistEnumeration;
            }
            else
            {
                reference = representationType.ConceptSchemeEnumeration;
            }

            if (reference != null)
            {
                this.representation = RefUtil.CreateReference(this, reference);
                if (representationType.EnumerationFormat != null)
                {
                    this.textFormat = new TextFormatObjectCore(representationType.EnumerationFormat, this);
                }
            }

            this.Validate();
        }
Ejemplo n.º 37
0
        public bool NextDraw(Point pt, IDrawingContext dc, bool isFinal)
        {
            Points[1] = pt;

            double radius = Math.Atan((Points[1].X - Points[0].X) / (Points[0].Y - Points[1].Y));
            double degree = radius * 180 / Math.PI;

            if (degree < 0)
            {
                if (Points[1].X > Points[0].X)
                {
                    degree = 180 + degree;
                }
            }
            else
            {
                if (Points[1].X < Points[0].X)
                {
                    degree = 180 + degree;
                }
            }

            IPen pen = DrawingObjectFactory.CreatePen(MeasureColor, MeasureThickness);

            if (MeasureDashes != null)
            {
                pen.Dashes = MeasureDashes;
            }
            //Trace.WriteLine(radius + "," + degree);
            RotateTransform transferm = new RotateTransform()
            {
                Angle   = degree,
                CenterX = Points[0].X,
                CenterY = Points[0].Y
            };

            dc.PushTransform(transferm);
            Point pt1 = new Point(Points[0].X + 3, Points[0].Y);
            Point pt2 = new Point(Points[0].X - 3, Points[0].Y);

            dc.DrawLine(pen, pt1, pt2);

            double value = -Math.Sqrt(Math.Abs(Points[0].X - Points[1].X) * Math.Abs(Points[0].X - Points[1].X) + Math.Abs(Points[0].Y - Points[1].Y) * Math.Abs(Points[0].Y - Points[1].Y));
            Point  pt3   = new Point(Points[0].X, Points[0].Y + value);

            dc.DrawLine(pen, Points[0], pt3);

            pt1 = new Point(Points[0].X + 3, Points[0].Y + value);
            pt2 = new Point(Points[0].X - 3, Points[0].Y + value);
            dc.DrawLine(pen, pt1, pt2);

            dc.Pop();

            ITextFormat format = DrawingObjectFactory.CreateTextFormat(measureValue.ToString("P2"), FlowDirection, FontFamily, FontStyle, FontWeight, FontStretch, FontSize, Foreground);

            Point ptText = Points[1];

            ptText.Y -= format.Height;
            dc.DrawText(format, ptText);
            return(false);
        }
Ejemplo n.º 38
0
 /// <summary>
 /// Creates an instance of <see cref="Tracer"/>.
 /// </summary>
 /// <param name="spanProcessor">Span processor.</param>
 /// <param name="traceConfig">Trace configuration.</param>
 /// <param name="binaryFormat">Binary format context propagator.</param>
 /// <param name="textFormat">Text format context propagator.</param>
 public Tracer(SpanProcessor spanProcessor, TraceConfig traceConfig, IBinaryFormat binaryFormat, ITextFormat textFormat)
 {
     this.spanProcessor     = spanProcessor ?? throw new ArgumentNullException(nameof(spanProcessor));
     this.ActiveTraceConfig = traceConfig ?? throw new ArgumentNullException(nameof(traceConfig));
     this.BinaryFormat      = binaryFormat ?? throw new ArgumentNullException(nameof(binaryFormat));
     this.TextFormat        = textFormat ?? throw new ArgumentNullException(nameof(textFormat));
 }
Ejemplo n.º 39
0
 public HelloWorld() : base()
 {
     _textFormat = DirectWriteFactory.CreateTextFormat("Gabriola", fontSize: 64);
     _textFormat.SetTextAlignment(TextAlignment.Center);
     _textFormat.SetParagraphAlignment(ParagraphAlignment.Center);
 }