Esempio n. 1
0
            private string GetComponentName(IValueReference <TValue> componentValue,
                                            [CanBeNull] IReifiedType <TValue> objectNamesType,
                                            [CanBeNull] IMetadataMethodLite getInspectorTitleMethod,
                                            IStackFrame frame,
                                            IValueFetchOptions options, IValueServicesFacade <TValue> services)
            {
                if (objectNamesType != null && getInspectorTitleMethod != null)
                {
                    try
                    {
                        var inspectorTitle = objectNamesType.CallStaticMethod(frame, options, getInspectorTitleMethod,
                                                                              componentValue.GetValue(options));
                        var stringValueRole =
                            new SimpleValueReference <TValue>(inspectorTitle, frame, services.RoleFactory)
                            .AsStringSafe(options);
                        if (stringValueRole != null)
                        {
                            return(stringValueRole.GetString());
                        }
                    }
                    catch (Exception e)
                    {
                        myLogger.Error(e, "Unable to fetch object names for {0}", componentValue);
                    }
                }

                return(componentValue.GetPrimaryRole(options).ReifiedType.MetadataType.ShortName);
            }
Esempio n. 2
0
            private string GetComponentName(IValueReference <TValue> componentValue,
                                            [CanBeNull] IReifiedType <TValue> objectNamesType,
                                            [CanBeNull] IMetadataMethodLite getInspectorTitleMethod,
                                            IStackFrame frame,
                                            IValueFetchOptions options,
                                            IValueServicesFacade <TValue> services,
                                            out bool isNameFromValue)
            {
                if (objectNamesType != null && getInspectorTitleMethod != null)
                {
                    try
                    {
                        var inspectorTitle = objectNamesType.CallStaticMethod(frame, options, getInspectorTitleMethod,
                                                                              componentValue.GetValue(options));
                        var stringValueRole =
                            new SimpleValueReference <TValue>(inspectorTitle, frame, services.RoleFactory)
                            .AsStringSafe(options);
                        if (stringValueRole != null)
                        {
                            isNameFromValue = true;
                            return(stringValueRole.GetString());
                        }
                    }
                    catch (EvaluatorAbortedException e)
                    {
                        myLogger.LogExceptionSilently(e);
                    }
                    catch (Exception e)
                    {
                        myLogger.Warn(e, ExceptionOrigin.Algorithmic,
                                      $"Unable to fetch object names for {componentValue}");
                    }
                }

                isNameFromValue = false;
                return(componentValue.GetPrimaryRole(options).ReifiedType.MetadataType.ShortName);
            }