예제 #1
0
        private void SelectAllItems(IEnumType enumType)
        {
            var items = binsBunches.Where(x => x.Scopes.EnumValues.Contains(enumType));                 //items with that type

            foreach (var item in items)
            {
                item.Select(enumType);
            }
        }
예제 #2
0
        private static int GetTypeSize(IType type)
        {
            if (type is IEnumType)
            {
                IEnumType targetType = (IEnumType)type;
                switch (targetType.ValueType)
                {
                case EnumerationBaseType.SByte:
                    return(GetTypeSize(IntermediateCliGateway.GlobalManager.ObtainTypeReference(RuntimeCoreType.SByte)));

                case EnumerationBaseType.Byte:
                    return(GetTypeSize(IntermediateCliGateway.GlobalManager.ObtainTypeReference(RuntimeCoreType.Byte)));

                case EnumerationBaseType.Int16:
                    return(GetTypeSize(IntermediateCliGateway.GlobalManager.ObtainTypeReference(RuntimeCoreType.Int16)));

                case EnumerationBaseType.UInt16:
                    return(GetTypeSize(IntermediateCliGateway.GlobalManager.ObtainTypeReference(RuntimeCoreType.UInt16)));

                case EnumerationBaseType.Int32:
                    return(GetTypeSize(IntermediateCliGateway.GlobalManager.ObtainTypeReference(RuntimeCoreType.Int32)));

                case EnumerationBaseType.UInt32:
                    return(GetTypeSize(IntermediateCliGateway.GlobalManager.ObtainTypeReference(RuntimeCoreType.UInt32)));

                case EnumerationBaseType.Int64:
                    return(GetTypeSize(IntermediateCliGateway.GlobalManager.ObtainTypeReference(RuntimeCoreType.Int64)));

                case EnumerationBaseType.UInt64:
                    return(GetTypeSize(IntermediateCliGateway.GlobalManager.ObtainTypeReference(RuntimeCoreType.UInt64)));

                case EnumerationBaseType.NativeInteger:
                    return(Marshal.SizeOf(typeof(IntPtr)));

                case EnumerationBaseType.NativeUnsignedInteger:
                    return(Marshal.SizeOf(typeof(UIntPtr)));

                case EnumerationBaseType.Default:
                default:
                    goto case EnumerationBaseType.Int32;
                }
            }
            else if (primitiveSizes.ContainsKey(type))
            {
                return(primitiveSizes[type]);
            }
            else if (type is ICliType)
            {
                var typeName     = type.FullName;
                var assemblyName = type.Assembly.ToString();
                var assem        = Assembly.Load(new AssemblyName(assemblyName));
                var targetType   = assem.GetType(typeName);
                return(Marshal.SizeOf(targetType));
            }
            throw new ArgumentOutOfRangeException("type");
        }
예제 #3
0
        public static EnumValue <T> Parse(IEnumType <T> type, string str)
        {
            EnumValue <T> value2 = null;

            if (!EnumValue <T> .TryParse(type, str, out value2))
            {
                throw new FormatException($"Cannot parse '{str}' to EnumValue of type '{type.Name}'!");
            }
            return(value2);
        }
예제 #4
0
 private void AddNewLegendItem(IEnumType enumType, Brush brush)
 {
     if (enumTypes.Count(x => x.EnumType.Equals(enumType)) == 0)
     {
         var legendItem = new PieLegendItem(enumType, brush);
         legendItem.MouseOn  += LegendItem_MouseOn;
         legendItem.MouseOut += LegendItem_MouseOut;
         LegendItemsStackPanel.Children.Add(legendItem);
         enumTypes.Add(legendItem);
     }
 }
예제 #5
0
 public void ReferenceDeclaration(IEnumType declaration)
 {
     if (declaration is IIntermediateEnumType)
     {
         this.ReferenceDeclaration((IIntermediateEnumType)declaration);
     }
     else
     {
         this.Formatter.ReferenceDeclaration(declaration);
     }
 }
