public static dynamic GetTSObject(LinkAttributes dynObject)
 {
     if (dynObject is null)
     {
         return(null);
     }
     return(dynObject.teklaObject);
 }
        private void BuildNetwork(IEnqueueCommand <NetworkCommand> commandQueue)
        {
            var node1 = new NodeIdentifier();
            var node2 = new NodeIdentifier();
            var node3 = new NodeIdentifier();

            var linkAttributes = new LinkAttributes(2, 2f);

            commandQueue.Enqueue(BuildAddNodeCommand(node1, 0, 0));
            commandQueue.Enqueue(BuildAddNodeCommand(node2, 4, 4));
            commandQueue.Enqueue(BuildAddNodeCommand(node3, -4, -4));

            commandQueue.Enqueue(new NetworkCommand.LinkNodes(node1, PortDirection.Right, node2, PortDirection.Bottom, linkAttributes));
            commandQueue.Enqueue(new NetworkCommand.LinkNodes(node1, PortDirection.Bottom, node3, PortDirection.Right, linkAttributes));
        }
Beispiel #3
0
        private void BuildNetwork(IEnqueueCommand <NetworkCommand> commandQueue)
        {
            var gateway   = new NodeIdentifier();
            var router    = new NodeIdentifier();
            var consumer1 = new NodeIdentifier();
            var consumer2 = new NodeIdentifier();
            var consumer3 = new NodeIdentifier();

            var linkAttributes = new LinkAttributes(2, 2f);

            commandQueue.Enqueue(new NetworkCommand.AddGatewayNode(gateway, new NodePosition(0, 4), 50));
            commandQueue.Enqueue(new NetworkCommand.AddRouterNode(router, new NodePosition(0, 0), 5));
            commandQueue.Enqueue(new NetworkCommand.AddConsumerNode(consumer1, new NodePosition(4, -4), 5));
            commandQueue.Enqueue(new NetworkCommand.AddConsumerNode(consumer2, new NodePosition(-4, -4), 5));
            commandQueue.Enqueue(new NetworkCommand.AddConsumerNode(consumer3, new NodePosition(0, -4), 5));

            commandQueue.Enqueue(new NetworkCommand.LinkNodes(gateway, PortDirection.Bottom, router, PortDirection.Top, new LinkAttributes(50, .5f)));
            commandQueue.Enqueue(new NetworkCommand.LinkNodes(router, PortDirection.Right, consumer1, PortDirection.Left, linkAttributes));
            commandQueue.Enqueue(new NetworkCommand.LinkNodes(router, PortDirection.Left, consumer2, PortDirection.Right, linkAttributes));
            commandQueue.Enqueue(new NetworkCommand.LinkNodes(router, PortDirection.Bottom, consumer3, PortDirection.Top, linkAttributes));
        }
