Ejemplo n.º 1
0
        private string TypeHeader()
        {
            var specKind = TypeExtractor.GetSpecialKind(_kind);

            if (specKind != ClrElementKind.Unknown)
            {
                switch (specKind)
                {
                case ClrElementKind.Free:
                case ClrElementKind.Guid:
                case ClrElementKind.DateTime:
                case ClrElementKind.TimeSpan:
                case ClrElementKind.Decimal:
                    return(Constants.PrimitiveHeader);

                case ClrElementKind.Interface:
                    return(Constants.InterfaceHeader);

                case ClrElementKind.Enum:
                    return(Constants.PrimitiveHeader);

                case ClrElementKind.SystemVoid:
                    return(Constants.StructHeader);

                case ClrElementKind.SystemObject:
                case ClrElementKind.System__Canon:
                case ClrElementKind.Exception:
                case ClrElementKind.Abstract:
                    return(Constants.ClassHeader);
                }
                throw new MdrException("[ClrtDisplayableType.TypeHeader] Not all cases are handled for (specKind != ClrElementKind.Unknown).");
            }
            else
            {
                switch (TypeExtractor.GetStandardKind(_kind))
                {
                case ClrElementKind.String:
                    return(Constants.PrimitiveHeader);

                case ClrElementKind.SZArray:
                case ClrElementKind.Array:
                case ClrElementKind.Object:
                case ClrElementKind.Class:
                    return(Constants.ClassHeader);

                case ClrElementKind.Struct:
                    return(Constants.StructHeader);

                case ClrElementKind.Unknown:
                    return(Constants.PrimitiveHeader);

                default:
                    return(Constants.PrimitiveHeader);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get type display panel.
        /// </summary>
        /// <param name="dispType">Type information.</param>
        /// <returns>Adorned panel.</returns>
        public static StackPanel GetClrtDisplayableTypeStackPanel(ClrtDisplayableType dispType)
        {
            var stackPanel = new StackPanel()
            {
                Orientation = Orientation.Horizontal
            };

            Image image = new Image();

            if (dispType.IsDummy)
            {
                image.Source = ((Image)Application.Current.FindResource("GroupPng")).Source;
                stackPanel.Children.Add(image);
                stackPanel.Children.Add(GetClrtDisplayableTypeTextBlock(dispType));
                return(stackPanel);
            }

            var kind     = dispType.Kind;
            var specKind = TypeExtractor.GetSpecialKind(kind);

            if (specKind != ClrElementKind.Unknown)
            {
                switch (specKind)
                {
                case ClrElementKind.Free:
                case ClrElementKind.Guid:
                case ClrElementKind.DateTime:
                case ClrElementKind.TimeSpan:
                case ClrElementKind.Decimal:
                    image.Source = ((Image)Application.Current.FindResource("PrimitivePng")).Source;
                    break;

                case ClrElementKind.Interface:
                    image.Source = ((Image)Application.Current.FindResource("InterfacePng")).Source;
                    break;

                case ClrElementKind.Enum:
                    image.Source = ((Image)Application.Current.FindResource("EnumPng")).Source;
                    break;

                case ClrElementKind.SystemObject:
                case ClrElementKind.System__Canon:
                case ClrElementKind.Exception:
                case ClrElementKind.Abstract:
                    image.Source = ((Image)Application.Current.FindResource("ClassPng")).Source;
                    break;

                case ClrElementKind.SystemNullable:
                    image.Source = ((Image)Application.Current.FindResource("StructPng")).Source;
                    break;
                }
            }
            else
            {
                switch (TypeExtractor.GetStandardKind(kind))
                {
                case ClrElementKind.String:
                    image.Source = ((Image)Application.Current.FindResource("PrimitivePng")).Source;
                    break;

                case ClrElementKind.SZArray:
                case ClrElementKind.Array:
                    image.Source = ((Image)Application.Current.FindResource("ArrayPng")).Source;
                    break;

                case ClrElementKind.Object:
                case ClrElementKind.Class:
                    image.Source = ((Image)Application.Current.FindResource("ClassPng")).Source;
                    break;

                case ClrElementKind.Struct:
                    image.Source = ((Image)Application.Current.FindResource("StructPng")).Source;
                    break;

                case ClrElementKind.Unknown:
                    image.Source = ((Image)Application.Current.FindResource("QuestionPng")).Source;
                    break;

                default:
                    image.Source = ((Image)Application.Current.FindResource("PrimitivePng")).Source;
                    break;
                }
            }

            stackPanel.Children.Add(image);
            stackPanel.Children.Add(GetClrtDisplayableTypeTextBlock(dispType));
            return(stackPanel);
        }
Ejemplo n.º 3
0
        public bool Accept(object obj)
        {
            bool accept   = true;
            var  specKind = TypeExtractor.GetSpecialKind(_kind);

            if (specKind != ClrElementKind.Unknown)
            {
                switch (specKind)
                {
                case ClrElementKind.Exception:
                case ClrElementKind.Enum:
                case ClrElementKind.Free:
                    break;

                case ClrElementKind.Guid:
                    accept = AcceptGuid((Guid)obj, (Guid)_value, _op);
                    break;

                case ClrElementKind.DateTime:
                    accept = Accept <DateTime>((DateTime)obj, (DateTime)_value, _op);
                    break;

                case ClrElementKind.TimeSpan:
                    accept = Accept <TimeSpan>((TimeSpan)obj, (TimeSpan)_value, _op);
                    break;

                case ClrElementKind.Decimal:
                    accept = Accept <decimal>((decimal)obj, (decimal)_value, _op);
                    break;

                case ClrElementKind.SystemVoid:
                    break;

                case ClrElementKind.SystemObject:
                case ClrElementKind.Interface:
                case ClrElementKind.Abstract:
                case ClrElementKind.System__Canon:
                    accept = Accept <ulong>((ulong)obj, (ulong)_value, _op);
                    break;

                default:
                    break;
                }
            }
            else
            {
                var stdKind = TypeExtractor.GetStandardKind(_kind);
                switch (stdKind)
                {
                case ClrElementKind.Class:
                case ClrElementKind.Struct:
                    break;

                case ClrElementKind.SZArray:
                case ClrElementKind.Array:
                case ClrElementKind.Object:
                    accept = Accept <ulong>((ulong)obj, (ulong)_value, _op);
                    break;

                case ClrElementKind.Boolean:
                    accept = AcceptBoolean((bool)obj, (bool)_value);
                    break;

                case ClrElementKind.Char:     // ?
                    accept = Accept <char>((char)obj, (char)_value, _op);
                    break;

                case ClrElementKind.Int8:
                    accept = Accept <sbyte>((sbyte)obj, (sbyte)_value, _op);
                    break;

                case ClrElementKind.Int16:
                    accept = Accept <Int16>((Int16)obj, (Int16)_value, _op);
                    break;

                case ClrElementKind.Int32:
                    accept = Accept <Int32>((Int32)obj, (Int32)_value, _op);
                    break;

                case ClrElementKind.Int64:
                    accept = Accept <long>((long)obj, (long)_value, _op);
                    break;

                case ClrElementKind.UInt8:
                    accept = Accept <byte>((byte)obj, (byte)_value, _op);
                    break;

                case ClrElementKind.UInt16:
                    accept = Accept <Int16>((Int16)obj, (Int16)_value, _op);
                    break;

                case ClrElementKind.UInt32:
                    accept = Accept <UInt32>((UInt32)obj, (UInt32)_value, _op);
                    break;

                case ClrElementKind.UInt64:
                    accept = Accept <UInt64>((ulong)obj, (ulong)_value, _op);
                    break;

                case ClrElementKind.Float:
                case ClrElementKind.Double:
                    accept = Accept <double>((double)obj, (double)_value, _op);
                    break;

                case ClrElementKind.String:
                    accept = AcceptString((string)obj, _filterString, _op);
                    break;

                case ClrElementKind.Pointer:
                case ClrElementKind.NativeInt:
                case ClrElementKind.NativeUInt:
                case ClrElementKind.FunctionPointer:
                    accept = Accept <UInt64>((ulong)obj, (ulong)_value, _op);
                    break;

                default:
                    break;
                }
            }

            return(accept);
        }
Ejemplo n.º 4
0
        private void InitFilterDescription()
        {
            _kind = _dispType.Kind;
            Debug.Assert(_kind != ClrElementKind.Unknown);
            var specKind = TypeExtractor.GetSpecialKind(_kind);

            if (TypeExtractor.IsString(_kind))
            {
                TypeValueDescr.Visibility = Visibility.Hidden;
                TypeValueCase.IsChecked   = _dispType.HasFilter && _dispType.Filter.IsIgnoreCase();
                TypeValueRegex.IsChecked  = _dispType.HasFilter && _dispType.Filter.IsRegex();
                return;
            }

            TypeValueCase.Visibility  = Visibility.Hidden;
            TypeValueRegex.Visibility = Visibility.Hidden;

            if (specKind != ClrElementKind.Unknown)
            {
                switch (specKind)
                {
                case ClrElementKind.Exception:
                    TypeValueDescr.Inlines.Add(new Run("Enter address in hex format: "));
                    TypeValueDescr.Inlines.Add(new Run("0x000083599c5498")
                    {
                        FontWeight = FontWeights.Bold
                    });
                    TypeValueDescr.Inlines.Add(new Run(", leading zeros are not necessary."));
                    break;

                case ClrElementKind.Enum:
                    TypeValueDescr.Inlines.Add(new Run("Enum format is integral value of enumeration."));
                    break;

                case ClrElementKind.Free:
                    TypeValueDescr.Inlines.Add(new Run("Free type should not be filtered!")
                    {
                        FontWeight = FontWeights.Bold, Foreground = Brushes.Red
                    });
                    break;

                case ClrElementKind.Guid:
                    TypeValueDescr.Inlines.Add(new Run("Guid format ex.: "));
                    TypeValueDescr.Inlines.Add(new Run("00000000-0000-0000-0000-000000000000")
                    {
                        FontWeight = FontWeights.Bold
                    });
                    break;

                case ClrElementKind.DateTime:
                    TypeValueDescr.Inlines.Add(new Run("DateTime format ex.: "));
                    TypeValueDescr.Inlines.Add(new Run("2009-06-15T13:45:30")
                    {
                        FontWeight = FontWeights.Bold
                    });
                    TypeValueDescr.Inlines.Add(new Run(" -> 6/15/2009 1:45 PM"));
                    break;

                case ClrElementKind.TimeSpan:
                    TypeValueDescr.Inlines.Add(new Run("TimeSpan format ex.: "));
                    TypeValueDescr.Inlines.Add(new Run("1:3:16:50.5 ")
                    {
                        FontWeight = FontWeights.Bold
                    });
                    break;

                case ClrElementKind.Decimal:
                    TypeValueDescr.Inlines.Add(new Run("Decimal format ex.: "));
                    TypeValueDescr.Inlines.Add(new Run("3.14159265")
                    {
                        FontWeight = FontWeights.Bold
                    });
                    break;

                case ClrElementKind.SystemVoid:
                    TypeValueDescr.Inlines.Add(new Run("System.Void -- unexpected type!")
                    {
                        FontWeight = FontWeights.Bold, Foreground = Brushes.Red
                    });
                    break;

                case ClrElementKind.SystemObject:
                case ClrElementKind.Interface:
                case ClrElementKind.Abstract:
                case ClrElementKind.System__Canon:
                    TypeValueDescr.Inlines.Add(new Run("Enter address in hex format: "));
                    TypeValueDescr.Inlines.Add(new Run("0x000083599c5498")
                    {
                        FontWeight = FontWeights.Bold
                    });
                    TypeValueDescr.Inlines.Add(new Run(", leading zeros are not necessary."));
                    break;

                default:
                    TypeValueDescr.Inlines.Add(new Run("Unexpected type!")
                    {
                        FontWeight = FontWeights.Bold, Foreground = Brushes.Red
                    });
                    break;
                }
            }
            else
            {
                var stdKind = TypeExtractor.GetStandardKind(_kind);
                switch (stdKind)
                {
                case ClrElementKind.Boolean:
                    TypeValueDescr.Inlines.Add(new Run("Valid values for this type, are: "));
                    TypeValueDescr.Inlines.Add(new Run("true")
                    {
                        FontWeight = FontWeights.Bold
                    });
                    TypeValueDescr.Inlines.Add(new Run(" or "));
                    TypeValueDescr.Inlines.Add(new Run("false")
                    {
                        FontWeight = FontWeights.Bold
                    });
                    break;

                case ClrElementKind.Class:
                case ClrElementKind.Struct:
                case ClrElementKind.SZArray:
                case ClrElementKind.Array:
                    break;

                case ClrElementKind.Object:
                    TypeValueDescr.Inlines.Add(new Run("Enter address in hex format: "));
                    TypeValueDescr.Inlines.Add(new Run("0x000083599c5498")
                    {
                        FontWeight = FontWeights.Bold
                    });
                    TypeValueDescr.Inlines.Add(new Run(", leading zeros are not necessary."));
                    break;

                case ClrElementKind.Char:
                case ClrElementKind.Int8:
                case ClrElementKind.UInt8:
                case ClrElementKind.Int16:
                case ClrElementKind.UInt16:
                case ClrElementKind.Int32:
                case ClrElementKind.UInt32:
                case ClrElementKind.Int64:
                case ClrElementKind.UInt64:
                case ClrElementKind.Float:
                case ClrElementKind.Double:
                case ClrElementKind.String:
                case ClrElementKind.Pointer:
                case ClrElementKind.NativeInt:
                case ClrElementKind.NativeUInt:
                case ClrElementKind.FunctionPointer:
                    TypeValueDescr.Inlines.Add(new Run("Primitive type: " + stdKind.ToString() + ", enter in standard format."));
                    break;

                default:
                    TypeValueDescr.Inlines.Add(new Run("Unexpected type!")
                    {
                        FontWeight = FontWeights.Bold, Foreground = Brushes.Red
                    });
                    break;
                }
            }
        }
Ejemplo n.º 5
0
        public bool CanGetFields(out string msg)
        {
            msg = null;
            if (IsDummy)
            {
                msg = "Cannot get fields, this is alternatives grouping node.";
                return(false);
            }
            var specKind = TypeExtractor.GetSpecialKind(_kind);

            if (specKind != ClrElementKind.Unknown)
            {
                switch (specKind)
                {
                case ClrElementKind.Free:
                case ClrElementKind.Guid:
                case ClrElementKind.DateTime:
                case ClrElementKind.TimeSpan:
                case ClrElementKind.Decimal:
                    msg = "Cannot get fields, this type is considered primitive.";
                    return(false);

                case ClrElementKind.Interface:
                    msg = "Cannot get fields of an interface.";
                    return(false);

                case ClrElementKind.Enum:
                    msg = "Cannot get fields, this type is primitive.";
                    return(false);

                case ClrElementKind.Exception:
                    return(true);

                case ClrElementKind.System__Canon:
                    msg = "Cannot get fields, this is System__Canon type.";
                    return(false);

                case ClrElementKind.SystemObject:
                    msg = "Cannot get fields, this is System.Object.";
                    return(false);

                case ClrElementKind.SystemVoid:
                    msg = "Cannot get fields, this is System.Void.";
                    return(false);

                case ClrElementKind.Abstract:
                    msg = "Cannot get fields, this is abstract class.";
                    return(false);
                }
                throw new MdrException("[ClrtDisplayableType.TypeHeader] Not all cases are handled for (specKind != ClrElementKind.Unknown).");
            }
            else
            {
                switch (TypeExtractor.GetStandardKind(_kind))
                {
                case ClrElementKind.String:
                    msg = "Cannot get fields, this type is considered primitive.";
                    return(false);

                case ClrElementKind.SZArray:
                case ClrElementKind.Array:
                    msg = "Cannot get fields, this is array type.";
                    return(false);

                case ClrElementKind.Object:
                case ClrElementKind.Class:
                    return(true);

                case ClrElementKind.Struct:
                    return(true);

                case ClrElementKind.Unknown:
                    msg = "Cannot get fields, the type is unknown.";
                    return(false);

                default:
                    msg = "Cannot get fields, this type is primitive.";
                    return(false);
                }
            }
        }