public override bool CanCreateObjectId(DbgValue value, CreateObjectIdOptions options)
 {
     if (value == null)
     {
         throw new ArgumentNullException(nameof(value));
     }
     return(GetRuntimeObjectIdService(value.Runtime).CanCreateObjectId(value, options));
 }
        public override DbgObjectId[] CreateObjectIds(DbgValue[] values, CreateObjectIdOptions options)
        {
            if (values == null)
            {
                throw new ArgumentNullException(nameof(values));
            }
            if (values.Length == 0)
            {
                return(Array.Empty <DbgObjectId>());
            }
            // Common case
            if (values.Length == 1)
            {
                var value = values[0] ?? throw new ArgumentException();
                return(GetRuntimeObjectIdService(value.Runtime).CreateObjectIds(values, options));
            }
            var dict = new Dictionary <DbgRuntime, List <(DbgValue value, int index)> >();

            for (int i = 0; i < values.Length; i++)
            {
                var value = values[i];
                if (value == null)
                {
                    throw new ArgumentException();
                }
                if (!dict.TryGetValue(value.Runtime, out var list))
                {
                    dict.Add(value.Runtime, list = new List <(DbgValue, int)>());
                }
                list.Add((value, i));
            }
            var res = new DbgObjectId[values.Length];

            foreach (var kv in dict)
            {
                var objectIds = GetRuntimeObjectIdService(kv.Key).CreateObjectIds(kv.Value.Select(a => a.value).ToArray(), options);
                if (objectIds.Length != kv.Value.Count)
                {
                    throw new InvalidOperationException();
                }
                for (int i = 0; i < objectIds.Length; i++)
                {
                    res[kv.Value[i].index] = objectIds[i];
                }
            }
            return(res);
        }
Ejemplo n.º 3
0
 public abstract bool CanCreateObjectId(DbgValue value, CreateObjectIdOptions options);
Ejemplo n.º 4
0
 public abstract DbgObjectId[] CreateObjectIds(DbgValue[] values, CreateObjectIdOptions options);
Ejemplo n.º 5
0
 /// <summary>
 /// Creates an object id or returns null
 /// </summary>
 /// <param name="value">Value</param>
 /// <param name="options">Options</param>
 /// <returns></returns>
 public DbgObjectId CreateObjectId(DbgValue value, CreateObjectIdOptions options = CreateObjectIdOptions.None) =>
 CreateObjectIds(new[] { value ?? throw new ArgumentNullException(nameof(value)) }, options)[0];