예제 #6
0
        private void editorBrowsableState_Disposed(object sender, EventArgs e)
        {
            if (this.editorBrowsableState != null)
            {
#if DEBUG
                Debug.WriteLine("EditorBrowsableState Disposed.");
#endif
                this.editorBrowsableState.Disposed -= editorBrowsableState_Disposed;
                this.editorBrowsableState           = null;
            }
        }
예제 #7
0
 /// <summary>
 /// Initialize new instance of <see cref="EnumTypeModel"/>.
 /// </summary>
 /// <param name="name">
 /// The name of the enum type.
 /// </param>
 /// <param name="description">
 /// The description of the enum type.
 /// </param>
 /// <param name="type">
 /// The enum type.
 /// </param>
 /// <param name="underlyingType">
 /// The underlying runtime type.
 /// </param>
 /// <param name="values">
 /// The enum values.
 /// </param>
 public EnumTypeModel(
     NameString name,
     string?description,
     IEnumType type,
     string?underlyingType,
     IReadOnlyList <EnumValueModel> values)
     : base(name, description, type, TypeNames.String, name)
 {
     Type           = type ?? throw new ArgumentNullException(nameof(type));
     UnderlyingType = underlyingType;
     Values         = values ?? throw new ArgumentNullException(nameof(values));
 }
예제 #8
0
        public static bool TryParse(IEnumType <T> type, string str, out EnumValue <T> value)
        {
            T    local;
            bool flag = false;

            value = null;
            if (type.EnumValues.TryParse(str, out local))
            {
                value = new EnumValue <T>(type, local);
                flag  = true;
            }
            return(flag);
        }
예제 #9
0
        public PieLegendItem(IEnumType enumType, Brush color)
        {
            InitializeComponent();

            InitialFontSize        = ItemName.FontSize;
            InitialBorderThickness = ItemColor.BorderThickness.Left;
            InitialSideSize        = ItemColor.Height;

            ItemColor.Background = InitialBrush = color;
            ItemName.Text        = enumType.ToString();

            EnumType = enumType;
        }
예제 #10
0
        internal static IEnumValue Create(IEnumType enumType, byte[] bytes, int offset)
        {
            Type   managedType = ((IManagedMappableType)enumType).ManagedType;
            object obj2        = null;

            if (managedType == typeof(byte))
            {
                obj2 = bytes[offset];
            }
            else if (managedType == typeof(sbyte))
            {
                obj2 = (sbyte)bytes[offset];
            }
            else if (managedType == typeof(short))
            {
                obj2 = BitConverter.ToInt16(bytes, offset);
            }
            else if (managedType == typeof(ushort))
            {
                obj2 = BitConverter.ToUInt16(bytes, offset);
            }
            else if (managedType == typeof(int))
            {
                obj2 = BitConverter.ToInt32(bytes, offset);
            }
            else if (managedType == typeof(uint))
            {
                obj2 = BitConverter.ToUInt32(bytes, offset);
            }
            else if (managedType == typeof(long))
            {
                obj2 = BitConverter.ToInt64(bytes, offset);
            }
            else
            {
                if (managedType != typeof(ulong))
                {
                    throw new ArgumentException("Wrong Enum base type.");
                }
                obj2 = BitConverter.ToUInt64(bytes, offset);
            }
            return(Create(enumType, obj2));
        }
예제 #11
0
        private void OutTypeData(IEnumType enumType)
        {
            DiagramStatInfo.Clear();
            DiagramStatInfo.Header = enumType.Item;

            var items = binsBunches.Select(x => x.Scopes[enumType]).Where(x => x != null);

            foreach (var item in items)
            {
                DiagramStatInfo.Add(item.Sum.ToString("f2"), item.Ratio.ToString("P2"));
            }
            var sum = items.Sum(x => x.Sum);

            DiagramStatInfo.Add($"Total: {sum:f2}", DiagramStatInfo.ColumnType.Data);

            var avgPercent = sum / binsBunches.Sum(x => x.Scopes.TotalSum);

            DiagramStatInfo.Add($"Average: {items.Average(x => x.Sum):f2}", $"{avgPercent:P2}");
        }
