Esempio n. 1
0
 public static UserControl GetViewVMB(ViewModelBase module)
 {
     System.Attribute[] attrs = System.Attribute.GetCustomAttributes(module.GetType());
     foreach (System.Attribute attr in attrs)
     {
         if (attr is PreferredViewAttribute)
         {
             PreferredViewAttribute a      = (PreferredViewAttribute)attr;
             ObjectHandle           handle = Activator.CreateInstance(a.AssemblyName, a.ViewName);
             object p = handle.Unwrap();
             return((UserControl)p);
         }
     }
     return(null);
 }
Esempio n. 2
0
        /// <summary>
        /// Gets a view for a given DataStoreItemViewmodel
        /// </summary>
        /// <param name="viewModel">The DataStoreItemViewModel that will be tied to the view</param>
        /// <returns>If there DataStoreItemViewModel has a preferred view attribute it will instantiate and
        /// return that. If not the method will try to instantiate and return a view based on the
        /// underlying DataStoreItem</returns>
        private static UserControl GetView(DataStoreItemViewModel viewModel)
        {
            System.Attribute[] attrs = System.Attribute.GetCustomAttributes(viewModel.GetType());
            foreach (System.Attribute attr in attrs)
            {
                if (attr is PreferredViewAttribute)
                {
                    PreferredViewAttribute a      = (PreferredViewAttribute)attr;
                    ObjectHandle           handle = Activator.CreateInstance(a.AssemblyName, a.ViewName);
                    object p = handle.Unwrap();
                    return((UserControl)p);
                }
            }
            ObjectHandle handler = Activator.CreateInstance("iRadiate.Desktop.Common", "iRadiate.Desktop.Common.View." + viewModel.Item.ConcreteType.Name + "View");
            object       pr      = handler.Unwrap();

            return((UserControl)pr);
        }