当前位置: 首页>>代码示例>>C#>>正文


C# Generator.PassGeneratorRequest类代码示例

本文整理汇总了C#中Passbook.Generator.PassGeneratorRequest的典型用法代码示例。如果您正苦于以下问题:C# PassGeneratorRequest类的具体用法?C# PassGeneratorRequest怎么用?C# PassGeneratorRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PassGeneratorRequest类属于Passbook.Generator命名空间,在下文中一共展示了PassGeneratorRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetPass

        public override Passbook.Generator.PassGeneratorRequest GetPass(string serialNumber)
        {
            PassGeneratorRequest request = new PassGeneratorRequest();

            request.PassTypeIdentifier = PassTypeIdentifier;
            request.SerialNumber = Guid.NewGuid().ToString("D");

            TemplateModel parameters = new TemplateModel();

            parameters.AddField("origin", FieldAttribute.Label, "San Francisco");
            parameters.AddField("origin", FieldAttribute.Value, "SFO");

            parameters.AddField("destination", FieldAttribute.Label, "London Heathrow");
            parameters.AddField("destination", FieldAttribute.Value, "LHR");

            parameters.AddField("seat", FieldAttribute.Value, "7A");
            parameters.AddField("boarding-gate", FieldAttribute.Value, "F12");
            parameters.AddField("passenger-name", FieldAttribute.Value, "John Appleseed");

            request.AddBarCode("M1APPLESEED/JMR EZQ7O92 GVALHRBA 00723319C002F00009100", BarcodeType.PKBarcodeFormatPDF417, "iso-8859-1");

            request.LoadTemplate("BoardingPass", parameters);

            return request;
        }
开发者ID:joe-keane,项目名称:dotnet-passbook,代码行数:25,代码来源:BoardingPassProvider.cs

示例2: CopyImageFiles

        private void CopyImageFiles(PassGeneratorRequest request, string tempPath)
        {
            // get and copy all files in given directory
            if (request.ImagesPath != null)
            {
                foreach (var file in Directory.GetFiles(request.ImagesPath))
                {
                    string fileName = file.Split('\\').Last(),
                           temporaryPathAndFile = Path.Combine(tempPath, fileName);

                    // copy from origin to temp destination
                    File.Copy(file, temporaryPathAndFile);
                }
            }

            // override path
            if (request.ImagesList != null && request.ImagesList.Count > 0)
            {
                foreach (var image in request.ImagesList)
                {
                    string temporaryPathAndFile = Path.Combine(tempPath, StringEnum.GetStringValue(image.Key));

                    // copy from origin to temp destination
                    File.Copy(image.Value, temporaryPathAndFile, true);
                }
            }
        }
开发者ID:balexandre,项目名称:dotnet-passbook,代码行数:27,代码来源:PassGenerator.cs

示例3: CreatePackage

        private string CreatePackage(PassGeneratorRequest request)
        {
            string tempPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName(), "contents");
            Directory.CreateDirectory(tempPath);

            CopyImageFiles(request, tempPath);
            CreatePassFile(request, tempPath);
            GenerateManifestFile(request, tempPath);

            return tempPath;
        }
开发者ID:fbeltrao,项目名称:dotnet-passbook,代码行数:11,代码来源:PassGenerator.cs

示例4: GetCertificate

 public static X509Certificate2 GetCertificate(PassGeneratorRequest request)
 {
     if (request.Certificate == null)
     {
         return GetSpecifiedCertificateFromCertStore(request.CertThumbprint, StoreName.My, request.CertLocation);
     }
     else
     {
         return GetCertificateFromBytes(request.Certificate, request.CertificatePassword);
     }
 }
开发者ID:dpvreony-forks,项目名称:dotnet-passbook,代码行数:11,代码来源:PassGenerator.cs