Beispiel #4
0
 public extern static ReactElement Link(LinkAttributes properties, params ReactElementOrText[] children);
        protected override void AddSpecifiedAttributes()
        {
            AddAttribute(PropertyHelper.GetDescription(() => RouteId), RouteId);

            if (RoutingMode != null)
            {
                AddAttribute(RoutingMode);
            }
            if (Waypoints != null)
            {
                foreach (var wp in Waypoints)
                {
                    AddAttribute(wp);
                }
            }
            if (JsonAttributes != null)
            {
                AddAttribute(JsonAttributes);
            }
            if (GeneralizationTolerances != null)
            {
                AddAttribute(GeneralizationTolerances);
            }

            AddAttribute(new JsonRepresentation(JsonAttribute.Include_TypeElement, JsonAttribute.UsePluralNamingForCollections, JsonAttribute.SupressJsonResponseObjectWrapper));

            if (RequestId != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => RequestId), RequestId);
            }
            if (Departure != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => Departure), ((DateTime)Departure).ToString("s"));
            }
            if (UnitSystem != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => UnitSystem), EnumHelper.GetDescription(UnitSystem));
            }
            if (ViewBounds != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => ViewBounds), ViewBounds.GetAttributeValue());
            }
            if (InstructionFormat != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => InstructionFormat), EnumHelper.GetDescription(InstructionFormat));
            }
            if (Language != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => Language), EnumHelper.GetDescription(Language));
            }
            if (JsonCallback != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => JsonCallback), JsonCallback);
            }
            if (Representation != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => Representation), EnumHelper.GetDescription(Representation));
            }
            if (RouteAttributes != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => RouteAttributes), string.Join(",", RouteAttributes.Select(ra => EnumHelper.GetDescription(ra))));
            }
            if (LegAttributes != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => LegAttributes), string.Join(",", LegAttributes.Select(la => EnumHelper.GetDescription(la))));
            }
            if (ManeuverAttributes != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => ManeuverAttributes), string.Join(",", ManeuverAttributes.Select(ma => EnumHelper.GetDescription(ma))));
            }
            if (LinkAttributes != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => LinkAttributes), string.Join(",", LinkAttributes.Select(la => EnumHelper.GetDescription(la))));
            }
            if (ReturnElevation != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => ReturnElevation), ReturnElevation.ToString().ToLower());
            }
        }
        protected override void AddSpecifiedAttributes()
        {
            //Add IRequestAttribute types
            AddAttribute(RoutingMode);
            foreach (var wp in Waypoints)
            {
                AddAttribute(wp);
            }
            if (Resolution != null)
            {
                AddAttribute(Resolution);
            }
            if (JsonAttributes != null)
            {
                AddAttribute(JsonAttributes);
            }
            if (GeneralizationTolerances != null)
            {
                AddAttribute(GeneralizationTolerances);
            }
            if (VehicleType != null)
            {
                AddAttribute(VehicleType);
            }
            if (ConsumptionModel != null)
            {
                AddAttribute(ConsumptionModel);
            }
            if (CustomConsumptionDetails != null)
            {
                AddAttribute(CustomConsumptionDetails);
            }

            AddAttribute(new JsonRepresentation(JsonAttribute.Include_TypeElement, JsonAttribute.UsePluralNamingForCollections, JsonAttribute.SupressJsonResponseObjectWrapper));

            //Other parameters
            if (RequestId != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => RequestId), RequestId);
            }
            if (AvoidAreas != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => AvoidAreas), string.Join("!", AvoidAreas.Select(aa => aa.GetAttributeValue()).ToArray()));
            }
            if (AvoidLinks != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => AvoidLinks), string.Join(",", AvoidLinks.Select(al => al.GetAttributeValue()).ToArray()));
            }
            if (AvoidSeasonalClosures != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => AvoidSeasonalClosures), AvoidSeasonalClosures.ToString().ToLower());
            }
            if (AvoidTurns != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => AvoidTurns), string.Join(",", AvoidTurns.Select(at => EnumHelper.GetDescription(at))));
            }
            if (ExcludeZones != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => ExcludeZones), string.Join(",", ExcludeZones));
            }
            if (ExcludeCountries != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => ExcludeCountries), string.Join(",", ExcludeCountries));
            }
            if (Departure != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => Departure), ((DateTime)Departure).ToString("s"));
            }
            if (Arrival != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => Arrival), ((DateTime)Arrival).ToString("s"));
            }
            if (Alternatives != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => Alternatives), Alternatives.ToString());
            }
            if (UnitSystem != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => UnitSystem), EnumHelper.GetDescription(UnitSystem));
            }
            if (ViewBounds != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => ViewBounds), ViewBounds.GetAttributeValue());
            }
            if (InstructionFormat != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => InstructionFormat), EnumHelper.GetDescription(InstructionFormat));
            }
            if (Language != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => Language), EnumHelper.GetDescription(Language));
            }
            if (JsonCallback != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => JsonCallback), JsonCallback);
            }
            if (Representation != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => Representation), EnumHelper.GetDescription(Representation));
            }
            if (RouteAttributes != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => RouteAttributes), string.Join(",", RouteAttributes.Select(ra => EnumHelper.GetDescription(ra))));
            }
            if (LegAttributes != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => LegAttributes), string.Join(",", LegAttributes.Select(la => EnumHelper.GetDescription(la))));
            }
            if (ManeuverAttributes != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => ManeuverAttributes), string.Join(",", ManeuverAttributes.Select(ma => EnumHelper.GetDescription(ma))));
            }
            if (LinkAttributes != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => LinkAttributes), string.Join(",", LinkAttributes.Select(la => EnumHelper.GetDescription(la))));
            }
            if (LineAttributes != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => LineAttributes), string.Join(",", LineAttributes.Select(la => EnumHelper.GetDescription(la))));
            }

            if (MaxNumberOfChanges != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => MaxNumberOfChanges), MaxNumberOfChanges.ToString());
            }
            if (AvoidTransportTypes != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => AvoidTransportTypes), string.Join(",", AvoidTransportTypes.Select(tt => EnumHelper.GetDescription(tt))));
            }

            if (WalkTimeMultiplier != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => WalkTimeMultiplier), WalkTimeMultiplier.Value.ToString(HereAPISession.Culture));
            }
            if (WalkSpeed != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => WalkSpeed), WalkSpeed.Value.ToString(HereAPISession.Culture));
            }
            if (WalkRadius != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => WalkRadius), WalkRadius.Value.ToString(HereAPISession.Culture));
            }
            if (CombineChange != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => CombineChange), CombineChange.ToString().ToLower());
            }
            if (TruckType != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => TruckType), EnumHelper.GetDescription(TruckType));
            }
            if (TrailersCount != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => TrailersCount), TrailersCount.ToString());
            }

            if (ShippedHazardousGoods != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => ShippedHazardousGoods), string.Join(",", ShippedHazardousGoods.Select(sg => EnumHelper.GetDescription(sg))));
            }

            if (LimitedWeight != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => LimitedWeight), LimitedWeight.Value.ToString(HereAPISession.Culture));
            }
            if (WeightPerAxle != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => WeightPerAxle), WeightPerAxle.Value.ToString(HereAPISession.Culture));
            }
            if (Height != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => Height), Height.Value.ToString(HereAPISession.Culture));
            }
            if (Width != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => Width), Width.Value.ToString(HereAPISession.Culture));
            }
            if (Length != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => Length), Length.Value.ToString(HereAPISession.Culture));
            }

            if (TunnelCategory != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => TunnelCategory), EnumHelper.GetDescription(TunnelCategory));
            }
            if (TruckRestrictionPenalty != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => TruckRestrictionPenalty), EnumHelper.GetDescription(TruckRestrictionPenalty));
            }

            if (ReturnElevation != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => ReturnElevation), ReturnElevation.ToString().ToLower());
            }
        }
