public ExpressionTree BuildExpressionTree(List<AssignStatement> expressions, string calcForWire)
        {
            Dictionary<string, AssignStatement> variableMapping = expressions.ToDictionary(x => x.Variable.Identifier, y => y);
            Dictionary<AssignStatement, IEnumerable<VariableExpression>> dependencyMapping = expressions.ToDictionary(x => x, y => y.Value.GetDependencies());

            return CreateFor(calcForWire, variableMapping, dependencyMapping, new Dictionary<string, ExpressionTree>());
        }
Example #2
0
        public ControlFlowGraph2(MethodBody body)
        {
            _body = body;
            _basicBlocks = new ControlFlowGraph(body).ToList();
            _entries = _basicBlocks.ToDictionary(b => b.Entry, b => b);
            _exits = _basicBlocks.ToDictionary(b => b.Exit, b => b);
            _entryInstructions = _basicBlocks.Select(b => b.Entry).ToList();

            IncludeExceptionHandlers(body);
        }
Example #3
0
        public XMLOpcodeLookup(XDocument document)
        {
            XContainer root = document.Element("BlamScript");

            // Script execution types
            var scriptTypes = from element in root.Element("scriptTypes").Descendants("type")
                              select new
                              {
                                  Opcode = (ushort)XMLUtil.GetNumericAttribute(element, "opcode"),
                                  Name = XMLUtil.GetStringAttribute(element, "name")
                              };
            _scriptTypeNameLookup = scriptTypes.ToDictionary(t => t.Opcode, t => t.Name);
            _scriptTypeOpcodeLookup = scriptTypes.ToDictionary(t => t.Name, t => t.Opcode);

            // Value types
            var valueTypes = new List<ScriptValueType>();
            foreach (var element in root.Element("valueTypes").Descendants("type"))
            {
                var name = XMLUtil.GetStringAttribute(element, "name");
                var opcode = (ushort)XMLUtil.GetNumericAttribute(element, "opcode");
                var size = XMLUtil.GetNumericAttribute(element, "size");
                var quoted = XMLUtil.GetBoolAttribute(element, "quoted", false);
                var tag = XMLUtil.GetStringAttribute(element, "tag", null);

                valueTypes.Add(new ScriptValueType(name, opcode, size, quoted, tag));
            }
            _typeLookupByOpcode = valueTypes.ToDictionary(t => t.Opcode);
            _typeLookupByName = valueTypes.ToDictionary(t => t.Name);

            // Functions
            foreach (var element in root.Element("functions").Descendants("function"))
            {
                var name = XMLUtil.GetStringAttribute(element, "name");
                if (name == "")
                    continue;

                var opcode = (ushort)XMLUtil.GetNumericAttribute(element, "opcode");
                var returnType = XMLUtil.GetStringAttribute(element, "returnType", "void");
                var flags = (uint)XMLUtil.GetNumericAttribute(element, "flags", 0);
                var parameterTypes = element.Descendants("arg").Select(e => XMLUtil.GetStringAttribute(e, "type")).ToArray();

                var info = new ScriptFunctionInfo(name, opcode, returnType, flags, parameterTypes);
                List<ScriptFunctionInfo> functions;
                if (!_functionLookupByName.TryGetValue(name, out functions))
                {
                    functions = new List<ScriptFunctionInfo>();
                    _functionLookupByName[name] = functions;
                }
                functions.Add(info);
                _functionLookupByOpcode[opcode] = info;
            }
        }