示例5: ZipPackage

        private void ZipPackage(PassGeneratorRequest request)
        {
            using (MemoryStream zipToOpen = new MemoryStream())
            {
                using (ZipArchive archive = new ZipArchive(zipToOpen, ZipArchiveMode.Update, true))
                {
					foreach (KeyValuePair<PassbookImage, byte[]> image in request.Images)
					{	
						ZipArchiveEntry imageEntry = archive.CreateEntry(image.Key.ToFilename());

						using (BinaryWriter writer = new BinaryWriter(imageEntry.Open()))
						{
							writer.Write(image.Value);
							writer.Flush();
						}
					}

					foreach (KeyValuePair<string, byte[]> localization in localizationFiles)
					{
						ZipArchiveEntry localizationEntry = archive.CreateEntry(string.Format ("{0}.lproj/pass.strings", localization.Key.ToLower()));

						using (BinaryWriter writer = new BinaryWriter(localizationEntry.Open()))
						{
							writer.Write(localization.Value);
							writer.Flush();
						}
					}

                    ZipArchiveEntry PassJSONEntry = archive.CreateEntry(@"pass.json");
                    using (BinaryWriter writer = new BinaryWriter(PassJSONEntry.Open()))
                    {
                        writer.Write(passFile);
                        writer.Flush();
                    }

                    ZipArchiveEntry ManifestJSONEntry = archive.CreateEntry(@"manifest.json");
                    using (BinaryWriter writer = new BinaryWriter(ManifestJSONEntry.Open()))
                    {
                        writer.Write(manifestFile);
                        writer.Flush();
                    }

                    ZipArchiveEntry SignatureEntry = archive.CreateEntry(@"signature");
                    using (BinaryWriter writer = new BinaryWriter(SignatureEntry.Open()))
                    {
                        writer.Write(signatureFile);
                        writer.Flush();
                    }
                }

                pkPassFile = zipToOpen.ToArray();
                zipToOpen.Flush();
            }
        }
开发者ID:joe-keane,项目名称:dotnet-passbook,代码行数:54,代码来源:PassGenerator.cs

示例6: Generate

        public byte[] Generate(PassGeneratorRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request", "You must pass an instance of PassGeneratorRequest");
            }

            CreatePackage(request);
            ZipPackage(request);

            return pkPassFile;
        }
开发者ID:dpvreony-forks,项目名称:dotnet-passbook,代码行数:12,代码来源:PassGenerator.cs

示例7: Generate

        public Pass Generate(PassGeneratorRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            string pathToPackage = CreatePackage(request);

            string pathToZip = ZipPackage(pathToPackage);

            return new Pass(pathToZip);
        }
开发者ID:balexandre,项目名称:dotnet-passbook,代码行数:13,代码来源:PassGenerator.cs

示例8: Generate

        public byte[] Generate(PassGeneratorRequest request)
        {
            if (request == null)
                throw new ArgumentNullException("request", "You must pass an instance of PassGeneratorRequest");

            if (request.IsValid)
            {
                CreatePackage(request);
                ZipPackage(request);

                return pkPassFile;
            }
            else
                throw new Exception("PassGeneratorRequest is not valid");
        }
开发者ID:edudutra,项目名称:dotnet-passbook,代码行数:15,代码来源:PassGenerator.cs

示例9: CreatePassFile

        private void CreatePassFile(PassGeneratorRequest request)
        {
            using (MemoryStream ms = new MemoryStream())
            {
                using (StreamWriter sr = new StreamWriter(ms))
                {
                    using (JsonWriter writer = new JsonTextWriter(sr))
                    {
                        request.Write(writer);
                    }

                    passFile = ms.ToArray();
                }
            }
        }
开发者ID:nobodyyu,项目名称:dotnet-passbook,代码行数:15,代码来源:PassGenerator.cs

示例10: GetPass

        public override Passbook.Generator.PassGeneratorRequest GetPass(string serialNumber)
        {
            PassGeneratorRequest request = new PassGeneratorRequest();

            request.PassTypeIdentifier = PassTypeIdentifier;
            request.SerialNumber = Guid.NewGuid().ToString("D");

            TemplateModel parameters = new TemplateModel();

            request.AddBarCode("01927847623423234234", BarcodeType.PKBarcodeFormatPDF417, "UTF-8", "01927847623423234234");

            request.LoadTemplate("Coupon", parameters);

            return request;
        }
开发者ID:joe-keane,项目名称:dotnet-passbook,代码行数:15,代码来源:CouponPassProvider.cs

示例11: GetCertificate

        private static X509Certificate2 GetCertificate(PassGeneratorRequest request)
        {
            Trace.TraceInformation("Fetching Pass Certificate...");

            try
            {
                if (request.Certificate == null)
                    return GetSpecifiedCertificateFromCertStore(request.CertThumbprint, StoreName.My);
                else
                    return GetCertificateFromBytes(request.Certificate, request.CertificatePassword);
            }
            catch (Exception exp)
            {
                Trace.TraceError("Failed to fetch Pass Certificate: [{0}]", exp.Message);
                throw;
            }
        }
开发者ID:edudutra,项目名称:dotnet-passbook,代码行数:17,代码来源:PassGenerator.cs

