Exemple #1
0
        public static Produces <T> AcceptingMany <T>(this Produces <T> produces) where T : Message
        {
            if (produces == null)
            {
                throw new ArgumentNullException("produces");
            }
            var multi = new Multiplexor <T>();

            produces.AttachConsumer(multi);
            return(multi);
        }
Exemple #2
0
        public LazyLoadedProjection(Func <T> factory)
        {
            this.factory = factory;
            var definition = new T();

            Consumes     = definition.Consumes;
            AsyncOptions = definition.AsyncOptions;
            Produces     = (definition as IDocumentsProjection)?.Produces;
            if (Produces?.Any() != true && definition is IDocumentProjection documentProjection)
            {
                Produces = new[] { documentProjection.Produces }
            }
            ;
        }
        public override void ComputeInputs(BuildComponentFactory factory)
        {
            if (Produces.Count == 0)
            {
                return;
            }

            var output = (BuildComponentFlyingGoose)Produces.Where(r => r is BuildComponentFlyingGoose).First();

            Dimension seamAllowance;

            if (output.Trim)
            {
                seamAllowance = new Dimension(0.875, DimensionUnits.Inch);
            }
            else
            {
                seamAllowance = new Dimension(1, DimensionUnits.Inch);
            }

            var producesCount = Produces.Where(r => r is BuildComponentFlyingGoose).Sum(r => r.Quantity);

            var bodyCount  = producesCount;
            var bodyWidth  = output.Area.Width + seamAllowance;
            var bodyHeight = output.Area.Height + seamAllowance;
            var bodyArea   = new Area(bodyWidth, bodyHeight).Round();

            var cornerCount  = producesCount * 2;
            var cornerWidth  = (output.Area.Width / 2) + seamAllowance;
            var cornerHeight = output.Area.Height + seamAllowance;
            var cornerArea   = new Area(cornerWidth, cornerHeight).Round();

            var input1 = factory.CreateBuildComponentRectangle(output.FabricStyles[0], bodyArea);

            input1.Quantity = bodyCount;
            AddInput(input1);

            var input2 = factory.CreateBuildComponentRectangle(output.FabricStyles[1], cornerArea);

            input2.Quantity = cornerCount;
            AddInput(input2);
        }
        public override int CanProduceQuantity(string styleKey)
        {
            if (styleKey == null)
            {
                throw new ArgumentNullException(styleKey);
            }

            if (styleKey == m_producesStyleKey)
            {
                return(int.MaxValue);
            }

            if (styleKey == HalfSquareTriangleStyleFromFlyingGooseStyle(m_producesStyleKey))
            {
                var flyingGooseQuantity = Produces.Where(r => r is BuildComponentFlyingGoose).Sum(r => r.Quantity);
                var triangleQuantity    = Produces.Where(r => r is BuildComponentHalfSquareTriangle).Sum(r => r.Quantity);

                return((flyingGooseQuantity * 2) - triangleQuantity);
            }

            return(0);
        }
Exemple #5
0
        //public List<Security> security { get; set; }

        public void Serialize(JsonWriter writer)
        {
            writer.WritePropertyName(Id);

            writer.WriteStartObject();

            if (Tags != null && Tags.Any())
            {
                writer.WritePropertyName("tags");
                writer.WriteStartArray();
                foreach (string tag in Tags)
                {
                    writer.WriteValue(tag);
                }
                writer.WriteEndArray();
            }

            if (!string.IsNullOrWhiteSpace(Summary))
            {
                writer.WritePropertyName("summary");
                writer.WriteValue(Summary);
            }

            if (!string.IsNullOrWhiteSpace(Description))
            {
                writer.WritePropertyName("description");
                writer.WriteValue(Description);
            }

            if (ExternalDocs != null)
            {
                writer.WritePropertyName("externalDocs");
                ExternalDocs.Serialize(writer);
            }

            if (!string.IsNullOrWhiteSpace(OperationId))
            {
                writer.WritePropertyName("operationId");
                writer.WriteValue(OperationId);
            }

            if (Consumes != null && Consumes.Any())
            {
                writer.WritePropertyName("consumes");
                writer.WriteStartArray();
                foreach (string cons in Consumes)
                {
                    writer.WriteValue(cons);
                }
                writer.WriteEndArray();
            }

            if (Produces != null && Produces.Any())
            {
                writer.WritePropertyName("produces");
                writer.WriteStartArray();
                foreach (string prod in Produces)
                {
                    writer.WriteValue(prod);
                }
                writer.WriteEndArray();
            }

            if (Parameters != null && Parameters.Any())
            {
                writer.WritePropertyName("parameters");
                writer.WriteStartArray();
                foreach (ParameterBase p in Parameters)
                {
                    p.Serialize(writer);
                }
                writer.WriteEndArray();
            }

            if (Responses != null && Responses.Any())
            {
                writer.WritePropertyName("responses");
                writer.WriteStartObject();
                foreach (Response r in Responses)
                {
                    r.Serialize(writer);
                }
                writer.WriteEndObject();
            }

            if (Schemes != null && Schemes.Any())
            {
                writer.WritePropertyName("schemes");
                writer.WriteStartArray();
                foreach (string sch in Schemes)
                {
                    writer.WriteValue(sch);
                }
                writer.WriteEndArray();
            }
            if (Deprecated)
            {
                writer.WritePropertyName("deprecated");
                writer.WriteValue(Deprecated);
            }

            writer.WriteEndObject();
        }
 public static Produces <T> Consumes <T>(this Produces <T> producer, IProducerConsumerCollection <T> collection)
 {
     producer.Attach(new CollectionConsumer <T>(collection));
     return(producer);
 }
 public static Produces <T> Consumes <T>(this Produces <T> producer, IEnumerable <Consumes <T> > consumers)
 {
     producer.Attach(new CompositeConsumer <T>(consumers));
     return(producer);
 }
 public static Produces <T> Consumes <T>(this Produces <T> producer, Action <T> @delegate, Consumes <T> forwardTo)
 {
     producer.Attach(new DelegatingConsumer <T>(@delegate, forwardTo));
     return(producer);
 }
 public static Produces <T> Consumes <T>(this Produces <T> producer, Consumes <T> consumer)
 {
     producer.Attach(consumer);
     return(producer);
 }
Exemple #10
0
 private PipeAdapter(Consumes <TIn> consumer, Produces <TOut> producer)
 {
     _consumer = consumer;
     _producer = producer;
 }
 public void AttachTo <TDerived>(Produces <TDerived> producer) where TDerived : TBase
 {
     producer.AttachConsumer(_combiner.GetConsumer <TDerived>());
 }