Example #4
0
        public DrinksContainer LoadDrinks(string source)
        {
            using (StringReader stringReader = new StringReader(source))
            {
                List<Drink> trainingSet = new List<Drink>();

                string line = stringReader.ReadLine();
                string[] columnNames = line.Split(';').Skip(COLUMNS_TO_SKIP).ToArray();

                while ((line = stringReader.ReadLine()) != null)
                {
                    string[] values = line.Split(';');
                    int id = int.Parse(values[0]);
                    string drinkName = values[1],
                           url = values[2],
                           imageUrl = values[3];

                    double[] trainingRow = new double[values.Length - COLUMNS_TO_SKIP];

                    for (int i = 0; i < trainingRow.Length - 1; i++)
                    {
                        trainingRow[i] = double.Parse(values[i + COLUMNS_TO_SKIP], System.Globalization.CultureInfo.InvariantCulture);
                    }

                    trainingSet.Add(new Drink(id, drinkName, url, trainingRow, imageUrl));
                }

                return new DrinksContainer(trainingSet.ToDictionary(r => r.ID, r => r), columnNames);
            }
        }
 public AppenderConfigProperties(List<pt.sapo.gis.trace.configuration.Appender.Property> properties)
 {
     if (properties != null)
     {
         this.properties = properties.ToDictionary(p => p.Name, p => p.Content);
     }
 }
        private void ActualizarPantalla(List<Encomienda> encomienda)
        {
            var diccionarioDeEncimiendas = new Dictionary<int, Encomienda>();

            #region Cargar el diccionario a mostrar en la grilla

            if (encomienda == null)
            {

            }
            else
            {
                //El datasource se carga con la lista de pasajes recibida por parámetro
                diccionarioDeEncimiendas = encomienda.ToDictionary(e => e.ID, e => e);
            }

            //Muestra en la grilla el contenido de los pasajes que se encuentran cargados en el diccionario
            var bind = diccionarioDeEncimiendas.Values.Select(e => new
            {
                Codigo_Pasaje = e.Codigo_Encomienda,
                Numero_Butaca = e.KG,
                Precio = e.Precio
            });

            #endregion

            DgvEncomiendas.DataSource = bind.ToList();
            AgregarBotonesDeColumnas();

            DgvEncomiendas.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
        }
Example #7
0
        public bool Refresh(ProviderMember aMember, List<ProviderCategory> categoryList)
        {
            CategoryList = new List<SelectList>();
            AlternateCategoryMapList = new List<AlternateCategoryMapVM>();

            List<KeyValuePair<long, string>> ddList = new List<KeyValuePair<long, string>>();
            ddList.Add(_nullCategory);
            ddList.AddRange(categoryList.ToDictionary(aCategory => aCategory.Id.Value, aCategory => aCategory.Title));

            foreach (ProviderAlternateCategoryId altCategory in aMember.AlternateCategoryList)
            {
                if(!string.IsNullOrEmpty(altCategory.DisplayName))
                {
                    long selectedCatId = altCategory.CategoryId ?? -1;
                    AlternateCategoryMapList.Add(new AlternateCategoryMapVM
                    {
                        AlternateTitle = altCategory.DisplayName,
                        AlternateId = altCategory.AlternateId,
                        MapId = selectedCatId
                    });

                    CategoryList.Add(new SelectList(ddList, "key", "value", selectedCatId));
                }
            }
            return true;
        }
 private void GetInstanceStates()
 {
     var loadBalancer = command.Parameters[0];
     var elb = new ELB();
     this.states = elb.InstanceState(loadBalancer);
     this.stateMap = states.ToDictionary(k => k.InstanceId, v => v.State);
 }
        private static void SetExecuted(List<MigrationInfo> migrations)
        {
            MigrationLogic.EnsureMigrationTable<SqlMigrationEntity>();

            var first = migrations.FirstOrDefault();

            var executedMigrations = Database.Query<SqlMigrationEntity>().Select(m => m.VersionNumber).OrderBy().ToList().Where(d => first == null || first.Version.CompareTo(d) <= 0).ToList();

            var dic = migrations.ToDictionary(a => a.Version, "Migrations in folder");

            foreach (var ver in executedMigrations)
            {
                var m = dic.TryGetC(ver);
                if (m != null)
                    m.IsExecuted = true;
                else
                    migrations.Add(new MigrationInfo
                    {
                        FileName = null,
                        Comment = ">> In Database Only <<",
                        IsExecuted = true,
                        Version = ver
                    });

            }

            migrations.Sort(a => a.Version);
        }
