コード例 #1
0
            private void Decompile <T>(Unit <T> unit)
                where T : struct
            {
                Man.UnitsOfMeasurement.Number factor = Man.UnitsOfMeasurement.Number.CreateFromObject(unit.Factor);

                Man.UnitsOfMeasurement.UnitType decompiledUnit =
                    new Man.UnitsOfMeasurement.UnitType(
                        unit.Type.Name,
                        new Man.UnitsOfMeasurement.SenseExpr(TranslateDimension(unit.Sense), null /* no sense code */),
                        new Man.UnitsOfMeasurement.NumExpr(factor != null, factor, null /* no factor code */)
                        );

                decompiledUnit.Tags.AddRange(unit.Symbol);

                AddFamily(unit.Family, decompiledUnit);

                m_units.Add(decompiledUnit);
            }
コード例 #2
0
            private void Decompile <T>(Scale <T> scale)
                where T : struct
            {
                string scaleRefPoint = Attribute.IsDefined(scale.Type, typeof(ScaleReferencePointAttribute)) ?
                                       (Attribute.GetCustomAttribute(scale.Type, typeof(ScaleReferencePointAttribute)) as ScaleReferencePointAttribute).Name :
                                       string.Empty;

                Man.UnitsOfMeasurement.Number   offset        = Man.UnitsOfMeasurement.Number.CreateFromObject(scale.Offset.Value);
                Man.UnitsOfMeasurement.UnitType scaleUnitType = m_units.Find(u => u.Name == scale.Unit.Type.Name);

                Man.UnitsOfMeasurement.ScaleType decompiledScale =
                    new Man.UnitsOfMeasurement.ScaleType(
                        scale.Type.Name,
                        scaleRefPoint,
                        scaleUnitType,
                        new Man.UnitsOfMeasurement.NumExpr(offset != null, offset, null /* no offset code */)
                        );

                AddFamily(scale.Family, decompiledScale);

                m_scales.Add(decompiledScale);
            }