Ejemplo n.º 1
0
        private void buildImports(ClassStructure classStructure)
        {
            var imports = TypeExtractor.GetTypes(classStructure);

            multiplyTags(imports.Count, ((JSRenderble)DI.Get <IRequestContextImport>()).Name);
            childRenderbles.AddRange(imports.Select(importTypeStructure => (JSRenderble)DI.Get <IRequestContextImport>(importTypeStructure)));
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            // 创建 execution environment
            var env = StreamExecutionEnvironment.GetExecutionEnvironment()
                      // 告诉系统按照 EventTime 处理
                      .SetStreamTimeCharacteristic(TimeCharacteristic.EventTime)
                      // 为了打印到控制台的结果不乱序,我们配置全局的并发为1,改变并发对结果正确性没有影响
                      .SetParallelism(1);

            var file     = Path.Combine(Directory.GetCurrentDirectory(), "Resources", "UserBehavior.csv");
            var pojoType = TypeExtractor.CreateTypeInfo <UserBehavior>() as PojoTypeInfo <UserBehavior>;

            var stream = env.ReadCsvFile <UserBehavior>("")                                            // 创建数据源,得到UserBehavior类型的DataStream
                         .AssignTimestampsAndWatermarks(new UserBehaviorAscendingTimestampExtractor()) // 抽取出时间和生成watermark
                         .Filter(new UserBehaviorFilter())                                             // 过滤出只有点击的数据
                         .KeyBy("itemId")                                                              // 按商品分区统计
                         .TimeWindow(TimeSpan.FromMinutes(60), TimeSpan.FromMinutes(5))                // 窗口大小是一小时,每隔5分钟滑动一次
                         .Aggregate(new CountAggregator(), new WindowResultFunction())                 // 获得每个窗口的点击量的数据流
                         .KeyBy("windowEnd")                                                           // 为了统计每个窗口下最热门的商品,再次按窗口进行分组.
                         .Process(new TopNHotProducts(3));                                             // 计算点击量排名前3名的商品

            stream.Print();                                                                            // 控制台打印输出

            env.Execute("Hot Products Job");
        }
Ejemplo n.º 3
0
        public void TypeExtractOnBinaryOp_ReturnsTwoConsts2()
        {
            var visitor = TypeExtractor <int> .Extract(() => 1 + 2);

            visitor.ExtractedItems.Should().Contain(1);
            visitor.ExtractedItems.Should().Contain(2);
        }
Ejemplo n.º 4
0
        public static StructFieldsEx GetStructFields(StructFields sf, ClrType type)
        {
            Debug.Assert(type.IsValueClass);
            var flds = type.Fields;
            var cnt  = flds.Count;

            StructFieldsEx[] structFields = null;
            var types  = new ClrType[cnt];
            var fields = new ClrInstanceField[cnt];

            for (int i = 0; i < cnt; ++i)
            {
                var fld  = flds[i];
                var kind = TypeExtractor.GetElementKind(fld.Type);
                if (TypeExtractor.IsUnknownStruct(kind))
                {
                    fields[i] = fld;
                    types[i]  = fld.Type;
                    if (structFields == null)
                    {
                        structFields = new StructFieldsEx[cnt];
                    }
                    Debug.Assert(sf.Structs[i] != null);
                    structFields[i] = GetStructFields(sf.Structs[i], fld.Type);
                }
                else
                {
                    fields[i] = fld;
                    types[i]  = fld.Type;
                }
            }
            return(new StructFieldsEx(sf, types, fields, structFields));
        }
Ejemplo n.º 5
0
        public void TypeExtractOnLocal_ReturnsValue()
        {
            var x       = 1;
            var visitor = TypeExtractor <int> .Extract(() => x);

            visitor.ExtractedItems.Should().Contain(1);
        }
Ejemplo n.º 6
0
        public static StructFields GetStructFields(ClrType type)
        {
            Debug.Assert(type.IsValueClass);
            var flds      = type.Fields.ToArray(); // enumeration seems off when this is not done
            var cnt       = flds.Length;
            var kinds     = new ClrElementKind[cnt];
            var names     = new string[cnt];
            var typeNames = new string[cnt];

            StructFields[] structFields = null;

            for (int i = 0; i < cnt; ++i)
            {
                var fld = flds[i];
                kinds[i]     = TypeExtractor.GetElementKind(fld.Type);
                names[i]     = fld.Name;
                typeNames[i] = fld.Type == null ? Constants.UnknownName : fld.Type.Name;
                if (TypeExtractor.IsUnknownStruct(kinds[i]))
                {
                    if (structFields == null)
                    {
                        structFields = new StructFields[cnt];
                    }
                    structFields[i] = GetStructFields(fld.Type);
                }
            }
            return(new StructFields(type.Name, kinds, names, typeNames, structFields));
        }
