Пример #1
0
        private async void LoadDetails(HtmlNode nodo, List <Book> books, MotorConfig config)
        {
            Book book = new Book
            {
                Store    = config.Pagina,
                Name     = HttpUtility.HtmlDecode(ObtenerTexto(config.RootNombre, nodo)),
                Price    = HttpUtility.HtmlDecode(ClearPrice(ObtenerTexto(config.RootPrice, nodo))),
                Url      = ObtenerTexto(config.RootUrlArticulo, nodo),
                ImageUrl = ObtenerTexto(config.RootImageUrl, nodo)
            };

            if (book.Url != null)
            {
                await Task.Run(() =>
                {
                    HtmlWeb htmlWeb         = new HtmlWeb();
                    HtmlDocument doc        = htmlWeb.Load(book.Url);
                    List <HtmlNode> infoTec = new List <HtmlNode>();
                    book.Description        = HttpUtility.HtmlDecode(ObtenerTexto(config.RootDescripcion, doc.DocumentNode));

                    book.Author    = HttpUtility.HtmlDecode(ObtenerTexto(config.RootAutor, doc.DocumentNode));
                    book.ISBN      = HttpUtility.HtmlDecode(ObtenerTexto(config.RootISBN, doc.DocumentNode));
                    book.Language  = HttpUtility.HtmlDecode(ObtenerTexto(config.RootLenguaje, doc.DocumentNode));
                    book.Editorial = HttpUtility.HtmlDecode(ObtenerTexto(config.RootEditorial, doc.DocumentNode));

                    books.Add(book);
                });
            }
        }
Пример #2
0
    private void MotorConfigUpdated(MotorConfig motorConfig)
    {
        SimMotor simMotor;

        if (!simMotorsByHandle.TryGetValue(motorConfig.Handle, out simMotor))
        {
            simMotor = new SimMotor()
            {
                Id     = motorConfig.Id,
                Handle = motorConfig.Handle
            };
            simMotors.Add(simMotor);
            simMotorsByHandle.Add(simMotor.Handle, simMotor);
            simMotorsById.Add(simMotor.Id, simMotor);
        }

        simMotor.Config = motorConfig;

        if (motorConfig.FollowingId != 0)
        {
            SimMotor following;
            if (simMotorsById.TryGetValue(motorConfig.FollowingId, out following))
            {
                simMotor.Following = following;
            }
        }
        else
        {
            simMotor.Following = null;
        }
    }
Пример #3
0
    /// <summary>
    /// When this component gets a motor update, if it's the motor assigned
    /// to this component, update the SimMotor object
    /// </summary>
    /// <param name="motorConfig"></param>
    private void MotorConfigUpdated(MotorConfig motorConfig)
    {
        if (motorId != motorConfig.Id)
        {
            // this motor isn't assigned to us, ignore the update
            return;
        }

        simMotor = motorStore.CreateOrUpdateMotor(motorConfig);
    }
Пример #4
0
    public SimMotor CreateOrUpdateMotor(MotorConfig motorConfig)
    {
        SimMotor simMotor;

        if (!simMotorsByHandle.TryGetValue(motorConfig.Handle, out simMotor))
        {
            simMotor = new SimMotor()
            {
                Id     = motorConfig.Id,
                Handle = motorConfig.Handle
            };
            // initialize the MotorOutput
            simMotors.Add(simMotor);
            simMotorsByHandle.Add(simMotor.Handle, simMotor);
            simMotorsById.Add(simMotor.Id, simMotor);
            Debug.Log("Created motor: " + simMotor.Id);
        }

        simMotor.Config = motorConfig;

        if (motorConfig.FollowingId != 0 && simMotor.Following == null)
        {
            SimMotor following;
            if (simMotorsById.TryGetValue(motorConfig.FollowingId, out following))
            {
                simMotor.Following = following;
                Debug.Log("motor " + motorConfig + " following " + following.Config);
            }
        }
        else
        {
            simMotor.Following = null;
        }

        return(simMotor);
    }
Пример #5
0
 protected virtual void OnEnable()
 {
     config = (MotorConfig)target;
 }
Пример #6
0
 public override Task <Empty> UpdateMotor(MotorConfig request, ServerCallContext context)
 {
     Debug.Log("Updating motor " + request.Id + " " + request.ToString());
     EventManager.PublishMotorConfigUpdateEvent(request);
     return(Task.FromResult(emptyResponse));
 }
Пример #7
0
 void OnEnable()
 {
     m_MotorConfig = (MotorConfig)target;
 }
Пример #8
0
 public static void PublishMotorConfigUpdateEvent(MotorConfig motorConfig)
 {
     MotorConfigUpdated?.Invoke(motorConfig);
 }