Example #10
0
 public CountryCodeHelper(List<Country> countries)
 {
     _countryCodes = countries.ToDictionary(x => x.Name, x => x.CountryCode);
     _currencyCodes = countries
         .Distinct((x, y) => x.CountryCode == y.CountryCode)
         .ToDictionary(x => x.CountryCode, x => x.CurrencyCode);
 }
Example #11
0
        private void ActualizarPantalla(List<Pasaje> pasajes)
        {
            var diccionarioDePasajes = new Dictionary<int, Pasaje>();

            #region Cargar el diccionario a mostrar en la grilla

            if (pasajes == null)
            {

            }
            else
            {
                //El datasource se carga con la lista de pasajes recibida por parámetro
                diccionarioDePasajes = pasajes.ToDictionary(p => p.ID, p => p);
            }

            //Muestra en la grilla el contenido de los pasajes que se encuentran cargados en el diccionario
            var bind = diccionarioDePasajes.Values.Select(p => new
            {
                Codigo_Pasaje = p.Codigo_Pasaje,
                Pasajero = p.ID_Cliente,
                Numero_Butaca = p.ID_Butaca,
                Precio = p.Precio
            });

            #endregion

            DgvPasaje.DataSource = bind.ToList();
            AgregarBotonesDeColumnas();

            DgvPasaje.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
        }
Example #12
0
        public ActionResult Index()
        {
            var currentUser = this.userService.GetCurrentUser();

            var sharedCourses = this.storage.GetCourses(currentUser.Id);
            var courses = this.storage.GetCourses(User.Identity.Name);
            var all = sharedCourses.Union(courses);

            var owners = all.Select(i => i.Owner).Distinct().ToList();

            var users = new List<User>();
            foreach (var owner in owners)
            {
                var copy = owner;
                users.AddRange(this.userService.GetUsers(i => i.Username == copy));
            }
            var dic = users.ToDictionary(i => i.Username, j => j.Username);


            var viewCourses = all.Select(i => new ViewCourseModel
            {
                Id = i.Id,
                Name = i.Name,
                Created = i.Created,
                Updated = i.Updated,
                Locked = i.Locked ?? false,
                Shared = i.Owner != currentUser.Username,
                OwnerName = dic.ContainsKey(i.Owner) ? dic[i.Owner] : i.Owner,
                UpdatedByName = i.UpdatedBy
            });
            return View(viewCourses.OrderByDescending(i => i.Updated).AsEnumerable());
        }
Example #13
0
        public Rulebook(List<IRule> rules, List<IModifier> modifiers, Type interactionType)
        {
            this.interactionType = interactionType;

            foreach (IRule rule in rules)
            {
                string interaction = rule.Interaction;

                if (!this.rules.ContainsKey(interaction)) 	this.rules.Add(interaction, new Section(rule));
                else 										this.rules[interaction].Add(rule);
            }

            this.Modifiers = modifiers.ToDictionary<IModifier, string>(i => i.Target);

            // Merge sections that descend from other sections. This means that the hierarchy does not
            // need to be negotiated when looking up rules in a section. For example, if you have some
            // generic "Move" rules and then you have a specific "Move.Run" rule section, the "Move.Run"
            // will have all of the rules in "Move" added to it. Since rules are selected in list order
            // the specific "Move.Run" rules will be checked first before moving on to the generic "Move" rules.
            foreach (KeyValuePair<string, Section> kvp in this.rules)
            {
                string interaction 	= kvp.Key;
                int trim 			= interaction.LastIndexOf('.');

                if (trim > 0)
                {
                    interaction = interaction.Remove(trim);
                    if (this.rules.ContainsKey(interaction)) kvp.Value.Merge(this.rules[interaction]);
                }
            }
        }
