Exemplo n.º 1
0
        /// <summary>
        /// If the PluginType is an open generic type, this method will create a
        /// closed type copy of this PluginFamily
        /// </summary>
        /// <param name="templateTypes"></param>
        /// <returns></returns>
        public PluginFamily CreateTemplatedClone(Type[] templateTypes)
        {
            var templatedType   = _pluginType.MakeGenericType(templateTypes);
            var templatedFamily = new PluginFamily(templatedType);

            templatedFamily.copyLifecycle(this);

            _instances.GetAll().Select(x => {
                var clone = x.CloseType(templateTypes);
                if (clone == null)
                {
                    return(null);
                }

                clone.Name = x.Name;
                return(clone);
            }).Where(x => x != null).Each(templatedFamily.AddInstance);

            if (GetDefaultInstance() != null)
            {
                var defaultKey = GetDefaultInstance().Name;
                var @default   = templatedFamily.Instances.FirstOrDefault(x => x.Name == defaultKey);
                if (@default != null)
                {
                    templatedFamily.SetDefault(@default);
                }
            }

            if (MissingInstance != null)
            {
                templatedFamily.MissingInstance = MissingInstance.CloseType(templateTypes);
            }

            //Are there instances that close the templatedtype straight away?
            _instances.GetAll()
            .Where(x => x.ReturnedType.CanBeCastTo(templatedType))
            .Each(templatedFamily.AddInstance);

            return(templatedFamily);
        }
Exemplo n.º 2
0
        public static StatsReport From(ISchema schema, Operation operation, PerfRecord[] records, DateTime start)
        {
            var operationStat = records.Single(x => string.Equals(x.Category, "operation"));

            var report = new StatsReport
            {
                Start    = start,
                End      = start.AddMilliseconds(operationStat.Duration),
                Duration = operationStat.Duration,
                Types    = TypesFromSchema(schema)
            };

            var perField = new LightweightCache <string, TypeStat>(type => new TypeStat {
                Name = type
            });

            var typeInfo = new TypeInfo(schema);

            var fieldVisitor = new EnterLeaveListener(_ =>
            {
                _.Match <AstField>(f =>
                {
                    var parent     = typeInfo.GetParentType().GetNamedType();
                    var parentType = parent.Name;
                    var fieldName  = f.Name;

                    perField[parentType][fieldName].ReturnType = SchemaPrinter.ResolveName(typeInfo.GetLastType());
                });
            });

            new BasicVisitor(typeInfo, fieldVisitor).Visit(operation);

            var queryResolvers = records.Where(x => string.Equals(x.Category, "field")).ToList();

            queryResolvers.Apply(resolver =>
            {
                var typeName  = resolver.MetaField <string>("typeName");
                var fieldName = resolver.MetaField <string>("fieldName");

                perField[typeName][fieldName].AddLatency(resolver.Duration);
            });

            var operationName = operation.Name ?? "Anonymous";

            report.PerSignature[operationName] = new StatsPerSignature {
                PerType = perField.GetAll()
            };

            return(report);
        }
Exemplo n.º 3
0
        public IChannel[] Start(IHandlerPipeline pipeline, BusSettings settings, OutgoingChannels channels)
        {
            _pipeline = pipeline;

            foreach (var address in settings.KnownSubscribers.Where(x => x.Uri.Scheme == Protocol))
            {
                Channels[address.Uri] = new StubChannel(address.Uri, _replyUri, pipeline, address);
            }

            foreach (var node in settings.Listeners.Where(x => x.Uri.Scheme == Protocol))
            {
                Channels.FillDefault(node.Uri);
            }



            return(Channels.GetAll().OfType <IChannel>().ToArray());
        }
Exemplo n.º 4
0
 public IEnumerable <Type> AllCommandTypes()
 {
     return(_commandTypes.GetAll());
 }
Exemplo n.º 5
0
 internal string[] AllQueueNames()
 {
     return _queues.GetAll().Select(x => x.Name).ToArray();
 }
Exemplo n.º 6
0
 public static IEnumerable <MimeType> All()
 {
     return(_mimeTypes.GetAll());
 }