Beispiel #7
0
        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            if (output.TagMode == TagMode.SelfClosing && AspFor == null)
            {
                throw new InvalidOperationException(
                          $"Content is required when the '{AspForAttributeName}' attribute is not specified.");
            }

            var errorSummaryContext = context.GetContextItem <ErrorSummaryContext>();

            var childContent = await output.GetChildContentAsync();

            IHtmlContent itemContent;

            if (output.TagMode == TagMode.StartTagAndEndTag)
            {
                itemContent = childContent.Snapshot();
            }
            else
            {
                Debug.Assert(AspFor != null);

                var validationMessage = _modelHelper.GetValidationMessage(
                    ViewContext,
                    AspFor !.ModelExplorer,
                    AspFor.Name);

                if (validationMessage == null)
                {
                    return;
                }

                itemContent = new HtmlString(validationMessage);
            }

            string?resolvedHref = null;

            if (output.Attributes.TryGetAttribute("href", out var hrefAttribute))
            {
                resolvedHref = hrefAttribute.Value.ToString();
                output.Attributes.Remove(hrefAttribute);
            }
            else if (AspFor != null)
            {
                var errorFieldId = TagBuilder.CreateSanitizedId(
                    _modelHelper.GetFullHtmlFieldName(ViewContext, AspFor !.Name),
                    Constants.IdAttributeDotReplacement);

                // Date inputs are special; they don't have an element with ID which exactly corresponds to the name derived above;
                // the IDs are suffixed with .Day .Month and .Year for each of the components.
                // We don't have a perfect way to know whether this error is for a date input.
                // The best we can do is look at the type for the ModelExpression and see if it looks like a date type.
                // If it does look like a date type we also consult DateInputParseErrorsProvider to know which input to link to
                // (e.g. if .Day is valid but .Month and .Year are not, we link to .Month as the first input with errors.)
                // (Note we cannot rely on DateInputParseErrorsProvider for identifying date inputs since we could have errors
                // that didn't come from model binding so TryGetErrorsForModel will return false.)

                if (IsModelExpressionForDate())
                {
                    var dateInputErrorComponents = DateInputErrorComponents.All;

                    if (_dateInputParseErrorsProvider.TryGetErrorsForModel(AspFor.Name, out var dateInputParseErrors))
                    {
                        dateInputErrorComponents = dateInputParseErrors.GetErrorComponents();
                    }

                    Debug.Assert(dateInputErrorComponents != DateInputErrorComponents.None);

                    if (dateInputErrorComponents.HasFlag(DateInputErrorComponents.Day))
                    {
                        errorFieldId += ".Day";
                    }
                    else if (dateInputErrorComponents.HasFlag(DateInputErrorComponents.Month))
                    {
                        errorFieldId += ".Month";
                    }
                    else
                    {
                        errorFieldId += ".Year";
                    }
                }

                resolvedHref = $"#{errorFieldId}";
            }

            errorSummaryContext.AddItem(new ErrorSummaryItem()
            {
                Content        = itemContent,
                Attributes     = output.Attributes.ToAttributeDictionary(),
                Href           = resolvedHref,
                LinkAttributes = LinkAttributes.ToAttributeDictionary()
            });

            output.SuppressOutput();

            bool IsModelExpressionForDate()
            {
                Debug.Assert(AspFor != null);

                var modelType = AspFor !.Metadata.ModelType;

                return(_options.DateInputModelConverters.Any(c => c.CanConvertModelType(modelType)));
            }
        }