Example #14
0
 public IEnumerable<MouseDragAction> GetDrawInstructions(List<ColorSpot> colorPalette, IDictionary<string, string> options = null, IBrushChanger brushChanger = null)
 {
     if (!colorPalette.Any())
     {
         throw new ArgumentException("I need some colors. Give me some colors. Thanks!");
     }
     var output = new List<MouseDragAction>();
     var colorPixels = colorPalette.ToDictionary(colorSpot => colorSpot, colorSpot => new List<Point>());
     using (var bitmap = new Bitmap(_bitmapPath))
     {
         bitmap.LoopThroughPixels((point, color) =>
             {
                 var selectedColor = colorPalette.OrderBy(c => c.Color.DifferenceTo(color)).FirstOrDefault();
                 if (selectedColor == null || !colorPixels.ContainsKey(selectedColor) ||
                     selectedColor.Color.DifferenceTo(Color.White) == 0)
                 {
                     return;
                 }
                 colorPixels[selectedColor].Add(point);
             });
     }
     foreach (var colorPixel in colorPixels.Where(colorPixel => colorPixel.Value.Any()))
     {
         output.Add(new MouseDragAction(new List<Point> { colorPixel.Key.Point }, true, colorPixel.Key.Color));
         var actions = colorPixel.Value.Select(point => new MouseDragAction(new List<Point> { point })).ToList();
         if (options.GetBoolValueOrDefault("MixPoints", false))
         {
             actions = actions.Shuffle().ToList();
         }
         output.AddRange(actions);
     }
     return output.ToArray();
 }
Example #15
0
        /// <summary>
        /// NEED TO REFACTOR THIS TO A REPORT
        /// </summary>
        /// <param name="interventionTypeId"></param>
        /// <param name="year"></param>
        /// <param name="diseaseId"></param>
        /// <param name="customAggRule"></param>
        /// <returns></returns>
        public List<AdminLevelIndicators> GetDistrictIndicatorTrees(int interventionTypeId, int year, int diseaseId, Func<AggregateIndicator, object, object> customAggRule, int reportingLevel)
        {
            List<AdminLevelIndicators> list = new List<AdminLevelIndicators>();
            Dictionary<int, AdminLevelIndicators> dic = new Dictionary<int, AdminLevelIndicators>();
            OleDbConnection connection = new OleDbConnection(DatabaseData.Instance.AccessConnectionString);
            using (connection)
            {
                connection.Open();
                OleDbCommand command = new OleDbCommand();
                list = GetAdminLevels(command, connection, false);
                dic = list.ToDictionary(n => n.Id, n => n);
                AddIntvIndicators(interventionTypeId, year, dic, command, connection, customAggRule);
                AddSurveyIndicators(diseaseId, year, dic, command, connection, customAggRule);
                AddDistroIndicators(diseaseId, year, dic, command, connection, customAggRule);
            }

            var rootNodes = new List<AdminLevelIndicators>();
            foreach (var node in list)
            {
                if (node.ParentId.HasValue && node.ParentId.Value > 0)
                {
                    AdminLevelIndicators parent = dic[node.ParentId.Value];
                    node.Parent = parent;
                    parent.Children.Add(node);
                }
                else
                {
                    rootNodes.Add(node);
                }
            }
            return list.Where(a => a.LevelNumber == reportingLevel).ToList();
        }
Example #16
0
        public static void FillNodePropertyValues(
            this Tree<ItemModel> tree,
            List<UnitPropertyModel> propertyModels,
            IEnumerable<UnitPropertyValueModel> propertyValues)
        {
            var propDict = propertyModels.GroupBy(p => p.UnitId).ToDictionary(p => p.Key, p => p.ToList());
            var propNameDict = propertyModels.ToDictionary(p => p.Id, p => p.Name);
            var propValsDict = propertyValues
                .GroupBy(p => p.UnitId)
                .ToDictionary(p => p.Key,
                    p => p.GroupBy(g => g.PropertyId).ToDictionary(g => propNameDict[g.Key], g => g.FirstOrDefault()));
            foreach (var node in tree.FlatNodes)
            {
                if (!propDict.ContainsKey(node.Value.Id))
                    continue;
                var nodeProps = propDict[node.Value.Id];
                foreach (var prop in nodeProps)
                {
                    var clone = prop.Clone();
                    if (!node.Children.Any())
                        clone.PropertyValue = propValsDict[node.Value.Id][clone.Name];
                    node.Value.Properties.Add(clone.Name, clone);
                }
            }

            foreach (var root in tree.Roots)
            {
                SetNodeProps(root, root.Value.Properties, propValsDict);
            }
        }
