Beispiel #1
0
        public PropertyDescriptor[] GetPropertyDescriptors(Type componentType, ComponentEditor componentEditor = null, object converter = null)
        {
            ComponentEditor editor = componentEditor != null ? componentEditor : VoidComponentEditor;

            IComponentDescriptor componentDescriptor;

            if (!ComponentDescriptors.TryGetValue(componentType, out componentDescriptor))
            {
                componentDescriptor = null;
            }

            if (componentDescriptor != null)
            {
                if (converter == null)
                {
                    converter = componentDescriptor.CreateConverter(editor);
                }

                PropertyDescriptor[] properties = componentDescriptor.GetProperties(editor, converter);
                return(properties);
            }
            else
            {
                if (componentType.IsScript())
                {
                    FieldInfo[] serializableFields = componentType.GetSerializableFields(false);
                    return(serializableFields.Select(f => new PropertyDescriptor(f.Name, editor.Component, f, f)).ToArray());
                }
                else
                {
                    PropertyInfo[] properties = componentType.GetProperties(BindingFlags.Instance | BindingFlags.Public).Where(p => p.CanRead && p.CanWrite).ToArray();
                    return(properties.Select(p => new PropertyDescriptor(p.Name, editor.Component, p, p)).ToArray());
                }
            }
        }
Beispiel #2
0
        internal void InitializeComponentsForRestore(IVssWriterComponents components)
        {
            // Erase the current list of components for this writer.
            ComponentDescriptors.Clear();

            // Enumerate the components from the BC document
            foreach (IVssComponent component in components.Components)
            {
                VssComponentDescriptor desc = new VssComponentDescriptor(m_host, this.WriterMetadata.WriterName, component);
                m_host.WriteLine("Found component available for restore: \"{0}\"", desc.FullPath);
                ComponentDescriptors.Add(desc);
            }
        }