Ejemplo n.º 7
0
 public void UpdateInstanceValue(InstanceValue instVal, string descr)
 {
     _instValue                = instVal;
     Title                     = TypeExtractor.GetDisplayableTypeName(instVal.TypeName);
     CollectionInfo.Text       = GuiUtils.GetExtraDataString(instVal.ExtraData as KeyValuePair <string, string>[], instVal.TypeName, instVal.Address);
     KeyValuePairs.ItemsSource = instVal.KeyValuePairs;
 }
Ejemplo n.º 8
0
        private void buildImports(TypeStructure typeStructure)
        {
            var imports = TypeExtractor.GetTypes(typeStructure);

            multiplyTags(imports.Count, ((JSRenderble)DI.Get <IImport>(typeStructure)).Name);
            childRenderbles.AddRange(imports.Select(importTypeStructure => (JSRenderble)DI.Get <IImport>(importTypeStructure)));
        }
Ejemplo n.º 9
0
 public void SetField(ClrType parent)
 {
     if (parent.Fields != null && _fldIndex >= 0 && _fldIndex < parent.Fields.Count)
     {
         _field = parent.Fields[_fldIndex];
         _kind  = TypeExtractor.GetElementKind(_field.Type);
     }
 }
Ejemplo n.º 10
0
 public void UpdateInstanceValue(InstanceValue instVal, string descr)
 {
     _instanceValue = instVal;
     Debug.Assert(instVal.ArrayValues != null);
     Title = TypeExtractor.GetDisplayableTypeName(instVal.TypeName);
     CollectionValues.ItemsSource = instVal.ArrayValues;
     CollectionInfo.Text          = descr == null?GuiUtils.GetExtraDataString(instVal.ExtraData as KeyValuePair <string, string>[], instVal.TypeName, instVal.Address) : descr;
 }
Ejemplo n.º 11
0
 public CollectionDisplay(int id, string descr, InstanceValue instVal, bool locked = true)
 {
     _wndType = ValueWindows.WndType.List;
     _id      = id;
     InitializeComponent();
     SetLock(locked);
     UpdateInstanceValue(instVal, descr);
     Title = TypeExtractor.GetDisplayableTypeName(instVal.TypeName);
 }
Ejemplo n.º 12
0
        public ExportRequestContext(ClassStructure classStructure) : base("ExportRequestContext")
        {
            var exportClasses = TypeExtractor.GetTypes(classStructure).Select(x => Configuration.Instance.ModelsNameFactory(x.TypeName)).ToList();

            exportClasses.Add(classStructure.Name);
            tagValues = new Dictionary <string, string> {
                { typesTag, exportClasses.Aggregate((a, b) => $"{a},{b}") }
            };
        }
Ejemplo n.º 13
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.º 14
0
        public void TypeExtractorMustListTypesFromGivenAssembly()
        {
            var targetAssembly = typeof(SampleClass).Assembly;

            ITypeExtractor extractor = new TypeExtractor();
            var            results   = extractor.GetTypes(targetAssembly);

            Assert.NotNull(results);
            Assert.True(results.Count() > 0);
        }
        private MarkdownableType[] GetRuleTypes()
        {
            const string RulesNamespace = "ValidationLibrary.Rules";

            _logger.LogInformation("Generating documentation files for rules in namespace {namespace}", RulesNamespace);
            var validationLibraryAssembly = Assembly.Load(RulesNamespace);
            var types = TypeExtractor.Load(validationLibraryAssembly, RulesNamespace);

            return(types);
        }
Ejemplo n.º 16
0
        public void TypeExtractorMustListTypesFromGivenAssembly()
        {
            Assembly targetAssembly = typeof(SampleClass).Assembly;

            ITypeExtractor     extractor = new TypeExtractor();
            IEnumerable <Type> results   = extractor.GetTypes(targetAssembly);

            Assert.IsNotNull(results);
            Assert.IsTrue(results.Count() > 0);
        }