Example #17
0
        public void Read(IConfiguration configuration)
        {
            var value = configuration["RetryCount"];
            if (!string.IsNullOrEmpty(value))
            {
                RetryCount = int.Parse(value);
            }
			value = configuration["DefaultAdBlock"];
            if (!string.IsNullOrEmpty(value))
            {
                DefaultAdBlock = value;
            }

            var items = new List<AdBlock>();
            foreach (var subConfig in configuration.GetSection("AdBlock").GetChildren())
            {
                var item = new AdBlock { Name = subConfig.Key };
				value = subConfig["Origin"];
                if (!string.IsNullOrEmpty(value))
                {
                    item.Origin = value;
                }
				value = subConfig["ProductCode"];
                if (!string.IsNullOrEmpty(value))
                {
                    item.ProductCode = value;
                }
                items.Add(item);
            }
            AdBlocks = items.ToDictionary(
                item => item.Name, 
                item => item,
                StringComparer.OrdinalIgnoreCase);
        }
Example #18
0
        public PluginEntity GetPluginEntity(Assembly _Assembly, string _Url, out List<Function> _Functions)
        {
            //this.Functions.ForEach(x => { x.Url = _Url; x.Assembly = _Assembly; });  // x 是临时的~~ 修改不了

            //for (int i = 0; i < this.Functions.Count; i++)   // 这样写赋值不上
            //{

            //    //Functions[i].Url = _Url;
            //    this.Functions[i].Url = "asdfasdf";
            //    this.Functions[i].Assembly = _Assembly;
            //}

            _Functions = Functions.Select(x => new Function()
                {
                    Action = x.Action,
                    Assembly = _Assembly,
                    Controller = x.Controller,
                    NameSpace = x.NameSpace,
                    ControllerType = x.ControllerType,
                    Name = x.Name,
                    Url = _Url
                }).ToList();

            return new PluginEntity(
                        Name: this.Name,
                        Author: this.Author,
                        Description: this.Description,
                        Functions: _Functions.ToDictionary(x => x.Name), // 通过Function对象的Name属性作为key
                        Assembly: _Assembly
                       );
        }
Example #19
0
        static Utils()
        {
            var oneByte = new List<OpCode>();
            var twoByte = new List<OpCode>();

            foreach (var field in typeof(OpCodes).GetFields(BindingFlags.Public | BindingFlags.Static))
            {
                var op = (OpCode)field.GetValue(null);

                if (op.Size == 1)
                {
                    oneByte.Add(op);
                    continue;
                }

                if (op.Size == 2)
                {
                    twoByte.Add(op);
                    continue;
                }

                throw new Exception("Unexpected op size for " + op);
            }

            OneByteOps = oneByte.ToDictionary(d => (int)d.Value, d => d);
            TwoByteOps = twoByte.ToDictionary(d => (int)(d.Value & 0xFF), d => d);
        }
Example #20
0
        public void Read(IConfiguration configuration)
        {
            string value;
            if (configuration.TryGet("RetryCount", out value))
            {
                RetryCount = int.Parse(value);
            }
            if (configuration.TryGet("DefaultAdBlock", out value))
            {
                DefaultAdBlock = value;
            }

            var items = new List<AdBlock>();
            foreach (var subConfig in configuration.GetSubKeys("AdBlock"))
            {
                var item = new AdBlock { Name = subConfig.Key };
                if (subConfig.Value.TryGet("Origin", out value))
                {
                    item.Origin = value;
                }
                if (subConfig.Value.TryGet("ProductCode", out value))
                {
                    item.ProductCode = value;
                }
                items.Add(item);
            }
            AdBlocks = items.ToDictionary(
                item => item.Name,
                item => item,
                StringComparer.OrdinalIgnoreCase);
        }
