public List <PortfolioViewModel> Get(bool mustHaveImages)
        {
            var portfolios = new List <PortfolioViewModel>();

            if (Directory.Exists(PortfolioBase))
            {
                foreach (var directory in Directory.GetDirectories(PortfolioBase))
                {
                    var path = Path.Combine(directory, "data.json");
                    if (!File.Exists(path))
                    {
                        continue;
                    }
                    var jsonText = File.ReadAllText(path);
                    var model    = JsonConvert.DeserializeObject <Portfolio>(jsonText);
                    model.Id = RelativeName(directory);
                    var viewModel = Mapper.Map <PortfolioViewModel>(model);
                    viewModel.Path = string.Format("{0}/{1}", RelativeBase.Replace("~/", ""), RelativeName(directory));
                    if (mustHaveImages == false || (!string.IsNullOrEmpty(viewModel.Thumb) && viewModel.Images.Any()))
                    {
                        portfolios.Add(viewModel);
                    }
                }
            }

            return(portfolios.OrderBy(p => p.Title).ToList());
        }
Ejemplo n.º 2
0
        private IOpcode GetOpCodeFromCurrentPointer()
        {
            var     opcodeValue = Convert.ToUInt32(new string(LocalComputerMemory.PointerValue().ToString().TakeLast(2).ToArray()));
            IOpcode opcode      = null;

            switch ((OpCode)opcodeValue)
            {
            case OpCode.Adds:
                opcode = new Add();
                break;

            case OpCode.Multiplie:
                opcode = new Multiply();
                break;

            case OpCode.Inputstuff:
                opcode = new Input();
                break;

            case OpCode.OutputStuff:
                opcode = new Output();
                break;

            case OpCode.JumpIfTrue:
                opcode = new JumpIfTrue();
                break;

            case OpCode.JumpIfFalse:
                opcode = new JumpIfFalse();
                break;

            case OpCode.isLessThen:
                opcode = new LessThan();
                break;

            case OpCode.isEqual:
                opcode = new Equal();
                break;

            case OpCode.RelativeBase:
                opcode = new RelativeBase();
                break;

            case OpCode.Exit:
                opcode = new Exit();
                break;

            default:
                break;
            }
            return(opcode);
        }
        private Portfolio GetPortfolio(string id)
        {
            var dataFileName = Path.Combine(PortfolioBase, id, "data.json");

            if (File.Exists(dataFileName))
            {
                var jsonText = File.ReadAllText(dataFileName);
                var model    = JsonConvert.DeserializeObject <Portfolio>(jsonText);
                model.Path = string.Format("{0}/{1}", RelativeBase.Replace("~/", ""), id);
                model.Id   = id;
                return(model);
            }
            return(new Portfolio());
        }