Ejemplo n.º 17
0
        public static StructValueStrings GetStructValueStrings(StructFieldsEx structFld, ClrHeap heap, ulong addr)
        {
            var cnt        = structFld._fields.Length;
            var structInfo = structFld._structFields;
            var vals       = new string[cnt];

            StructValueStrings[] structVals = null;
            for (int i = 0; i < cnt; ++i)
            {
                if (structInfo.IsAmbiguousKind(i))
                {
                    var fobj  = structFld._fields[i].GetValue(addr, true);
                    var faddr = (ulong)fobj;
                    var ftype = heap.GetObjectType(faddr);
                    if (ftype != null)
                    {
                        structFld._types[i] = ftype;
                        structInfo.SetKind(TypeExtractor.GetElementKind(ftype), i);
                    }
                }
                var fldType = structFld._types[i];
                var fld     = structFld._fields[i];
                var kind    = structFld._structFields.Kinds[i];
                Debug.Assert(fld != null);
                if (structFld._ex?[i] != null)
                {
                    if (structVals == null)
                    {
                        structVals = new StructValueStrings[cnt];
                    }

                    structVals[i] = GetStructValueStrings(structFld._ex[i], heap, fld.GetAddress(addr, true));
                }
                else if (fldType != null)
                {
                    var fobj  = fld.GetValue(addr, true);
                    var faddr = (ulong)fobj;
                    vals[i] = ValueExtractor.GetTypeValueString(heap, faddr, fldType, true, kind);
                }
                else
                {
                    if (TypeExtractor.IsKnownPrimitive(kind))
                    {
                        vals[i] = ValueExtractor.GetFieldValueString(heap, addr, true, fld, kind);
                    }
                    else
                    {
                        var fobj  = fld.GetAddress(addr, true);
                        var faddr = (ulong)fobj;
                        vals[i] = ValueExtractor.GetFieldValueString(heap, faddr, true, fld, kind);
                    }
                }
            }
            return(new StructValueStrings(vals, structVals));
        }
Ejemplo n.º 18
0
        public static ColumnType KindToColumnType(ClrElementKind kind)
        {
            var specKind = TypeExtractor.GetSpecialKind(kind);

            if (specKind != ClrElementKind.Unknown)
            {
                switch (specKind)
                {
                case ClrElementKind.Guid:
                case ClrElementKind.DateTime:
                case ClrElementKind.TimeSpan:
                case ClrElementKind.Decimal:
                case ClrElementKind.Enum:
                case ClrElementKind.Exception:
                    return(ColumnType.String);

                case ClrElementKind.Free:
                case ClrElementKind.Abstract:
                case ClrElementKind.SystemVoid:
                case ClrElementKind.SystemObject:
                    return(ColumnType.UInt64);

                default:
                    throw new ArgumentException("[ReportFile.KindToColumnType(..)] Invalid kind: " + kind.ToString());
                }
            }
            else
            {
                switch (kind)
                {
                case ClrElementKind.String:
                    return(ColumnType.String);

                case ClrElementKind.SZArray:
                case ClrElementKind.Array:
                case ClrElementKind.Object:
                case ClrElementKind.Class:
                    return(ColumnType.UInt64);

                case ClrElementKind.Int16:
                case ClrElementKind.Int32:
                    return(ColumnType.Int32);

                case ClrElementKind.UInt16:
                case ClrElementKind.UInt32:
                    return(ColumnType.UInt32);

                case ClrElementKind.Unknown:
                    throw new ArgumentException("[ReportFile.KindToColumnType(..)] Invalid kind: " + kind.ToString());

                default:
                    return(ColumnType.String);
                }
            }
        }
Ejemplo n.º 19
0
 protected TypeHint()
 {
     try
     {
         TypeInfo = TypeExtractor.CreateTypeInfo <T>();
     }
     catch (InvalidTypesException e)
     {
         throw new FLinkRuntimeException("The TypeHint is using a generic variable." + "This is not supported, generic types must be fully specified for the TypeHint.");
     }
 }
Ejemplo n.º 20
0
 private static TypeInformation <OUT> getWindowFunctionReturnType <IN, OUT, KEY, TW>(
     IWindowFunction <IN, OUT, KEY, TW> function,
     TypeInformation <IN> inType) where TW : Window
 => TypeExtractor.GetUnaryOperatorReturnType <IN, OUT>(
     function,
     typeof(IWindowFunction <IN, OUT, KEY, TW>),
     0,
     1,
     new int[] { 3, 0 },
     inType,
     null,
     false);
