Beispiel #1
0
            public IList <ICarModel> GetProductionList()
            {
                IList <ICarModel> models        = new List <ICarModel>();
                string            directoryPath = AppDomain.CurrentDomain.BaseDirectory;

                string[] files = Directory.GetFiles(directoryPath, "*.dll");

                foreach (string item in files)
                {
                    Assembly assembly = null;
                    try { assembly = Assembly.LoadFile(item); }
                    catch (ReflectionTypeLoadException e) { }

                    foreach (Type type in assembly.GetTypes())
                    {
                        Type temp = type.GetInterface("ICarModel");
                        if (temp != null)
                        {
                            CarInfoAttribute atr = (CarInfoAttribute)type.GetCustomAttribute(typeof(CarInfoAttribute));
                            if (atr != null && atr.VendorName == this.VendorName)
                            {
                                ICarModel model = Activator.CreateInstance(type) as ICarModel;
                                models.Add(model);
                            }
                        }
                    }
                }
                return(models);
            }
Beispiel #2
0
 public CarFacade(ICarAccessories accessories, ICarBody body, ICarEngine engine, ICarModel model)
 {
     this.accessories = accessories;
     this.body        = body;
     this.engine      = engine;
     this.model       = model;
 }
Beispiel #3
0
        /// <summary>
        /// Gets the plates by model id.
        /// </summary>
        /// <param name="modelId">The model id.</param>
        /// <param name="section">The section.</param>
        /// <returns>List of year plates</returns>
        public List <IYearPlate> GetPlatesByModelId(int modelId, CarValuationSection section)
        {
            int sectionYearFromPlateId = GetFromYearPlateIdForSection(section);
            int sectionYearToPlateId   = GetToYearPlateIdForSection(section);

            ICarModel model = CarModel.FromId(modelId);

            if (model.FromYearPlate == null || model.ToYearPlate == null)
            {
                return(null);
            }

            int plateFrom = model.FromYearPlate.Id;
            int plateTo   = model.ToYearPlate.Id;

            if (sectionYearFromPlateId > plateFrom)
            {
                plateFrom = sectionYearFromPlateId;
            }

            if (sectionYearToPlateId < plateTo)
            {
                plateTo = sectionYearToPlateId;
            }

            return(yearPlateProvider.GetRange(plateFrom, plateTo));
        }
Beispiel #4
0
 private void OnSelectedCarChanged(ICarModel car)
 {
     SelectedCar = car;
     if (_waitingForCar)
     {
         CanChangeScreen = true;
         _waitingForCar  = false;
     }
 }
Beispiel #5
0
        public IGenerateOptionsMacro CreateOptionsMacro(ICarModel car)
        {
            IGenerateOptionsMacro optionsMacro = null;
            var codeFile = @"using System; 
                             using System.Collections.Generic;
                             using ClickpointAuto.Core.Factories;
                             namespace ClickpointAuto.Core.Models
                             {
                                public class GenerateOptionsMacro : IGenerateOptionsMacro
                                {
                                   public List<string> GenerateOptions(ICarModel car)
                                   {
                                      var options = new List<string>();
                                      $
                                      return options;
                                   }   
                                }
                            }";

            codeFile = codeFile.Replace("$", car.OptionsMacroText);
            var syntaxTree  = SyntaxTree.ParseCompilationUnit(codeFile);
            var compilation = Compilation.Create("ClickPointAuto.GenerateOptions",

                                                 options: new CompilationOptions(
                                                     assemblyKind: AssemblyKind.DynamicallyLinkedLibrary))
                              .AddReferences(new MetadataReference[]
            {
                new AssemblyFileReference(typeof(object).Assembly.Location),
                new AssemblyFileReference(typeof(IGenerateOptionsMacro).Assembly.Location),
                new AssemblyFileReference(typeof(CarModel).Assembly.Location)
            }).AddSyntaxTrees(syntaxTree);

            Assembly compiledAssembly;

            using (var stream = new MemoryStream())
            {
                compilation.Emit(stream);
                compiledAssembly = Assembly.Load(stream.GetBuffer());
            }
            optionsMacro = compiledAssembly.
                           CreateInstance("ClickpointAuto.Core.Models.GenerateOptionsMacro", false) as IGenerateOptionsMacro;
            return(optionsMacro);
        }
        public IGenerateOptionsMacro CreateOptionsMacro(ICarModel car)
        {
            IGenerateOptionsMacro optionsMacro = null;
            var codeFile = @"using System;
                             using System.Collections.Generic;
                             using ClickpointAuto.Core.Factories;
                             namespace ClickpointAuto.Core.Models
                             {
                                public class GenerateOptionsMacro : IGenerateOptionsMacro
                                {
                                   public List<string> GenerateOptions(ICarModel car)
                                   {
                                      var options = new List<string>();
                                      $
                                      return options;
                                   }
                                }
                            }";
            codeFile = codeFile.Replace("$", car.OptionsMacroText);
            var syntaxTree = SyntaxTree.ParseCompilationUnit(codeFile);
            var compilation = Compilation.Create("ClickPointAuto.GenerateOptions",

                                                  options: new CompilationOptions(
                                                      assemblyKind: AssemblyKind.DynamicallyLinkedLibrary))
                .AddReferences(new MetadataReference[]
                                   {
                                       new AssemblyFileReference(typeof (object).Assembly.Location),
                                       new AssemblyFileReference(typeof (IGenerateOptionsMacro).Assembly.Location),
                                       new AssemblyFileReference(typeof(CarModel).Assembly.Location)

                                   }).AddSyntaxTrees(syntaxTree);

            Assembly compiledAssembly;
            using (var stream = new MemoryStream())
            {
                compilation.Emit(stream);
                compiledAssembly = Assembly.Load(stream.GetBuffer());
            }
            optionsMacro = compiledAssembly.
                               CreateInstance("ClickpointAuto.Core.Models.GenerateOptionsMacro", false) as IGenerateOptionsMacro;
            return optionsMacro;
        }
        //Load Data, always call on activation!
        public bool LoadServiceData(ICarModel car)
        {
            ServiceModel.PassRollBackDelegate(ChangesRolledBack);

            _car = car;

            try
            {
                _serviceList = DataAccess.GetServices(car.CarID); // load up Services from DB
                if (_serviceList is null)
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                _notifyError(e);
            }

            foreach (ServiceModel SM in _serviceList)
            {
                SM.RecalcCost();
            }

            _serviceList.Sort();

            //Binding
            _services = new BindingList <ServiceModel>(_serviceList);
            _services.RaiseListChangedEvents = true;

            SortedServices = new BindingListCollectionView(_services);
            SortedServices.MoveCurrentToFirst();
            FieldedService = SortedServices.CurrentItem as ServiceModel;


            NotifyOfPropertyChange(() => SortedServices);
            NotifyOfPropertyChange(() => CanDelete);
            return(true);
        }
 public static string GetInformation(this ICarModel car)
 => car.Brand + "-" + car.Model + "-" + car.Year;