Ejemplo n.º 1
0
        /// <summary>Отрисовывает объект в указанном контексте рисования</summary>
        /// <param name="dc">Контекст рисования</param>
        /// <param name="Projector">Индекс масштаба рисования</param>
        protected override void Draw(DrawingContext dc, IProjector <TX, TY> Projector)
        {
            Point p1 = Projector.Project(Segment.Start, Y1);
            Point p2 = Projector.Project(Segment.End, Y2);

            dc.DrawLine(_pen, p1, p2);
        }
Ejemplo n.º 2
0
        private FromTo ProjectDependency(WorkingGraph currentWorkingGraph, Dependency d, Dictionary <FromTo, Dependency> localCollector,
                                         Func <bool> onMissingPattern)
        {
            Item usingItem = _projector.Project(cachingGraph: currentWorkingGraph, item: d.UsingItem, left: true);
            Item usedItem  = _projector.Project(cachingGraph: currentWorkingGraph, item: d.UsedItem, left: false);

            if (usingItem == null)
            {
                if (onMissingPattern())
                {
                    Log.WriteWarning("No projection pattern found for " + d.UsingItem.AsString() + " - I ignore it");
                }
                return(null);
            }
            else if (usedItem == null)
            {
                if (onMissingPattern())
                {
                    Log.WriteWarning("No projection pattern found for " + d.UsedItem.AsString() + " - I ignore it");
                }
                return(null);
            }
            else if (usingItem.IsEmpty() || usedItem.IsEmpty())
            {
                // ignore this edge!
                return(null);
            }
            else
            {
                return(new FromTo(usingItem, usedItem).AggregateDependency(currentWorkingGraph, d, localCollector));
            }
        }
Ejemplo n.º 3
0
        public override void Draw(Graphics g, IProjector projector, CartesianToGdi GdiTrans)
        {
            PointF    start2d = projector.Project(Start);
            PointF    end2d   = projector.Project(End);
            PenPicker picker  = new PenPicker();
            Pen       pen     = picker.PickPen(Color, isDashedLine);

            g.DrawLine(pen, GdiTrans.ToGdi(start2d), GdiTrans.ToGdi(end2d));
        }
Ejemplo n.º 4
0
        public Result <FileDownloadResponse> Export(int typiconVersionId)
        {
            var found = _dbContext.Set <TypiconVersion>().FirstOrDefault(c => c.Id == typiconVersionId);

            if (found != null)
            {
                var projection = _projector.Project(found);

                if (projection.Success)
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(TypiconVersionProjection));

                    using (MemoryStream stream = new MemoryStream())
                    {
                        serializer.Serialize(stream, projection.Value);

                        var response = new FileDownloadResponse(stream.ToArray()
                                                                , "application/xml"
                                                                , GetFileName(projection.Value.Name.ToString(), found.VersionNumber));

                        return(Result.Ok(response));
                    }
                }
            }

            return(Result.Fail <FileDownloadResponse>($"Устав с Id={typiconVersionId} не был найден."));
        }
Ejemplo n.º 5
0
 public static TDestination Project <TSource, TDestination>(
     this TSource source, IProjector <TSource, TDestination> projector)
     where TSource : class
     where TDestination : class
 {
     return(projector.Project(source));
 }
Ejemplo n.º 6
0
        public TDestination Get <TDestination>(long id, IProjector <TEntity, TDestination> projector)
            where TDestination : class
        {
            var entity = Get(id);

            if (entity == null)
            {
                throw new Exception($"Entity {typeof(TEntity)} with identifier {id} not found");
            }

            return(projector.Project(entity));
        }
Ejemplo n.º 7
0
        private Item ProjectItem(WorkingGraph currentWorkingGraph, Dictionary <Item, Item> cache, Item item, bool left,
                                 int dependencyProjectCountForLogging)
        {
            Item result;

            if (!cache.TryGetValue(item, out result))
            {
                result = _projector.Project(cachingGraph: currentWorkingGraph, item: item, left: left, dependencyProjectCountForLogging: dependencyProjectCountForLogging);
                cache.Add(item, result);
            }
            return(result);
        }
Ejemplo n.º 8
0
        public async Task Consume(ConsumeContext <TEvent> context)
        {
            var text = $"Received event: {GetMessageDescription(context)}";

            _logger.Debug(text);
            try
            {
                _projector.Project(context.Message);
            }
            catch (Exception exception)
            {
                _logger.Error($"Error processing {GetMessageDescription(context)}");
                _logger.Error(exception);
                throw;
            }
        }
Ejemplo n.º 9
0
        public Result Import(byte[] file)
        {
            try
            {
                var xml = Encoding.UTF8.GetString(file);

                var projection = _serializer.Deserialize <TypiconVersionProjection>(xml);

                var entity = _projector.Project(projection);

                _dbContext.Set <TypiconEntity>().Add(entity.Value);

                int i = _dbContext.SaveChanges();

                return(Result.Ok());
            }
            catch (Exception ex)
            {
                return(Result.Fail(ex.Message));
            }
        }
Ejemplo n.º 10
0
 /// <summary>Отрисовывает объект в указанном контексте рисования</summary>
 /// <param name="dc">Контекст рисования</param>
 /// <param name="Projector">Индекс масштаба рисования</param>
 protected override void Draw(DrawingContext dc, IProjector <TX, TY> Projector)
 {
     dc.DrawLine(Pen,
                 new Point(-1000, Projector.Project(default(TX), Y).Y),
                 new Point(1000, Projector.Project(default(TX), Y).Y));
 }
 public override FSharpAsync <Unit> Invoke(Unit unitVar)
 {
     _ = builder;
     return(FSharpAsync.AwaitTask(_projectorHandler.Project(_stream, span)));
 }
Ejemplo n.º 12
0
        private DoubleVector2 Project(DoubleVector3 p)
        {
            var transformed = Vector3.Transform(new Vector3((float)p.X, (float)p.Y, (float)p.Z), Transform);

            return(projector.Project(new DoubleVector3(transformed.X, transformed.Y, transformed.Z)));
        }
 public static IQueryable <TDest> Project <TSource, TDest>(this IQueryable <TSource> source, IProjector projector)
 => projector.Project <TSource, TDest>(source);
Ejemplo n.º 14
0
 public virtual TResult Ask(TKey specification) =>
 Projector.Project <TEntity, TResult>(LinqProvider
                                      .GetQueryable <TEntity>()
                                      .Where(x => specification.Equals(x.Id)))
 .SingleOrDefault();
Ejemplo n.º 15
0
 public static IQueryable <T> Project <T>(this IQueryable queryable, IProjector projector)
 => projector.Project <T>(queryable);