Ejemplo n.º 21
0
        public static StructFieldsInfo GetStructFields(ClrType type, ClrHeap heap, ulong addr)
        {
            Debug.Assert(type.IsValueClass);
            var flds = type.Fields;
            var cnt  = flds.Count;

            StructFieldsInfo[] structFields = null;
            var types     = new ClrType[cnt];
            var typeKinds = new ClrElementKind[cnt];
            var fields    = new ClrInstanceField[cnt];
            var fldKinds  = new ClrElementKind[cnt];

            for (int i = 0; i < cnt; ++i)
            {
                var fld   = flds[i];
                var ftype = fld.Type;
                fields[i]    = fld;
                fldKinds[i]  = TypeExtractor.GetElementKind(fld.Type);
                types[i]     = fld.Type;
                typeKinds[i] = fldKinds[i];
                if (TypeExtractor.IsAmbiguousKind(fldKinds[i]))
                {
                    ClrType        fType = null;
                    ClrElementKind fKind = ClrElementKind.Unknown;
                    ClrType        rType = null;
                    ClrElementKind rKind = ClrElementKind.Unknown;
                    //object obj = fld.GetValue(addr, false, false);
                    object obj = fld.GetValue(addr, true, false); // TODO JRD
                    if (obj is ulong)
                    {
                        (fType, fKind, rType, rKind) = TypeExtractor.GetRealType(heap, (ulong)obj);
                    }
                    if (fType != null)
                    {
                        types[i]     = fType;
                        typeKinds[i] = fKind;
                        ftype        = fType;
                    }
                }

                if (TypeExtractor.IsUnknownStruct(fldKinds[i]) || TypeExtractor.IsUnknownStruct(typeKinds[i]))
                {
                    if (structFields == null)
                    {
                        structFields = new StructFieldsInfo[cnt];
                    }
                    var faddr = fld.GetAddress(addr, false);
                    structFields[i] = GetStructFields(types[i], heap, faddr);
                }
            }
            return(new StructFieldsInfo(type, types, typeKinds, fields, fldKinds, structFields));
        }
Ejemplo n.º 22
0
 private void ItemLstGetTypeValuesReportClicked(object sender, RoutedEventArgs e)
 {
     if (_instanceValue.ArrayValues == null || _instanceValue.ArrayValues.Length < 2)
     {
         return;
     }
     if ((TypeExtractor.IsNonStringObjectReference(_instanceValue.Fields[0].Kind)))
     {
         var owner = (MainWindow)Owner;
         // TODO JRD
         //System.Windows.Threading.Dispatcher.CurrentDispatcher.InvokeAsync(() => owner.ExecuteInstanceValueQuery("Getting object value at: " + Utils.RealAddressString(addr), addr));
     }
 }
Ejemplo n.º 23
0
 public T CompileAndCreateInstance <T>(string code)
 {
     using (var provider = CreateProvider())
     {
         var result = Compile(code, provider);
         var dynamicImplementation = TypeExtractor.RetreiveSubTypesFromAssembly(typeof(T), result.CompiledAssembly).FirstOrDefault();
         if (dynamicImplementation.IsNull())
         {
             throw new StardustCoreException("Not able to locate implementation");
         }
         return(ActivatorFactory.Activator.Activate <T>(dynamicImplementation));
     }
 }
Ejemplo n.º 24
0
        public void UpdateInstanceValue(InstanceValue instVal, string descr)
        {
            if (instVal.Parent == null)
            {
                Title = TypeExtractor.GetDisplayableTypeName(instVal.TypeName);
            }
            ClassStructInfo.Text = descr;
            var stackPanel = new StackPanel()
            {
                Orientation = Orientation.Horizontal
            };
            var textBlk = new TextBlock();

            textBlk.Inlines.Add(instVal.ToString());
            stackPanel.Children.Add(textBlk);
            var tvRoot = new TreeViewItem
            {
                Header = GuiUtils.GetInstanceValueStackPanel(instVal),
                Tag    = instVal
            };

            var que = new Queue <KeyValuePair <InstanceValue, TreeViewItem> >();

            que.Enqueue(new KeyValuePair <InstanceValue, TreeViewItem>(instVal, tvRoot));
            while (que.Count > 0)
            {
                var             info         = que.Dequeue();
                InstanceValue   parentNode   = info.Key;
                TreeViewItem    tvParentNode = info.Value;
                InstanceValue[] descendants  = parentNode.Fields;
                for (int i = 0, icount = descendants.Length; i < icount; ++i)
                {
                    var descNode = descendants[i];
                    var tvNode   = new TreeViewItem
                    {
                        Header = GuiUtils.GetInstanceValueStackPanel(descNode),
                        Tag    = descNode
                    };
                    tvParentNode.Items.Add(tvNode);
                    que.Enqueue(new KeyValuePair <InstanceValue, TreeViewItem>(descNode, tvNode));
                }
            }

            var treeView = InstanceValueTreeview;

            treeView.Items.Clear();
            treeView.Items.Add(tvRoot);
            tvRoot.IsSelected = true;
            tvRoot.ExpandSubtree();
        }
