Ejemplo n.º 1
0
        protected void Application_Start(object sender, EventArgs e)
        {
            SerializationContext.Current.Initialize(new JavaScriptSerializationStrategy());

            var obj = new { Name = "John", Age = 10 };
            var text = obj.Serialize();
        }
        /// <summary>
        /// Logs the order creation
        /// </summary>
        /// <param name="order">
        /// The order.
        /// </param>
        internal static void AuditCreated(this IOrder order)
        {
            var obj = new
            {
                area = Area,
                key = "orderCreated",
                invoiceNumber = order.PrefixedOrderNumber()
            };

            UpdateAuditLog(order.Key, EntityType.Order, obj.Serialize());
        }
        /// <summary>
        /// Logs a shipment creation
        /// </summary>
        /// <param name="shipment">
        /// The shipment.
        /// </param>
        public static void AuditCreated(this IShipment shipment)
        {
            var obj = new
            {
                area = Area,
                key = "shipmentCreated",
                itemCount = shipment.Items.Count.ToString(CultureInfo.InvariantCulture)
            };

            UpdateAuditLog(shipment.Key, EntityType.Shipment, obj.Serialize());
        }
        /// <summary>
        /// Logs an invoice deletion
        /// </summary>
        /// <param name="invoice">
        /// The invoice.
        /// </param>
        internal static void AuditDeleted(this IInvoice invoice)
        {
            var obj = new
            {
                area = Area,
                key = "invoiceDeleted",
                invoiceNumber = invoice.PrefixedInvoiceNumber()
            };    

            UpdateAuditLog(invoice.Key, EntityType.Invoice, obj.Serialize());
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            SerializationContext.Current.Initialize(new JsonSerializationStrategy());

            var obj = new { Name = "John", Age = 10 };
            var text = obj.Serialize();
            Console.WriteLine(text);

            var obj2 = text.Deserialize<object>();
            var typeName = obj2.GetType().Name;

            Console.ReadLine();
        }
        void ICloudFileDataTransfer.Serialize(System.Runtime.Serialization.IFormatter dataFormatter, object objectGraph)
        {
            using (var cache = new MemoryStream())
            {
                // serialize into the cache
                dataFormatter.Serialize(cache, objectGraph);

                // go to start
                cache.Position = 0;

                // transfer the cache
                _fsEntry.GetDataTransferAccessor().Transfer(cache, nTransferDirection.nUpload);
            }
        }
Ejemplo n.º 7
0
        private static void EmitSampleXml(LdifCsvPivot pivot, System.Xml.Serialization.XmlSerializer ser)
        {
            try
            {
                string temp = System.Environment.GetEnvironmentVariable("TEMP");
                string opath = SamplePath.Replace("%TEMP%", temp ?? @"c:\temp");

                if (!System.IO.File.Exists(opath))
                {
                    using (System.IO.FileStream fs = new System.IO.FileStream(opath, System.IO.FileMode.Create))
                    {
                        ser.Serialize(fs, pivot.Columns);
                    }
                }
            }
            catch (Exception x)
            {
                Console.Error.WriteLine("Couldn't generate sample config at {0}: {1}",
                    SamplePath, x.Message);
            }
        }
        /// <summary>
        /// Logs a voided payment.
        /// </summary>
        /// <param name="payment">
        /// The payment.
        /// </param>
        /// <param name="amount">
        /// The refund amount
        /// </param>
        internal static void AuditPaymentRefunded(this IPayment payment, decimal amount)
        {
            var obj = new
            {
                area = Area,
                key = "paymentRefunded",
                refundAmount = amount,
                currencyCode = payment.ExtendedData.GetValue(Constants.ExtendedDataKeys.CurrencyCode)
            };

            UpdateAuditLog(payment.Key, EntityType.Payment, obj.Serialize());
        }
        /// <summary>
        /// Logs a voided payment.
        /// </summary>
        /// <param name="payment">
        /// The payment.
        /// </param>
        internal static void AuditPaymentVoided(this IPayment payment)
        {
            var obj = new
            {
                area = Area,
                key = "paymentVoided"
            };

            UpdateAuditLog(payment.Key, EntityType.Payment, obj.Serialize());
        }
        /// <summary>
        /// Logs an authorized payment
        /// </summary>
        /// <param name="payment">
        /// The payment to be collected
        /// </param>
        /// <param name="invoice">
        /// The invoice for which the payment was authorized 
        /// </param>
        internal static void AuditPaymentAuthorize(this IPayment payment, IInvoice invoice)
        {            
            var obj = new
            {
                area = Area,
                key = "paymentAuthorize",
                invoiceTotal = invoice.Total,
                currencyCode = invoice.Items.First().ExtendedData.GetValue(Constants.ExtendedDataKeys.CurrencyCode)
            };

            UpdateAuditLog(payment.Key, EntityType.Payment, obj.Serialize());
        }
        /// <summary>
        /// Logs a shipment status change
        /// </summary>
        /// <param name="shipment">
        /// The shipment.
        /// </param>
        public static void AuditStatusChanged(this IShipment shipment)
        {
            var obj = new
            {
                area = Area,
                key = "shipmentStatusChanged",
                shipmentStatus = shipment.ShipmentStatus.Name
            };

            UpdateAuditLog(shipment.Key, EntityType.Shipment, obj.Serialize());
        }
        /// <summary>
        /// Logs an invoice status change
        /// </summary>
        /// <param name="invoice">
        /// The invoice.
        /// </param>
        public static void AuditStatusChanged(this IInvoice invoice)
        {
            var obj = new
            {
                area = Area,
                key = "invoiceStatusChanged",
                invoiceStatus = invoice.InvoiceStatus.Name
            };

            UpdateAuditLog(invoice.Key, EntityType.Invoice, obj.Serialize());
        }
        /// <summary>
        /// Logs a captured payment
        /// </summary>
        /// <param name="payment">
        /// The payment.
        /// </param>
        /// <param name="amount">The amount captured</param>
        public static void AuditPaymentCaptured(this IPayment payment, decimal amount)
        {
            var obj = new
            {
                area = Area,
                key = "paymentCaptured",
                invoiceTotal = amount,
                currencyCode = payment.ExtendedData.GetValue(Constants.ExtendedDataKeys.CurrencyCode)
            };

            UpdateAuditLog(payment.Key, EntityType.Payment, obj.Serialize());
        }
        /// <summary>
        /// Logs an order deletion
        /// </summary>
        /// <param name="order">
        /// The order.
        /// </param>
        public static void AuditDeleted(this IOrder order)
        {
            var obj = new
            {
                area = Area,
                key = "orderDeleted",
                orderNumber = order.PrefixedOrderNumber()
            };

            UpdateAuditLog(order.Key, EntityType.Order, obj.Serialize());
        }
 /// <summary>
 /// Logs a declined payment
 /// </summary>
 /// <param name="payment">
 /// The payment.
 /// </param>
 public static void AuditPaymentDeclined(this IPayment payment)
 {
     var obj = new
     {
         area = Area,
         key = "paymentDeclined"
     };
     if (payment != null)
     {
         UpdateAuditLog(payment.Key, EntityType.Payment, obj.Serialize());
     }
 }