Example #21
0
        public void Weave()
        {
            Type aspectAttributes = null;
            var fieldBuilders = new List<FieldBuilder>();
            var typeBuilder = typeof(object).DefineType("Aspects".ToUniqueName(), attributes: TypeAttributes.Sealed | TypeAttributes.Abstract);
            var cctor = typeBuilder.DefineConstructor(MethodAttributes.Private | MethodAttributes.Static | MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName, CallingConventions.Standard, Type.EmptyTypes).GetILGenerator();

            aspectTypes.ForEach((aspect, i) => {
                var fieldBuilder = typeBuilder.DefineField("Aspect_{0}".Fmt(i).ToUniqueName(), aspect, FieldAttributes.Private | FieldAttributes.FamANDAssem | FieldAttributes.Static);
                var ctor = fieldBuilder.FieldType.GetConstructor(Type.EmptyTypes);

                if (ctor.IsNull()) {
                    throw new AspectWeavingException(Resources.AspectsDefaultCtorHasNotBeenFound.Fmt(fieldBuilder.FieldType.FullName));
                }

                cctor.Emit(OpCodes.Newobj, ctor);
                cctor.Emit(OpCodes.Stsfld, fieldBuilder);
                fieldBuilders.Add(fieldBuilder);
            });

            cctor.Emit(OpCodes.Ret);
            aspectAttributes = typeBuilder.CreateType();

            aspects = fieldBuilders.ToDictionary(builder => builder.FieldType, builder => {
                return aspectAttributes.GetField(builder.Name, BindingFlags.Static | BindingFlags.NonPublic);
            });
        }
 public AdsBlock(int blockId, List<string> baseRefsList)
 {
     BlockPositionStats = new BlockPositionStats(blockId);
     _blockId = blockId;
     _baseRefsList = baseRefsList;
     _targetSamplesForBGroup = TargetSamplesPerAd * baseRefsList.Count;
     _refPerfomanceStats = _baseRefsList.ToDictionary(x => x, x => new AdStats());
 }
Example #23
0
        public void Compile(string src)
        {
            // todo1[ak] check args
            string[] lines = src.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);

            _routines = this.CompileLines(lines);
            _routinesByName = _routines.ToDictionary(r => r.Name, r => r);
        }
Example #24
0
        private static Dictionary<string, string> ReadTranslationData()
        {
            List<UserData> userStringList = new List<UserData>();

            XmlSerializer serializer = new XmlSerializer(userStringList.GetType());
            userStringList = (List<UserData>)serializer.Deserialize(XmlReader.Create(SettingsPath));
            return userStringList.ToDictionary(n => n.Tag, n => n.Text.Replace("__BREAK__", Environment.NewLine));
        }
Example #25
0
        private static Dictionary<PrimeUsbDataType, PrimeUsbDataHeader> GetHeaders()
        {
            var t = new List<PrimeUsbDataHeader>(new[]
            {new PrimeUsbDataHeader {Header = new byte[]{0x00, 0x00, 0xf7, 0x01}, Type = PrimeUsbDataType.File},
            new PrimeUsbDataHeader {Header = new byte[]{0x00, 0x00, 0xf2, 0x01}, Type = PrimeUsbDataType.Message}});

            return t.ToDictionary(header => header.Type);
        }
 public void ProcessModelActivities(List<IActivitySchedule> activities)
 {
     RootJobs = new List<IJob>();
     _schedulableActivities = new ConcurrentDictionary<Guid, IActivitySchedule>(activities.ToDictionary(x => x.ScheduledItem.UID, x => x));
     foreach (var activity in activities.Where(x => x.ScheduledItem.DefaultPredecessors.Count == 0))
     {
         ProcessSchedulableActivity(activity);
     }
 }
        public InitialComponentsInjecter(
            DiContainer container, List<Component> injectableComponents)
        {
            _container = container;
            _componentMap = injectableComponents.ToDictionary(x => x, x => new ComponentInfo(x));

            // Installers are always injected just before calling Install()
            Assert.That(injectableComponents.Where(x => x.GetType().DerivesFrom<MonoInstaller>()).IsEmpty());
        }
