private DesignProperty GetInternalProperty(object component)
        {
            var designDescriptor = new DesignPropertyDescriptor(
                descriptor.Name,
                descriptor.PropertyType,
                descriptor.ComponentType,
                descriptor.Attributes.OfType <Attribute>().ToArray());

            var property = (DesignProperty)designDescriptor.GetValue(component);

            return(property);
        }
Esempio n. 2
0
        private static string GetAuthoringTemplateProperty(ITypeDescriptorContext context)
        {
            var templateSettings = context.Instance as ITemplateSettings;
            var commandSettings = context.Instance as ICommandSettings;

            if (templateSettings != null)
            {
                return templateSettings.TemplateAuthoringUri;
            }
            else if (commandSettings != null)
            {
                // Make up the design property descriptor to persist the authoring value.
                var descriptor = new DesignPropertyDescriptor(
                    Reflector<UnfoldVsTemplateCommand>.GetPropertyName(c => c.TemplateAuthoringUri),
                    typeof(string),
                    typeof(CommandSettings),
                    new Attribute[0]);

                var prop = (DesignProperty)descriptor.GetValue(commandSettings);
                return prop.GetValue().ToString();
            }

            return null;
        }
Esempio n. 3
0
        private static void SetAuthoringUri(ITypeDescriptorContext context, Uri uri)
        {
            var templateSettings = context.Instance as ITemplateSettings;
            var commandSettings = context.Instance as ICommandSettings;

            if (templateSettings != null)
            {
                templateSettings.TemplateAuthoringUri = uri.AbsoluteUri;
            }
            else if (commandSettings != null)
            {
                // Make up the design property descriptor to persist the authoring value.
                var descriptor = new DesignPropertyDescriptor(
                    Reflector<UnfoldVsTemplateCommand>.GetPropertyName(c => c.TemplateAuthoringUri),
                    typeof(string),
                    typeof(CommandSettings),
                    new Attribute[0]);

                var prop = (DesignProperty)descriptor.GetValue(commandSettings);
                prop.SetValue(uri.AbsoluteUri);
            }
        }
        /// <summary>
        /// Retrieves the current property from storage.
        /// </summary>
        protected virtual IPropertyBindingSettings GetPropertySettings(object component)
        {
            var settings = component as T;

            return((settings != null) ? DesignPropertyDescriptor.EnsurePropertySettings(component, this.Name, this.PropertyType) : null);
        }
        private static DesignProperty GetAuthoringTemplateProperty(ITypeDescriptorContext context)
        {
            var commandSettings = context.Instance as ICommandSettings;
            if (commandSettings != null)
            {
                // Make up the design property descriptor to access the authoring value.
                var descriptor = new DesignPropertyDescriptor(
                    Reflector<GenerateModelingCodeCommand>.GetPropertyName(c => c.TemplateAuthoringUri),
                    typeof(string),
                    typeof(CommandSettings),
                    new Attribute[0]);

                return (DesignProperty)descriptor.GetValue(commandSettings);
            }

            return null;
        }