예제 #12
0
        internal static IEnumValue Create(IEnumType enumType, object value)
        {
            Type managedType = ((IManagedMappableType)enumType).ManagedType;

            if (managedType == typeof(byte))
            {
                return(new EnumValue <byte>((IEnumType <byte>)enumType, (byte)value));
            }
            if (managedType == typeof(sbyte))
            {
                return(new EnumValue <sbyte>((IEnumType <sbyte>)enumType, (sbyte)value));
            }
            if (managedType == typeof(short))
            {
                return(new EnumValue <short>((IEnumType <short>)enumType, (short)value));
            }
            if (managedType == typeof(ushort))
            {
                return(new EnumValue <ushort>((IEnumType <ushort>)enumType, (ushort)value));
            }
            if (managedType == typeof(int))
            {
                return(new EnumValue <int>((IEnumType <int>)enumType, (int)value));
            }
            if (managedType == typeof(uint))
            {
                return(new EnumValue <uint>((IEnumType <uint>)enumType, (uint)value));
            }
            if (managedType == typeof(long))
            {
                return(new EnumValue <long>((IEnumType <long>)enumType, (long)value));
            }
            if (managedType != typeof(ulong))
            {
                throw new NotSupportedException();
            }
            return(new EnumValue <ulong>((IEnumType <ulong>)enumType, (ulong)value));
        }
예제 #13
0
        internal int Marshal(IDataType type, Encoding encoding, object val, byte[] bValue, int offset)
        {
            int  num   = 0;
            Type type2 = val.GetType();

            switch (type.Category)
            {
            case DataTypeCategory.Primitive:
            case DataTypeCategory.SubRange:
            case DataTypeCategory.String:
                num     = this._internalConverter.TypeMarshaller.Marshal(type, encoding, val, bValue, offset);
                offset += num;
                return(num);

            case DataTypeCategory.Alias:
            {
                IAliasType type3 = (IAliasType)type;
                return(this.Marshal(type3.BaseType, encoding, val, bValue, offset));
            }

            case DataTypeCategory.Enum:
            {
                IEnumType enumType = (IEnumType)type;
                if (!type2.IsEnum)
                {
                    throw new ArgumentException("Type is not an enum type!", "type");
                }
                IEnumValue value2 = EnumValueFactory.Create(enumType, val);
                Array.Copy(value2.RawValue, 0, bValue, offset, value2.RawValue.Length);
                offset += value2.RawValue.Length;
                return(num + value2.RawValue.Length);
            }

            case DataTypeCategory.Array:
                break;

            case DataTypeCategory.Struct:
                foreach (IMember member in ((IStructType)type).AllMembers)
                {
                    PropertyInfo property = type2.GetProperty(member.InstanceName, BindingFlags.Public | BindingFlags.IgnoreCase);
                    if (((property != null) && (property.GetGetMethod() != null)) && (property.GetSetMethod() != null))
                    {
                        num += this.Marshal(member, property.GetValue(type2, new object[0]), bValue, offset);
                        continue;
                    }
                    FieldInfo field = type2.GetField(member.InstanceName, BindingFlags.Public | BindingFlags.IgnoreCase);
                    if (field == null)
                    {
                        throw new ArgumentException("Struct member not found!", "type");
                    }
                    num += this.Marshal(member, field.GetValue(type2), bValue, offset);
                }
                return(num);

            default:
                throw new NotSupportedException();
            }
            IArrayType type6     = (IArrayType)type;
            int        arrayRank = type2.GetArrayRank();
            Array      array     = (Array)val;

            int[] numArray  = new int[arrayRank];
            int[] numArray2 = new int[arrayRank];
            int[] numArray3 = new int[arrayRank];
            int[] numArray4 = new int[arrayRank];
            int   index     = 0;

            while (true)
            {
                if (index >= arrayRank)
                {
                    int position = 0;
                    while (position < type6.Dimensions.ElementCount)
                    {
                        int[] indicesOfPosition = ((ArrayType)type6).GetIndicesOfPosition(position);
                        int[] indices           = new int[indicesOfPosition.Length];
                        int   num6 = 0;
                        while (true)
                        {
                            if (num6 >= indicesOfPosition.Length)
                            {
                                object obj4          = array.GetValue(indices);
                                int    elementOffset = ((ArrayType)type6).GetElementOffset(indices);
                                num += this.Marshal(type, encoding, obj4, bValue, offset + elementOffset);
                                position++;
                                break;
                            }
                            int num7 = numArray[num6] - numArray3[num6];
                            indices[num6] = indicesOfPosition[num6] + num7;
                            num6++;
                        }
                    }
                    break;
                }
                numArray[index]  = array.GetLowerBound(index);
                numArray2[index] = array.GetUpperBound(index);
                numArray3[index] = ((Dimension)type6.Dimensions[index]).LowerBound;
                numArray4[index] = ((Dimension)type6.Dimensions[index]).UpperBound;
                index++;
            }
            return(num);
        }
