Exemplo n.º 1
0
        // Called when a value is changed.
        protected override void SetValue(object sender, PropertySpecEventArgs e)
        {
            if (project == null)
            {
                return;
            }

            FieldInfo[] oFields;
            Type        oType = typeof(Options);

            oFields = oType.GetFields(BindingFlags.Public | BindingFlags.Instance);

            // Loop through all the fields in the 'Options' class.
            for (int i = 0; i < oFields.Length; i++)
            {
                // If the current field is not an option, ignore it.
                if (!oFields[i].FieldType.IsSubclassOf(typeof(OptionBase)))
                {
                    continue;
                }

                List <Attribute>    attrs = AttributeUtility.GetAllAttributes(oFields[i], false);
                OptionNameAttribute oname = (OptionNameAttribute)AttributeUtility.GetAttribute <OptionNameAttribute>(attrs);
                string name = (oname != null) ? oname.OptionName : "";

                if (e.Property.Name == name)
                {
                    oFields[i].SetValue(pOptions, e.Value);

                    return;
                }
            }
        }
Exemplo n.º 2
0
        /*=== construction ===*/

        public OptionInfo(List <Attribute> attrs)
        {
            /*=== name ===*/

            OptionNameAttribute name = (OptionNameAttribute)AttributeUtility.GetAttribute <OptionNameAttribute>(attrs);

            if (name != null)
            {
                Name = name.OptionName;
            }

            /*=== is global ===*/

            IsGlobalOptionAttribute isGlobal = (IsGlobalOptionAttribute)AttributeUtility.GetAttribute <IsGlobalOptionAttribute>(attrs);

            if (isGlobal != null)
            {
                IsGlobal = true;
            }

            /*=== is project ===*/

            IsProjectOptionAttribute isProject = (IsProjectOptionAttribute)AttributeUtility.GetAttribute <IsProjectOptionAttribute>(attrs);

            if (isProject != null)
            {
                IsProject = true;
            }

            /*=== category ===*/

            OptionCategoryAttribute category = (OptionCategoryAttribute)AttributeUtility.GetAttribute <OptionCategoryAttribute>(attrs);

            if (category != null)
            {
                Category = category.OptionCategory;
            }

            /*=== description ===*/

            OptionDescriptionAttribute description = (OptionDescriptionAttribute)AttributeUtility.GetAttribute <OptionDescriptionAttribute>(attrs);

            if (description != null)
            {
                Description = description.OptionDescription;
            }

            /*=== editor type ===*/

            OptionEditorTypeAttribute editorType = (OptionEditorTypeAttribute)AttributeUtility.GetAttribute <OptionEditorTypeAttribute>(attrs);

            if (editorType != null)
            {
                EditorType = editorType.OptionEditorType.AssemblyQualifiedName;
            }

            /*=== global type converter ===*/

            GlobalOptionTypeConverterAttribute globalTypeConverter = (GlobalOptionTypeConverterAttribute)AttributeUtility.GetAttribute <GlobalOptionTypeConverterAttribute>(attrs);

            if (globalTypeConverter != null)
            {
                GlobalTypeConverter = globalTypeConverter.OptionTypeConverter.AssemblyQualifiedName;
            }

            /*=== project type converter ===*/

            ProjectOptionTypeConverterAttribute projectTypeConverter = (ProjectOptionTypeConverterAttribute)AttributeUtility.GetAttribute <ProjectOptionTypeConverterAttribute>(attrs);

            if (projectTypeConverter != null)
            {
                ProjectTypeConverter = projectTypeConverter.OptionTypeConverter.AssemblyQualifiedName;
            }

            /*=== command line converter ===*/

            CommandLineAttribute commandLine = (CommandLineAttribute)AttributeUtility.GetAttribute <CommandLineAttribute>(attrs);

            if (commandLine != null)
            {
                CommandLine = commandLine.CommandLine;
            }
        }