Use of eval in Python

eval and exec are handy quick-and-dirty way to get some source code dynamically, maybe munge it a bit, and then execute it — but they’re hardly ever the best way, especially in production code as opposed to “quick-and-dirty” prototypes &c. For example, if I had to deal with such dynamic Python sources, I’d reach for … Read more

Create DataTemplate in codebehind

Although Archedius’s method works, officially it is deprecated and instead recommended way to programmatically create a template is to load XAML from a string or a memory stream using the Load method of the XamlReader class like this… public DataTemplate Create(Type type) { StringReader stringReader = new StringReader( @”<DataTemplate xmlns=””http://schemas.microsoft.com/winfx/2006/xaml/presentation””> <” + type.Name + @” … Read more

Dynamic Paths in Helper

basically you need to transform the class name of the model into something pointing to the correct path. model_name = m.class.to_s.underscore And then use it to call the appropriate path methods link_to “edit”, send(“edit_#{model_name}_path”, m) As an aside, you don’t need to put the link_tos in #{} because that function simply returns a string.

Binding to ExpandoObject. PropertyChanged not working

They didn’t add a default mechanism for binding to dynamic objects and instead added a new interface ICustomTypeProvider. And that interface wasn’t added to an ExpandoObject either, but with expando you should be able to use the indexer binding since it is an IDictionary<string, object> that implements INotifyPropertyChanged. <TextBlock Text=”{Binding [Foo]}”/>

Can I serialize an ExpandoObject in .NET 4?

I can’t serialize ExpandoObject, but I can manually serialize DynamicObject. So using the TryGetMember/TrySetMember methods of DynamicObject and implementing ISerializable, I can solve my problem which was really to serialize a dynamic object. I’ve implemented the following in my simple test app: using System; using System.Windows.Forms; using System.IO; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; using System.Collections.Generic; using … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)