public void UpdateKnownTypeDetail(InterfaceDescription interfaceDescription, MethodBodyTypesBuildResult methodBodyTypesBuildResult)
        {
            var responseKnownTypes = new List <Type>();
            var requestKnownType   = new List <Type>();

            foreach (var entry in interfaceDescription.Methods)
            {
                if (TypeUtility.IsTaskType(entry.ReturnType) && entry.ReturnType.GetTypeInfo().IsGenericType)
                {
                    var returnType = entry.MethodInfo.ReturnType.GetGenericArguments()[0];
                    if (!responseKnownTypes.Contains(returnType))
                    {
                        responseKnownTypes.Add(returnType);
                    }
                }

                requestKnownType.AddRange(entry.MethodInfo.GetParameters()
                                          .ToList()
                                          .Select(p => p.ParameterType)
                                          .Except(requestKnownType));
            }

            var knownType = new InterfaceDetails
            {
                Id = interfaceDescription.Id,
                ServiceInterfaceType      = interfaceDescription.InterfaceType,
                RequestKnownTypes         = requestKnownType,
                ResponseKnownTypes        = responseKnownTypes,
                MethodNames               = interfaceDescription.Methods.ToDictionary(item => item.Name, item => item.Id),
                RequestWrappedKnownTypes  = methodBodyTypesBuildResult.GetRequestBodyTypes(),
                ResponseWrappedKnownTypes = methodBodyTypesBuildResult.GetResponseBodyTypes(),
            };

            this.UpdateKnownTypes(interfaceDescription.Id, interfaceDescription.InterfaceType.FullName, knownType);
        }
        public bool TryGetKnownTypes(string interfaceName, out InterfaceDetails interfaceDetails)
        {
            if (!this.interfaceIdMapping.TryGetValue(interfaceName, out var interfaceId))
            {
                // TODO : Add EventSource diagnostics
                interfaceDetails = null;
                return(false);
            }

            return(this.knownTypesMap.TryGetValue(interfaceId, out interfaceDetails));
        }
        private void UpdateKnownTypes(
            int interfaceId,
            string interfaceName,
            InterfaceDetails knownTypes)
        {
            if (this.knownTypesMap.ContainsKey(interfaceId))
            {
                // TODO : Add EventSource diagnostics
                return;
            }

            if (this.knownTypesMap.TryAdd(interfaceId, knownTypes))
            {
                this.interfaceIdMapping.TryAdd(interfaceName, interfaceId);
            }
        }
 public bool TryGetKnownTypes(int interfaceId, out InterfaceDetails interfaceDetails)
 {
     return(this.knownTypesMap.TryGetValue(interfaceId, out interfaceDetails));
 }
Ejemplo n.º 5
0
 internal static bool TryGetKnownTypes(string interfaceName, out InterfaceDetails interfaceDetails)
 {
     return(InterfaceDetailsStore.TryGetKnownTypes(interfaceName, out interfaceDetails));
 }