示例12: CopyImageFiles

        private void CopyImageFiles(PassGeneratorRequest request, string tempPath)
        {
            string targetIconFileAndPath = Path.Combine(tempPath, Path.GetFileName(request.IconFile));
            string targetIconRetinaFileAndPath = Path.Combine(tempPath, Path.GetFileName(request.IconRetinaFile));

            File.Copy(request.IconFile, targetIconFileAndPath);
            File.Copy(request.IconRetinaFile, targetIconRetinaFileAndPath);

            string targetLogoFileAndPath = Path.Combine(tempPath, Path.GetFileName(request.LogoFile));
            string targetLogoRetinaFileAndPath = Path.Combine(tempPath, Path.GetFileName(request.LogoRetinaFile));

            File.Copy(request.LogoFile, targetLogoFileAndPath);
            File.Copy(request.LogoRetinaFile, targetLogoRetinaFileAndPath);

            string targetBackgroundFileAndPath = Path.Combine(tempPath, Path.GetFileName(request.BackgroundFile));
            string targetBackgroundRetinaFileAndPath = Path.Combine(tempPath, Path.GetFileName(request.BackgroundRetinaFile));

            File.Copy(request.BackgroundFile, targetBackgroundFileAndPath);
            File.Copy(request.BackgroundRetinaFile, targetBackgroundRetinaFileAndPath);
        }
开发者ID:fbeltrao,项目名称:dotnet-passbook,代码行数:20,代码来源:PassGenerator.cs

示例13: GetPass

        public override Passbook.Generator.PassGeneratorRequest GetPass(string serialNumber)
        {
            PassGeneratorRequest request = new PassGeneratorRequest();

            request.PassTypeIdentifier = PassTypeIdentifier;
            request.SerialNumber = Guid.NewGuid().ToString("D");

            TemplateModel parameters = new TemplateModel();

            parameters.AddField("event", FieldAttribute.Value, "Jeff Wayne's War of the Worlds");

            DateTime eventDate = DateTime.Now.AddDays(1);

            parameters.AddField("doors-open", FieldAttribute.Value, new DateTime(eventDate.Year, eventDate.Month, eventDate.Day, 20, 30, 00));
            parameters.AddField("seating-section", FieldAttribute.Value, 10);

            request.AddBarCode("01927847623423234234", BarcodeType.PKBarcodeFormatPDF417, "iso-8859-1", "01927847623423234234");

            request.LoadTemplate("Event", parameters);

            return request;
        }
开发者ID:joe-keane,项目名称:dotnet-passbook,代码行数:22,代码来源:EventPassProvider.cs

示例14: GetCertificate

        public static X509Certificate2 GetCertificate(PassGeneratorRequest request)
        {
            X509Store store = new X509Store(StoreName.My, request.CertLocation);
            store.Open(OpenFlags.ReadOnly);

            X509Certificate2Collection certs = store.Certificates;

            if (certs.Count > 0)
            {
                for (int i = 0; i < certs.Count; i++)
                {
                    X509Certificate2 cert = certs[i];

                    Debug.WriteLine(cert.Thumbprint);

                    if (string.Compare(cert.Thumbprint, request.CertThumbprint, true) == 0)
                    {
                        return certs[i];
                    }
                }
            }

            return null;
        }
开发者ID:fbeltrao,项目名称:dotnet-passbook,代码行数:24,代码来源:PassGenerator.cs

示例15: WriteRelevanceKeys

        private void WriteRelevanceKeys(JsonWriter writer, PassGeneratorRequest request)
        {
            if (request.RelevantDate.HasValue)
            {
                writer.WritePropertyName("relevantDate");
                writer.WriteValue(request.RelevantDate.Value.ToString("yyyy-MM-ddTHH:mm:ssZ"));
            }

            if (RelevantLocations.Count > 0)
            {
                writer.WritePropertyName("locations");
                writer.WriteStartArray();

                foreach (var location in RelevantLocations)
                {
                    location.Write(writer);
                }

                writer.WriteEndArray();
            }

            if (RelevantBeacons.Count > 0)
            {
                writer.WritePropertyName("beacons");
                writer.WriteStartArray();

                foreach (var beacon in RelevantBeacons)
                {
                    beacon.Write(writer);
                }

                writer.WriteEndArray();
            }
        }
开发者ID:seanhotw,项目名称:dotnet-passbook,代码行数:34,代码来源:PassGeneratorRequest.cs


注:本文中的Passbook.Generator.PassGeneratorRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。