Ejemplo n.º 25
0
        public void AddExtensionMethodsFrom(Assembly extensionAssembly)
        {
            var extensionAttributeType = typeof(ExtensionAttribute);

            // Scan the target assembly for extension methods that pertain to the current type
            var typeExtractor = new TypeExtractor();
            var loadedTypes   = typeExtractor.GetTypes(extensionAssembly);

            // Add every extension method inside that assembly
            var bindingFlags     = BindingFlags.Public | BindingFlags.Static;
            var extensionMethods = loadedTypes.SelectMany(t => t.GetMethods(bindingFlags))
                                   .Where(m => m.GetCustomAttributes(extensionAttributeType, false).Any());

            _extensionMethodPool.AddRange(extensionMethods);
        }
Ejemplo n.º 26
0
 public ContentDisplay(int id, string description, InstanceValue instVal, bool locked = true)
 {
     _wndType = ValueWindows.WndType.Content;
     _id      = id;
     InitializeComponent();
     _wordWrapped        = true;
     _instanceValue      = instVal;
     _lockedImg          = new Image();
     _lockedImg.Source   = ValueWindows.LockedImage.Source;
     _unlockedImg        = new Image();
     _unlockedImg.Source = ValueWindows.UnlockedImage.Source;
     UpdateInstanceValue(instVal, description);
     _locked         = locked;
     LockBtn.Content = locked ? _lockedImg : _unlockedImg;
     Title           = TypeExtractor.GetDisplayableTypeName(instVal.TypeName);
 }
Ejemplo n.º 27
0
        GetClassTypeInfo(ClrHeap heap, ulong addr)
        {
            try
            {
                addr = Utils.RealAddress(addr);
                var type = heap.GetObjectType(addr);
                if (type == null)
                {
                    return("Object Value Error" + Constants.HeavyGreekCrossPadded + "Cannot find an instance." + Constants.HeavyGreekCrossPadded + "Heap cannot get object type at address: " + Utils.RealAddressString(addr), null, ClrElementKind.Unknown, null, null);
                }
                var kind   = TypeExtractor.GetElementKind(type);
                var fldCnt = type.Fields.Count;

                var fldTypes = fldCnt == 0 ? Utils.EmptyArray <ClrType> .Value : new ClrType[fldCnt];
                var fldKinds = fldCnt == 0 ? Utils.EmptyArray <ClrElementKind> .Value : new ClrElementKind[fldCnt];
                var strings  = fldCnt == 0 ? Utils.EmptyArray <string> .Value : new string[fldCnt];
                for (int i = 0; i < fldCnt; ++i)
                {
                    var fld     = type.Fields[i];
                    var fldType = fld.Type; // returns ClrElementKind.Unknown if fld.Type is null
                    fldTypes[i] = fldType;
                    var fldKind = TypeExtractor.GetElementKind(fldType);
                    fldKinds[i] = fldKind;
                    if (fldKind == ClrElementKind.Unknown)
                    {
                        continue;                                    // nothing to do here, from MDR lib: There is
                    }
                    // a bug in several versions of our debugging layer which causes this.
                    if (TypeExtractor.IsAmbiguousKind(fldKind))
                    {
                        (ClrType aType, ClrElementKind aKind) = TypeExtractor.GetReferenceFieldRealTypeAndKind(heap, addr, fld);
                        if (aType != null)
                        {
                            fldType     = aType;
                            fldTypes[i] = fldType;
                            fldKind     = aKind;
                            fldKinds[i] = fldKind;
                        }
                    }
                }
                return(null, type, kind, fldTypes, fldKinds);
            }
            catch (Exception ex)
            {
                return(Utils.GetExceptionErrorString(ex), null, ClrElementKind.Unknown, null, null);
            }
        }