예제 #14
0
 public void ReferenceDeclaration(IEnumType declaration)
 {
 }
예제 #15
0
 internal EnumValue(IEnumType <T> enumType, T value)
 {
     this._size  = enumType.Size;
     this._value = value;
     this._name  = enumType.ToString(this._value);
 }
예제 #16
0
        public void Select(IEnumType enumType)
        {
            itemToBeSelected = Bins.FirstOrDefault(x => x.Scope.EnumMember.Equals(enumType) && x.Scope.Sum != 0);

            itemToBeSelected?.Select();
        }
예제 #17
0
 //TODO: add LoadNew(Scopes) method
 //SOLVE: extract some interfaces and other common stuff
 //SOLVE: remake a bit: probably I shouldn't use Model parts at Controls as much
 private void BinsBunch_StatTypeSelected(IEnumType enumType)
 {
     SelectAllItems(enumType);
     OutTypeData(enumType);
 }
예제 #18
0
 private void LegendItem_MouseOut(IEnumType enumType)
 {
     BinsBunch_StatTypeUnselected();
 }
예제 #19
0
 private void LegendItem_MouseOn(IEnumType enumType)
 {
     BinsBunch_StatTypeSelected(enumType);
 }
예제 #20
0
 public void ReferenceDeclaration(IEnumType declaration)
 {
     referenceStack.Push(declaration);
 }
