converter

Static Instance Base/Derived class

五迷三道 提交于 2019-12-22 05:49:18
问题 I would like to write a static instance property in a base class and derive this, but I am facing some problems. Here is the code for the base class - I currently have: public abstract class ResourceInstance<T> { private static T _instance; public static T Instance { get { if (_instance != null) return _instance; var method = MethodBase.GetCurrentMethod(); var declaringType = method.DeclaringType; if (declaringType != null) { var name = declaringType.Name; _instance = (T)Application.Current

How to set date format for JSON converter in Grails

早过忘川 提交于 2019-12-22 04:20:07
问题 I've a method in my Grails controller that should return a JSON, a property of the JSON is a Date object, but when I do: render myObject as JSON the output is like: { "dateProperty": "2010-12-31T23:00:00Z", "otherProperty" : "aValue..." } Is there a way to change the default date format used from the converter? I've tried to set the property grails.converters.json.date and also grails.date.formats in the Config.groovy , but this doesn't work. Am I doing something wrong or is there another way

Java print four byte hexadecimal number

五迷三道 提交于 2019-12-22 03:58:19
问题 I have a small problem. I have numbers like 5421, -1 and 1. I need to print them in four bytes, like: 5421 -> 0x0000152D -1 -> 0xFFFFFFFF 1 -> 0x00000001 Also, I have floating point numbers like 1.2, 58.654: 8.25f -> 0x41040000 8.26 -> 0x410428f6 0.7 -> 0x3f333333 I need convert both types of numbers into their hexadecimal version, but they must be exactly four bytes long (four pairs of hexadecimal digits). Does anybody know how is this possible in Java? Please help. 回答1: Here are two

Why does System.Convert has ToDateTime that accepts DateTime?

给你一囗甜甜゛ 提交于 2019-12-22 03:24:12
问题 // // Summary: // Returns the specified System.DateTime object; no actual conversion is performed. // // Parameters: // value: // A date and time value. // // Returns: // value is returned unchanged. public static DateTime ToDateTime(DateTime value); Why does System.Convert has ToDateTime that accepts DateTime ? The method documentation states the value remain unchanged. 回答1: Convention, predictability and because the IConvertable defines the method ToDateTime. My believe is that under the

How do I access EJB bean when inside a custom Converter [duplicate]

旧街凉风 提交于 2019-12-22 01:31:38
问题 This question already has answers here : How to inject @EJB, @PersistenceContext, @Inject, @Autowired, etc in @FacesConverter? (5 answers) Closed 5 years ago . This converter is called from my JSF. I already register it inside faces-config.xml public class ProjectConverter implements Converter{ @EJB DocumentSBean sBean; @ManagedProperty(value="#{logging}") private Logging log; public ProjectConverter(){ } public Object getAsObject(FacesContext context, UIComponent component, String value) {

How to set the SystemColors.HighlightBrushKey in WPF with a Converter

﹥>﹥吖頭↗ 提交于 2019-12-22 01:29:42
问题 I im trying to set the SystemColors.HighlightBrushKey always a bit darker than the Background of the selected Row. Therefore im using this Code: App.xaml: <WPFTests2:SelectionBackgroundConverter x:Key="SelectionBackgroundConverter"/> <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="{Binding Background, Converter={StaticResource SelectionBackgroundConverter}}"/> </Application.Resources> Window1.xaml: <Window x:Class="WPFTests2.Window1" xmlns="http://schemas.microsoft

Proper way to convert HTML to PDF

…衆ロ難τιáo~ 提交于 2019-12-21 20:35:10
问题 I want to convert HTML page to PDF. There are several options, but they have some problems. Print HTML page in IE through PDFCreator (too cumbersome) Use wkhtmltopdf (low quality) Use PhantomJS (low quality) Maybe I can use a complex solution? To print with PhantomJS through PDFCreator , or improve quality of wkhtmltopdf , or maybe something else? 回答1: Maybe you can try with Amyuni WebkitPDF. It's not open source, but it's free for commercial use, and it can be used from C#. Sample code for C

Convert PNG to SVG using python

痞子三分冷 提交于 2019-12-21 14:06:41
问题 Is there way to convert a png file into SVG file using only pure python or a python module such as wand? To be more precise, I want to convert a png into a real vector graphics, I don't want to embed a bitmap inside the svg, I want to convert into graphics code. I know this is possible with Illustrator or Inkscape, but I need an automated process. Thank you ! 回答1: You will need to run an external program to do the image tracing. A popular program is potrace. It is what Inkscape uses to

How to convert g729 encoded byte array to .WAV in C#?

杀马特。学长 韩版系。学妹 提交于 2019-12-21 13:04:09
问题 I have been working on a VoIP Application in C sharp language. The purpose of the project is VoIP Call Recording. It uses g729 Codec. I can extract the voice part from RTP payload. How to convert this Byte array to .wav format? Please help me. 回答1: You can try to use ffmpeg.exe and work with it via command line 来源: https://stackoverflow.com/questions/13468240/how-to-convert-g729-encoded-byte-array-to-wav-in-c

How to set FallbackValue in binding as path to external image file?

天涯浪子 提交于 2019-12-21 08:54:29
问题 I'm trying to set FallbackValue in case when my converter cannot be call, but I'm not sure how to do that. <Image Source="{Binding FallbackValue="Pictures/Unknown.png", Path=LatestPosition.DeviceFamily, Converter={x:Static conv:ConverterSet.DeviceTypeToImageSourceconverter}}" Name="image1" Stretch="Fill" Margin="5,8" Width="150" Height="150" Grid.RowSpan="4" /> Paths of external images in converter looks like that and when LatestPosition!=null the image is set in proper way. private static