public PerspexDesigner()
        {
            InitializeComponent();
            BindingOperations.SetBinding(State, TextBox.TextProperty,
                new Binding(nameof(ProcessHost.State)) {Source = _host, Mode = BindingMode.OneWay});

            _host.PropertyChanged += _host_PropertyChanged;
            _host.MetadataArrived += data => Metadata = data;
        }
            public void SetMetadata(PerspexDesignerMetadata metadata)
            {
                if (_oldMetadata == metadata)
                    return;
                _oldMetadata = metadata;

                
                var rootNs = Utils.PerspexNamespace;
                _rootNamespaces =
                    metadata.NamespaceAliases.Where(n => n.XmlNamespace == rootNs).Select(x => x.Namespace).ToList();
                _rootNsTypes = metadata.Types.Where(t => _rootNamespaces.Contains(t.Namespace)).ToDictionary(t => t.Name);
            }
Exemple #3
0
        PerspexDesignerMetadata BuildMetadata(List<Assembly> asms, Type xmlNsAttr)
        {
            var rv = new PerspexDesignerMetadata()
            {
                
                NamespaceAliases = new List<MetadataNamespaceAlias>(),
                Types = new List<MetadataType>()
            };


            foreach (var asm in asms)
            {
                foreach (dynamic xmlns in asm.GetCustomAttributes().Where(a => a.GetType() == xmlNsAttr))
                {
                    rv.NamespaceAliases.Add(new MetadataNamespaceAlias
                    {
                        Namespace = (string)xmlns.ClrNamespace,
                        XmlNamespace = (string)xmlns.XmlNamespace
                    });
                }

                try
                {
                    foreach (var type in asm.GetTypes())
                    {
                        try
                        {
                            if (!type.IsPublic || type.IsAbstract)
                                continue;
                            var t = new MetadataType()
                            {
                                Name = type.Name,
                                Namespace = type.Namespace,
                                Properties = new List<MetadataProperty>()
                            };
                            rv.Types.Add(t);
                            foreach (var prop in type.GetProperties())
                            {
                                if (prop.GetMethod?.IsPublic != true)
                                    continue;
                                var p = new MetadataProperty()
                                {
                                    Name = prop.Name,
                                    Type =
                                        prop.PropertyType == typeof (string) ||
                                        (prop.PropertyType.IsValueType &&
                                         prop.PropertyType.Assembly == typeof (int).Assembly)
                                            ? MetadataPropertyType.BasicType
                                            : prop.PropertyType.IsEnum
                                                ? MetadataPropertyType.Enum
                                                : MetadataPropertyType.MetadataType

                                };
                                if (p.Type == MetadataPropertyType.Enum)
                                    p.EnumValues = Enum.GetNames(prop.PropertyType);
                                if (p.Type == MetadataPropertyType.MetadataType)
                                    p.MetadataFullTypeName = prop.PropertyType.Namespace + "." + prop.PropertyType.Name;
                                t.Properties.Add(p);
                            }
                        }
                        catch
                        {
                            //
                        }
                    }
                }
                catch
                {
                    //
                }
            }
            return rv;
        }
Exemple #4
0
 public UpdateMetadataMessage(PerspexDesignerMetadata metadata)
 {
     Metadata = metadata;
 }