internal static IPkpassProcessor CreateByUri(Uri uri) { PkpassProcessorElement configData = null; var matchWithHost = Config.ProcessorsList.ToList().Where(p => p.Domain == uri.Host); if (matchWithHost.Count() > 0) { configData = matchWithHost.First(); } else { // No match by domain. Let's see first if the uri comes from a banned domain. if (Config.BannedDomainList.Get(uri.Host) != null) { return(null); } else { // So let's look inside the pkpass for the issuer. PkpassData pkpass = new DummyProcessor().DownloadData(uri); configData = Config.ProcessorsList.Get(pkpass.PassTypeIdentifier); } } IPkpassProcessor returnedValue = (IPkpassProcessor)Activator.CreateInstance(configData.Assembly, configData.Type).Unwrap(); return(returnedValue); }
internal static IPkpassProcessor CreateByIssuerViaFile(string filePath) { var pass = PkpassManager.OpenPkpass(filePath); var configData = Config.ProcessorsList.Get(pass.PassTypeIdentifier); IPkpassProcessor returnedValue = (IPkpassProcessor)Activator.CreateInstance(configData.Assembly, configData.Type).Unwrap(); return(returnedValue); }
internal void ProcessFile(string filePath) { IPkpassProcessor processor = PkpassProcessorFactory.CreateByIssuerViaFile(filePath); if (processor == null) { throw new ApplicationException("File type not supported"); } PkpassData data = processor.GetData(filePath); processor.Process(data); }
internal void ProcessUrl(string url) { Uri fileUri = new Uri(url); IPkpassProcessor processor = PkpassProcessorFactory.CreateByUri(fileUri); if (processor == null) { throw new ApplicationException("Link type not supported"); } PkpassData data = processor.DownloadData(fileUri); processor.Process(data, fileUri); }