Пример #1
0
        private void PluginInit()
        {
            var types = TypeLocator.FindTypes("*plugin*.dll", typeof(PanelBase));

            foreach (Type type in types)
            {
                PluginInfo             info = new PluginInfo();
                PanelMetadataAttribute atty = type.GetAttribute <PanelMetadataAttribute>();
                info.PluginType = type;
                if (atty != null && !string.IsNullOrWhiteSpace(atty.DisplayName))
                {
                    info.Name = atty.DisplayName;
                }
                else
                {
                    info.Name = PascalCaseSplitter.Split(type.Name);
                }
                if (atty != null && !string.IsNullOrWhiteSpace(atty.IconPath))
                {
                    info.Icon = WPFHelpers.GetImage(atty.IconPath, info.PluginType.Assembly);
                }
                if (info.Icon == null)
                {
                    info.Icon = WPFHelpers.GetImage("images/puzzle-piece.png");
                }
                this.Invoke(() => Plugins.Add(info));
            }
            this.BeginInvoke(() => { if (SelectedPanel == null)
                                     {
                                         SelectedPanel = Plugins[0];
                                     }
                             });
        }
 public void PascalCaseSplitterTestNumbers()
 {
     Assert.AreEqual("Foo Bar 2000", PascalCaseSplitter.Split("FooBar2000"));
     Assert.AreEqual("Frank's 2000 Inch TV", PascalCaseSplitter.Split("Frank's2000InchTV"));
     Assert.AreEqual("ASDF 8000 WEE", PascalCaseSplitter.Split("ASDF8000WEE"));
     Assert.AreEqual("9000", PascalCaseSplitter.Split("9000"));
     Assert.AreEqual("Param 9000", PascalCaseSplitter.Split("param9000"));
     Assert.AreEqual("9 Params", PascalCaseSplitter.Split("9params"));
     Assert.AreEqual("Thing Number 2", PascalCaseSplitter.Split("ThingNumber2"));
 }
Пример #3
0
        private void ParseProperties(IEnumerable <object> items)
        {
            Clear();
            foreach (object obj in items)
            {
                foreach (PropertyInfo prop in obj.GetType().GetProperties())
                {
                    if (prop.DeclaringType == typeof(DependencyObject))
                    {
                        continue;
                    }
                    if (prop.DeclaringType == typeof(DispatcherObject))
                    {
                        continue;
                    }

                    PropertyEditorMetadataAttribute atty = prop.GetCustomAttribute <PropertyEditorMetadataAttribute>();
                    if (atty != null && atty.Hidden)
                    {
                        continue;
                    }

                    PropertyGridEditor editor = null;
                    _properties.TryGetValue(prop.Name, out editor);

                    if (editor == null)
                    {
                        editor = PropertyGridEditorFactory.GetEditor(prop.PropertyType);
                        editor.PropertyType = prop.PropertyType;
                        editor.Name         = prop.Name;
                        editor.DisplayName  = PascalCaseSplitter.Split(prop.Name);
                        editor.IsReadOnly   = prop.SetMethod == null || !prop.SetMethod.IsPublic;
                        editor.Modified    += Meta_Modified;

                        _properties.Add(prop.Name, editor);
                        Properties.Add(editor);
                    }

                    editor.Values.Add(prop.GetValue(obj, null));
                }
            }
        }
 public void PascalCaseSplitterTestCamelCase()
 {
     Assert.AreEqual("Camel", PascalCaseSplitter.Split("camel"));
     Assert.AreEqual("Camel Case Splitter", PascalCaseSplitter.Split("camelCaseSplitter"));
 }
 public void PascalCaseSplitterTestPascalCase()
 {
     Assert.AreEqual("Pascal", PascalCaseSplitter.Split("Pascal"));
     Assert.AreEqual("Pascal Case Splitter Test Pascal Case", PascalCaseSplitter.Split("PascalCaseSplitterTestPascalCase"));
     Assert.AreEqual("Do Re Me Fa So La Ti Do", PascalCaseSplitter.Split("DoReMeFaSoLaTiDo"));
 }
 public void PascalCaseSplitterTestAcronyms()
 {
     Assert.AreEqual("XML Serializer", PascalCaseSplitter.Split("XMLSerializer"));
     Assert.AreEqual("Serailize Me Some XML", PascalCaseSplitter.Split("SerailizeMeSomeXML"));
     Assert.AreEqual("Do Some XML Stuff", PascalCaseSplitter.Split("DoSomeXMLStuff"));
 }