Example #28
0
 public void set_colors(List<category_colors> colors, info_type column) {
     try {
         colors_ = colors.ToDictionary(x => x.name, x => x);
     } catch {
         colors_ = null;
         logger.Error("invalid color names " + util.concatenate(colors.Select(x => x.name), ", ") );
     }
     column_ = column;
 }
Example #29
0
        private void ActualizarPantalla(List<Ruta> rutas)
        {
            //Borro lo que esta actualmente en la grilla
            BorrarDataGridView();
            var rutasDictionary = new Dictionary<int, Ruta>();

            #region Cargar comboBox
            CmbTipoServicio.DataSource = ServicioPersistencia.ObtenerTodos();
            CmbTipoServicio.ValueMember = "ID_Servicio";
            CmbTipoServicio.DisplayMember = "Nombre";

            CmbCiudadOrigen.DataSource = CiudadPersistencia.ObtenerTodos();
            CmbCiudadOrigen.ValueMember = "ID";
            CmbCiudadOrigen.DisplayMember = "Nombre";

            CmbCiudadDestino.DataSource = CiudadPersistencia.ObtenerTodos();
            CmbCiudadDestino.ValueMember = "ID";
            CmbCiudadDestino.DisplayMember = "Nombre";
            #endregion

            #region Obtengo el diccionario de rutas

            //El datasource debe ser todos los registros de rutas almacenadas en la base de datos
            if (rutas == null)
            {
                BorrarFiltrosUI();
                _rutas = RutaPersistencia.ObtenerTodas();
                //Convierto todas las rutas a un diccionario con entradas de la forma: (ID, Objeto)
                rutasDictionary = _rutas.ToDictionary(a => a.ID, a => a);
            }
            else
            {
                CmbTipoServicio.Text = "SERVICIO";
                CmbCiudadOrigen.Text = "CIUDAD ORIGEN";
                CmbCiudadDestino.Text = "CIUDAD DESTINO";
                //Convierto la lista de rutas a un diccionario con entradas de la forma: (ID, Objeto)
                rutasDictionary = rutas.ToDictionary(a => a.ID, a => a);
            }

            #endregion

            //Creo un bind para luego setearselo directamente a la DataGridView
            var bind = rutasDictionary.Values.Select(a => new
            {
                CodigoRuta = a.Codigo_Ruta,
                TipoServicio = RutaPersistencia.ObtenerServicioPorID(a.ID_Servicio),
                CiudadOrigen = RutaPersistencia.ObtenerCiudadPorID(a.ID_Ciudad_Origen),
                CiudadDestino = RutaPersistencia.ObtenerCiudadPorID(a.ID_Ciudad_Destino),
                PrecioBaseKg = a.Precio_Base_KG,
                PrecioBasePasaje = a.Precio_Base_Pasaje,
                Habilitado = a.Habilitado
            });
            DgvRuta.DataSource = bind.ToList();

            //Agrego los botones a cada fila para poder modificar/borrar cada ruta
            AgregarBotonesColumnas();
        }
Example #30
0
 public DataProcessor(List<FrameQueue> queues, IBrocker brocker, WorkersRepository workersRepository)
 {
     _brocker = brocker;
     _unlockedQueues = queues.ToDictionary(queue => queue.Id, queue => true);
     _queues = queues;
     foreach (var worker in workersRepository.GetAll())
     {
         worker.Ready += WorkerOnReady;
     }
 }