예제 #21
0
        public override void WriteValue(ISymbol symbol, object value, out DateTime utcWriteTime)
        {
            if (symbol == null)
            {
                throw new ArgumentNullException("symbol");
            }
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            int             num      = 0;
            ISymbol         symbol2  = symbol;
            IDataType       dataType = symbol2.DataType;
            IResolvableType type2    = dataType as IResolvableType;

            if (type2 != null)
            {
                dataType = type2.ResolveType(DataTypeResolveStrategy.AliasReference);
            }
            utcWriteTime = DateTime.MinValue;
            if (dataType.IsBitType)
            {
                num = this.tryWriteValue(symbol2, BitTypeConverter.Marshal(dataType.BitSize, value), 0, out utcWriteTime);
            }
            else if (!symbol2.IsPrimitiveType)
            {
                DynamicValue value2 = (DynamicValue)value;
                num = this.TryWriteValue(value2, out utcWriteTime);
            }
            else if (((dataType.Category == DataTypeCategory.Primitive) || (dataType.Category == DataTypeCategory.SubRange)) || (dataType.Category == DataTypeCategory.Pointer))
            {
                num = this.tryWriteValue(symbol2, PrimitiveTypeConverter.Default.Marshal(symbol2.DataType, value), 0, out utcWriteTime);
            }
            else if (dataType.Category == DataTypeCategory.String)
            {
                IStringType type3   = (IStringType)symbol2.DataType;
                byte[]      buffer3 = new PrimitiveTypeConverter(type3.Encoding).Marshal(symbol2.DataType, value);
                if (buffer3.Length >= type3.Size)
                {
                    Exception ex = new AdsErrorException($"String is too large for symbol '{symbol2.InstancePath}' (Type: {symbol2.TypeName}).", AdsErrorCode.DeviceInvalidSize);
                    Module.Trace.TraceError(ex);
                    throw ex;
                }
                num = this.tryWriteValue(symbol2, buffer3, 0, out utcWriteTime);
            }
            else if (dataType.Category == DataTypeCategory.Array)
            {
                IArrayType type4 = (IArrayType)symbol2.DataType;
                num = this.tryWriteValue(symbol2, PrimitiveTypeConverter.Default.Marshal(symbol2.DataType, value), 0, out utcWriteTime);
            }
            else
            {
                if (dataType.Category != DataTypeCategory.Enum)
                {
                    Exception ex = new SymbolException($"Could not write Symbol '{symbol2.InstancePath}' (Type: {symbol2.TypeName}). Category mismatch!", symbol2);
                    Module.Trace.TraceError(ex);
                    throw ex;
                }
                IEnumType type5 = (IEnumType)symbol2.DataType;
                num = this.tryWriteValue(symbol2, PrimitiveTypeConverter.Default.Marshal(symbol2.DataType, value), 0, out utcWriteTime);
            }
            if (num != 0)
            {
                Exception ex = new SymbolException($"Could not write Symbol '{symbol2.InstancePath}' (Type: {symbol2.TypeName})! Error: {num}", symbol2);
                Module.Trace.TraceError(ex);
                throw ex;
            }
        }