Ejemplo n.º 28
0
        private static Type FindType(Type typeToFind, Assembly module, string className)
        {
            var types = TypeExtractor.RetreiveSubTypesFromAssembly(typeToFind, module);

            if (className.ContainsCharacters())
            {
                types = from t in types
                        where t.FullName == className
                        select t;
            }
            var type = types.FirstOrDefault();

            if (type.IsNull())
            {
                throw new StardustCoreException(NoTypeFoundMessage.FormatString(typeToFind.FullName));
            }
            return(type);
        }
Ejemplo n.º 29
0
        private void TypeValueReportFilterMenuitem_OnClick(object sender, RoutedEventArgs e)
        {
            if (_currentTreeViewItem == null)
            {
                return;
            }
            var curDispItem = _currentTreeViewItem.Tag as ClrtDisplayableType;

            Debug.Assert(curDispItem != null);
            if (curDispItem.HasAlternatives)
            {
                StatusText.Text = "This field '" + curDispItem.FieldName + "', has alternatives, itself cannot be queried.";
                return;
            }
            var dlg = new TypeValueFilterDlg(_currentTreeViewItem.Tag as ClrtDisplayableType)
            {
                Owner = this
            };
            bool?dlgResult = dlg.ShowDialog();

            if (dlgResult == true)
            {
                if (dlg.Remove)
                {
                    curDispItem.RemoveFilter();
                }
                else if (TypeExtractor.IsString(curDispItem.Kind))
                {
                    var   op    = dlg.Operator;
                    Regex regex = null;
                    if (FilterValue.IsOp(FilterValue.Op.REGEX, op))
                    {
                        regex = new Regex(dlg.ValueString);
                    }
                    curDispItem.SetFilter(new FilterValue(dlg.ValueString, curDispItem.Kind, dlg.Operator, regex));
                }
                else
                {
                    curDispItem.SetFilter(new FilterValue(dlg.ValueObject, curDispItem.Kind, dlg.Operator));
                }
                GuiUtils.UpdateTypeValueSetupTreeViewItem(_currentTreeViewItem, curDispItem);
                UpdateSelection(curDispItem);
            }
        }
Ejemplo n.º 30
-1
        public void GetValue(ClrHeap heap, ulong address, Queue <ValueTuple <TypeValue, ulong> > que)
        {
            que.Clear();
            que.Enqueue((this, address));
            while (que.Count > 0)
            {
                (TypeValue val, ulong addr) = que.Dequeue();
                if (val._type == null)
                {
                    ClrType clrType = heap.GetObjectType(addr);
                    if (clrType == null)
                    {
                        continue;
                    }
                    val._type = clrType;
                    val._kind = TypeExtractor.GetElementKind(clrType);
                    val.SetValue(addr);
                }
                if (val._children != null)
                {
                    for (int i = 0, icnt = val._children.Length; i < icnt; ++i)
                    {
                        TypeValue fldVal = val._children[i];

                        if (fldVal._fieldName != null && fldVal._field == null)
                        {
                            ClrInstanceField f = val._type.GetFieldByName(fldVal._fieldName);
                            if (f == null)
                            {
                                continue;
                            }
                            fldVal._field = f;
                            fldVal._type  = f.Type;
                            fldVal._kind  = TypeExtractor.GetElementKind(f.Type);
                        }
                        object v = ValueExtractor.GetFieldValue(heap, addr, fldVal._type.IsValueClass, fldVal._field, fldVal._kind);
                        ulong  a = (v is ulong) ? (ulong)v : Constants.InvalidAddress;
                        fldVal.SetValue(v);
                        que.Enqueue((val._children[i], (ulong)val._value));
                    }
                }
                else
                {
                    if (val._fieldName != null && val._field == null)
                    {
                        ClrInstanceField f = val._type.GetFieldByName(val._fieldName);
                        val._field = f;
                        val._type  = f.Type;
                        val._kind  = TypeExtractor.GetElementKind(f.Type);
                    }
                    object v = ValueExtractor.GetFieldValue(heap, addr, val._type.IsValueClass, val._field, val._kind);
                    val.SetValue(v);
                }
            }
        }