Пример #1
0
 internal ProjectData(string projectId, NuGetProjectType projectType, int nullCount, int totalCount)
 {
     ProjectId   = new TelemetryPiiProperty(projectId);
     ProjectType = projectType.ToString();
     NullCount   = nullCount;
     TotalCount  = totalCount;
 }
Пример #2
0
        public static IDictionary <string, object> AsDictionary(object obj)
        {
            IDictionary <string, object> res;

            if (obj == null)
            {
                return(null);
            }

            if ((res = obj as IDictionary <string, object>) != null)
            {
                return(res);
            }

            if (!(obj is PythonToolsLoggerData))
            {
                return(null);
            }

            res = new Dictionary <string, object>();
            foreach (var propInfo in obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance))
            {
                try {
                    var value = propInfo.GetValue(obj);
                    if (propInfo.GetCustomAttributes().OfType <PiiPropertyAttribute>().Any())
                    {
                        value = new TelemetryPiiProperty(value);
                    }
                    res[propInfo.Name] = value;
                } catch (Exception ex) {
                    Debug.Fail(ex.ToUnhandledExceptionMessage(typeof(PythonToolsLoggerData)));
                }
            }
            return(res);
        }
Пример #3
0
        public static IDictionary<string, object> AsDictionary(object obj) {
            IDictionary<string, object> res;

            if (obj == null) {
                return null;
            }

            if ((res = obj as IDictionary<string, object>) != null) {
                return res;
            }

            if (!(obj is PythonToolsLoggerData)) {
                return null;
            }

            res = new Dictionary<string, object>();
            foreach (var propInfo in obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)) {
                try {
                    var value = propInfo.GetValue(obj);
                    if (propInfo.GetCustomAttributes().OfType<PiiPropertyAttribute>().Any()) {
                        value = new TelemetryPiiProperty(value);
                    }
                    res[propInfo.Name] = value;
                } catch (Exception ex) {
                    Debug.Fail(ex.ToUnhandledExceptionMessage(typeof(PythonToolsLoggerData)));
                }
            }
            return res;
        }