예제 #22
0
        private void initializeInstanceValue(IDataType type, Encoding encoding, object targetInstance, Type targetType, object targetMember, byte[] data, int offset)
        {
            object obj2 = null;

            switch (type.Category)
            {
            case DataTypeCategory.Primitive:
            case DataTypeCategory.String:
                this._internalConverter.TypeMarshaller.Unmarshal(type, encoding, data, offset, out obj2);
                this.initializeInstanceValue(targetInstance, targetMember, obj2);
                return;

            case DataTypeCategory.Alias:
            {
                IAliasType type2 = (IAliasType)type;
                this.initializeInstanceValue(type2.BaseType, encoding, targetInstance, targetType, targetMember, data, offset);
                return;
            }

            case DataTypeCategory.Enum:
            {
                IEnumType  enumType    = (IEnumType)type;
                Type       managedType = ((IManagedMappableType)enumType.BaseType).ManagedType;
                IEnumValue value2      = EnumValueFactory.Create(enumType, data, offset);
                if (!targetType.IsEnum)
                {
                    throw new ArgumentException("Type is not an enum type or enum base type!", "type");
                }
                obj2 = Enum.Parse(targetType, value2.ToString(), true);
                this.initializeInstanceValue(targetInstance, targetMember, obj2);
                return;
            }

            case DataTypeCategory.Array:
            {
                IArrayType type6       = (IArrayType)type;
                int        arrayRank   = targetType.GetArrayRank();
                Array      array       = (Array)targetInstance;
                int[]      numArray    = new int[arrayRank];
                int[]      numArray2   = new int[arrayRank];
                int[]      lowerBounds = type6.Dimensions.LowerBounds;
                int[]      upperBounds = type6.Dimensions.UpperBounds;
                for (int i = 0; i < arrayRank; i++)
                {
                    numArray[i]  = array.GetLowerBound(i);
                    numArray2[i] = array.GetUpperBound(i);
                }
                int position = 0;
                while (position < type6.Dimensions.ElementCount)
                {
                    int[] indicesOfPosition = ((ArrayType)type6).GetIndicesOfPosition(position);
                    int[] indices           = new int[indicesOfPosition.Length];
                    int   index             = 0;
                    while (true)
                    {
                        if (index >= indicesOfPosition.Length)
                        {
                            object obj3          = array.GetValue(indices);
                            int    elementOffset = ((ArrayType)type6).GetElementOffset(indicesOfPosition);
                            if (obj3 != null)
                            {
                                this.initializeInstanceValue(type6.ElementType, encoding, obj3, obj3.GetType(), indices, data, elementOffset);
                            }
                            else
                            {
                                TwinCAT.Ads.Module.Trace.TraceError("Failed to fill array element!");
                            }
                            position++;
                            break;
                        }
                        int num6 = numArray[index] - lowerBounds[index];
                        indices[index] = indicesOfPosition[index] + num6;
                        index++;
                    }
                }
                return;
            }

            case DataTypeCategory.Struct:
                foreach (IMember member in ((IStructType)type).AllMembers)
                {
                    PropertyInfo property = targetType.GetProperty(member.InstanceName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase);
                    if (((property != null) && (property.GetGetMethod() != null)) && (property.GetSetMethod() != null))
                    {
                        this.initializeInstanceValue(member.DataType, encoding, targetInstance, targetType, property, data, offset + member.ByteOffset);
                        continue;
                    }
                    FieldInfo field = targetType.GetField(member.InstanceName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase);
                    if (field != null)
                    {
                        this.initializeInstanceValue(member.DataType, encoding, targetInstance, targetType, field, data, offset + member.ByteOffset);
                    }
                    else
                    {
                        object[] args = new object[] { member.InstanceName, targetType.ToString() };
                        TwinCAT.Ads.Module.Trace.TraceWarning("Struct member '{0}' not found within {1}!", args);
                    }
                }
                break;

            case DataTypeCategory.SubRange:
            case DataTypeCategory.Bitset:
                break;

            case DataTypeCategory.Pointer:
            case DataTypeCategory.Reference:
            {
                int byteSize = ((IReferenceType)type).ByteSize;
                return;
            }

            default:
                throw new NotSupportedException();
            }
        }
예제 #23
0
        private void CheckType(IDataType type, Type targetType)
        {
            List <IDataType> list = null;

            if (this._checkedTypesDict.TryGetValue(targetType, out list) && list.Contains(type))
            {
                return;
            }
            switch (type.Category)
            {
            case DataTypeCategory.Primitive:
            case DataTypeCategory.Pointer:
            case DataTypeCategory.Reference:
                if (type.ByteSize > PrimitiveTypeConverter.MarshalSize(targetType))
                {
                    throw new MarshalException($"Source type '{type.Name}' is larger than target type '{targetType.Name}'!");
                }
                goto TR_0007;

            case DataTypeCategory.Alias:
            {
                IAliasType type2 = (IAliasType)type;
                try
                {
                    this.CheckType(type2.BaseType, targetType);
                }
                catch (MarshalException exception)
                {
                    throw new MarshalException($"Cannot Marshal Alias '{type2.Name}' !", exception);
                }
                goto TR_0007;
            }

            case DataTypeCategory.Enum:
            {
                IEnumType type3 = (IEnumType)type;
                if (!targetType.IsEnum)
                {
                    IManagedMappableType baseType = type3.BaseType as IManagedMappableType;
                    bool flag = false;
                    if (baseType == null)
                    {
                        throw new MarshalException($"Type '{targetType.Name}' is not an enum type or enum base type!");
                    }
                    flag = baseType.ManagedType == targetType;
                }
                else
                {
                    string[] names     = type3.EnumValues.GetNames();
                    string[] strArray2 = Enum.GetNames(targetType);
                    if (names.Length > strArray2.Length)
                    {
                        throw new MarshalException($"Enum Types '{type.Name}' and '{targetType.Name}' are not compatible!");
                    }
                    StringComparer ordinalIgnoreCase = StringComparer.OrdinalIgnoreCase;
                    string[]       strArray3         = names;
                    int            index             = 0;
                    while (index < strArray3.Length)
                    {
                        string   x         = strArray3[index];
                        bool     flag2     = false;
                        string[] strArray4 = strArray2;
                        int      num5      = 0;
                        while (true)
                        {
                            if (num5 < strArray4.Length)
                            {
                                string y = strArray4[num5];
                                if (ordinalIgnoreCase.Compare(x, y) != 0)
                                {
                                    num5++;
                                    continue;
                                }
                                flag2 = true;
                            }
                            if (!flag2)
                            {
                                throw new MarshalException($"Enum Types '{type.Name}' and '{targetType.Name}' are not compatible!");
                            }
                            index++;
                            break;
                        }
                    }
                }
                goto TR_0007;
            }

            case DataTypeCategory.Array:
            {
                IArrayType type4 = (IArrayType)type;
                if (!targetType.IsArray)
                {
                    throw new MarshalException($"Type '{targetType.Name}' is not an array type!");
                }
                int arrayRank = targetType.GetArrayRank();
                if (type4.Dimensions.Count != arrayRank)
                {
                    throw new MarshalException($"Array Types '{type.Name}' and '{targetType.Name}' are not compatible!");
                }
                Type elementType = targetType.GetElementType();
                try
                {
                    this.CheckType(type4.ElementType, elementType);
                }
                catch (MarshalException exception2)
                {
                    throw new MarshalException($"Cannot Marshal Elements of Array '{type4.Name}'!", exception2);
                }
                goto TR_0007;
            }

            case DataTypeCategory.Struct:
                foreach (IMember member in ((IStructType)type).AllMembers)
                {
                    PropertyInfo property = targetType.GetProperty(member.InstanceName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase);
                    if (property != null)
                    {
                        this.CheckType(member.DataType, property.PropertyType);
                        continue;
                    }
                    FieldInfo field = targetType.GetField(member.InstanceName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase);
                    if (field != null)
                    {
                        Type fieldType = field.FieldType;
                        try
                        {
                            this.CheckType(member.DataType, fieldType);
                        }
                        catch (MarshalException exception3)
                        {
                            IStructType type6;
                            throw new MarshalException($"Cannot Marshal Member '{member.InstanceName}' of Source Struct '{type6.Name}' to field '{field.Name}' of target struct '{targetType.Name}'!", exception3);
                        }
                    }
                }
                goto TR_0007;

            case DataTypeCategory.SubRange:
            {
                ISubRangeType type9 = (ISubRangeType)type;
                try
                {
                    this.CheckType(type9.BaseType, targetType);
                }
                catch (MarshalException exception4)
                {
                    throw new MarshalException($"Cannot Marshal Subrange '{type9.Name}'!", exception4);
                }
                goto TR_0007;
            }

            case DataTypeCategory.String:
                break;

            case DataTypeCategory.Bitset:
            case DataTypeCategory.Union:
                goto TR_0007;

            default:
                throw new NotSupportedException();
            }
            if (targetType != typeof(string))
            {
                throw new MarshalException($"Type mismatch! Target Type '{type.Name}' is not a string (Marshalling AdsType '{targetType.Name}')!");
            }
TR_0007:
            if (list == null)
            {
                list = new List <IDataType>();
                if (!this._checkedTypesDict.ContainsKey(targetType))
                {
                    this._checkedTypesDict.Add(targetType, list);
                }
            }
            list.Add(type);
        }
예제 #24
0
 private void LegendItem_MouseOn(IEnumType enumType)
 {
     piePieces.FirstOrDefault(x => x.EnumType.Equals(enumType))
     ?.Select();
 }