private static WorkItemLinkAttribute PropertyInfoLinkTypeCache(
     IPropertyInspector inspector,
     PropertyInfo property)
 {
     return(PropertyInfoFields.GetOrAdd(
                property,
                info => inspector.GetAttribute <WorkItemLinkAttribute>(property)));
 }
 // <summary>
 // Writes the attached property OwningPropertyInspector to the given element.
 // </summary>
 // <param name="d">The element to which to write the attached property.</param>
 // <param name="value">The property value to set</param>
 public static void SetOwningPropertyInspectorModel(DependencyObject dependencyObject, IPropertyInspector value)
 {
     if (dependencyObject == null)
     {
         throw FxTrace.Exception.ArgumentNull("dependencyObject");
     }
     dependencyObject.SetValue(PropertyInspectorHelper.OwningPropertyInspectorModelProperty, value);
 }
예제 #3
0
 protected SceneNodeObjectSet(IPropertyInspector transactionContext)
 {
     if (transactionContext == null)
     {
         throw new ArgumentNullException("transactionContext");
     }
     this.transactionContext = transactionContext;
 }
        // --------------------------------------------------------------------

        private void OnObjectPropertyInspectorChanged(object s, PropertyValueChangedEventArgs e)
        {
            PropertyGrid       propGrid  = s as PropertyGrid;
            IPropertyInspector inspector = propGrid.SelectedObject as IPropertyInspector;

            propGrid.Refresh();
            inspector.Apply();
            InspectorChanged?.Invoke(this, e);
        }
        internal SelectedElementsObjectSet(DesignerContext designerContext, IPropertyInspector transactionContext)
            : base(designerContext, transactionContext)
        {
            ObservableCollection <SystemResourceModel> systemResources = this.SystemResources;

            this.DesignerContext.SelectionManager.EarlyActiveSceneUpdatePhase += new SceneUpdatePhaseEventHandler(this.SelectionManager_EarlyActiveSceneUpdatePhase);
            this.DesignerContext.SelectionManager.LateActiveSceneUpdatePhase  += new SceneUpdatePhaseEventHandler(this.SelectionManager_LateActiveSceneUpdatePhase);
            this.SetActiveViewModel(designerContext.ActiveSceneViewModel);
        }
예제 #6
0
        private void CategoryContainer_Loaded(object sender, RoutedEventArgs e)
        {
            IPropertyInspector propertyInspectorModel = PropertyInspectorHelper.GetOwningPropertyInspectorModel((DependencyObject)this);

            if (propertyInspectorModel == null || CategoryContainer.GetPopupHost((DependencyObject)this) != null)
            {
                return;
            }
            this.Category.Expanded = propertyInspectorModel.IsCategoryExpanded(this.Category.get_CategoryName());
        }
예제 #7
0
 public AnnotatedPropertyValidator([NotNull] IPropertyInspector inspector)
 {
     _inspector            = inspector ?? throw new ArgumentNullException(nameof(inspector));
     PropertyInfoValidator = (item, info) =>
     {
         var name      = GetFieldDefinition(info)?.FieldName;
         var validName = !string.IsNullOrWhiteSpace(name);
         return(validName && item.Fields.Contains(name));
     };
 }
        public SimpleInspectorCategory(CCategoryInfo info, IPropertyInspector inspector)
            : base(info.Priority)
        {
            InitializeComponent();

            m_inspector    = inspector;
            m_propertyGrid = PropertyGrid;
            m_leftColumn   = LeftColumn;
            m_rightColumn  = RightColumn;
        }
예제 #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BulkIdentityAwareAttributeMapperStrategy"/> class.
        /// </summary>
        /// <param name="inspector">The inspector.</param>
        /// <param name="identityValueConverter">The identity value converter.</param>
        /// <exception cref="ArgumentNullException">inspector</exception>
        /// <autogeneratedoc />
        public BulkIdentityAwareAttributeMapperStrategy(
            IPropertyInspector inspector,
            IIdentityValueConverter <string, object> identityValueConverter
            )
        {
            Contract.Requires(inspector != null);
            Contract.Requires(identityValueConverter != null);

            _inspector = inspector ?? throw new ArgumentNullException(nameof(inspector));
            _displayNameToAliasValueConverter = identityValueConverter ?? throw new ArgumentNullException(nameof(identityValueConverter));
        }
예제 #10
0
        private bool IsStrongTypeId(IPropertyInspector propertyInspector)
        {
            var systemType = propertyInspector.Type.GetUnderlyingSystemType();

            if (systemType is null)
            {
                return(false);
            }

            return(StrongTypeIdHelper.IsStrongTypeId(systemType));
        }
예제 #11
0
        public ExpandableInspectorCategory(CCategoryInfo info, IPropertyInspector inspector)
            : base(info.Priority)
        {
            InitializeComponent();

            Expander.Header = info.Name;

            m_inspector    = inspector;
            m_propertyGrid = PropertyGrid;
            m_leftColumn   = LeftColumn;
            m_rightColumn  = RightColumn;
        }
        // --------------------------------------------------------------------

        private PropertyGrid CreatePropertyInspector(IPropertyInspector obj)
        {
            PropertyGrid propGrid = new PropertyGrid();

            propGrid.SelectedObject        = obj;
            propGrid.PropertyValueChanged += OnObjectPropertyInspectorChanged;
            propGrid.HelpVisible           = false;
            propGrid.Width          = this.Width;
            propGrid.ToolbarVisible = false;
            propGrid.Height         = obj.GetInspectorHeight();
            return(propGrid);
        }
예제 #13
0
        private void CategoryContainer_Loaded(object sender, RoutedEventArgs e)
        {
            IPropertyInspector owningPI = PropertyInspectorHelper.GetOwningPropertyInspectorModel(this);

            if (owningPI != null)
            {
                if (CategoryContainer.GetPopupHost(this) == null)
                {
                    this.Expanded = owningPI.IsCategoryExpanded(this.Category.CategoryName);
                }
            }
        }
예제 #14
0
    private bool Check(IPropertyInspector inspector)
    {
        //walkaround:
        //this convention causes problems with Components - creates columns like Issue`Id` so we apply it only to entities
        var type = inspector.EntityType;

        if (!(type.IsSubclassOf(typeof(Entity)) || type.IsSubclassOf(typeof(GlossaryEntity))))
        {
            return(false);
        }
        return(true);
    }
        private static IEnumerable <PropertyInfo> PropertiesOnWorkItemCache(
            IPropertyInspector inspector,
            IWorkItem workItem,
            Type targetType,
            Type attributeType)
        {
            // Composite key: work item type and target type

            var workItemType = workItem.Type.Name;
            var key          = new Tuple <string, RuntimeTypeHandle>(workItemType, targetType.TypeHandle);

            return(PropertiesThatExistOnWorkItem.GetOrAdd(
                       key,
                       tuple => inspector.GetAnnotatedProperties(targetType, attributeType).ToList()));
        }
예제 #16
0
        private static IEnumerable <PropertyInfo> PropertiesOnWorkItemCache(IPropertyInspector inspector, IWorkItem workItem, Type targetType, Type attributeType)
        {
            // Composite key: work item type and target type

            var workItemType = workItem.Type.Name;
            var key          = new Tuple <string, RuntimeTypeHandle>(workItemType, targetType.TypeHandle);

            return(PropertiesThatExistOnWorkItem.GetOrAdd(
                       key,
                       tuple =>
            {
                return
                inspector.GetAnnotatedProperties(targetType, typeof(FieldDefinitionAttribute))
                .Select(
                    property =>
                    new { property, fieldName = PropertyInfoFieldCache(inspector, property)?.FieldName })
                .Where(
                    @t =>
                    !string.IsNullOrEmpty(@t.fieldName) && workItem.Fields.Contains(@t.fieldName))
                .Select(@t => @t.property)
                .ToList();
            }));
        }
예제 #17
0
 /// <summary>
 /// Creates a new instance of <see cref="AttributeMapperStrategy"/> with a <see cref="AnnotatedPropertyValidator"/> using the specified <paramref name="inspector"/> and <paramref name="typeParser"/>.
 /// </summary>
 /// <param name="inspector">An instance of <see cref="IPropertyInspector"/>.</param>
 /// <param name="typeParser">An instance of <see cref="ITypeParser"/>.</param>
 public AttributeMapperStrategy([NotNull] IPropertyInspector inspector, [NotNull] ITypeParser typeParser)
     : this(new AnnotatedPropertyValidator(inspector), typeParser)
 {
 }
 public WorkItemLinksMapperStrategy(IPropertyInspector inspector, IWorkItemStore store)
 {
     _inspector = inspector;
     Store      = store;
 }
예제 #19
0
 public static void SetOwningPropertyInspectorModel(DependencyObject dependencyObject, IPropertyInspector value)
 {
     if (dependencyObject == null)
     {
         throw new ArgumentNullException("dependencyObject");
     }
     dependencyObject.SetValue(PropertyInspectorHelper.OwningPropertyInspectorModelProperty, value);
 }
예제 #20
0
        public EditResourceModel(DesignerContext designerContext, DictionaryEntryNode resourceEntryNode, IPropertyInspector transactionContext)
        {
            this.designerContext   = designerContext;
            this.resourceEntryNode = resourceEntryNode;
            object       key = resourceEntryNode.Key;
            DocumentNode expression;

            if ((expression = key as DocumentNode) != null)
            {
                this.keyString = XamlExpressionSerializer.GetStringFromExpression(expression, resourceEntryNode.DocumentNode);
            }
            else if ((this.keyString = key as string) == null)
            {
                this.keyString = key.ToString();
            }
            this.keyStringIsValid = true;
            ResourceEntryItem resource = (ResourceEntryItem)this.designerContext.ResourceManager.GetResourceItem((DocumentCompositeNode)resourceEntryNode.DocumentNode);

            this.resourceObjectSet = new ResourceValueObjectSet(resource, designerContext, transactionContext);
            this.standInProperty   = this.resourceObjectSet.CreateProperty(new PropertyReference((ReferenceStep)this.resourceObjectSet.ProjectContext.ResolveProperty(DictionaryEntryNode.ValueProperty)), TypeUtilities.GetAttributes(resource.EffectiveType));
            this.standInProperty.PropertyValue.PropertyValueException += new EventHandler <PropertyValueExceptionEventArgs>(this.OnPropertyValueException);
            this.standInProperty.PropertyValue.PropertyChanged        += new PropertyChangedEventHandler(this.OnValuePropertyChanged);
        }
예제 #21
0
 public BulkIdentityAwareAttributeMapperStrategy(IPropertyInspector inspector, IIdentityManagementService identityManagementService)
 {
     _inspector = inspector;
     _identityManagementService = identityManagementService;
 }
예제 #22
0
 public ResourceValueObjectSet(ResourceEntryItem resource, DesignerContext designerContext, IPropertyInspector transactionContext)
     : base(designerContext, transactionContext)
 {
     this.resource        = resource;
     this.designerContext = designerContext;
 }
예제 #23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BulkIdentityAwareAttributeMapperStrategy" /> class.
 /// </summary>
 /// <param name="inspector">The inspector.</param>
 /// <param name="identityManagementService">The identity management service.</param>
 /// <exception cref="ArgumentNullException">
 /// inspector
 /// or
 /// identityManagementService
 /// </exception>
 public BulkIdentityAwareAttributeMapperStrategy(IPropertyInspector inspector, IIdentityManagementService identityManagementService)
     : this(inspector, new IdentityFieldValueConverter(identityManagementService))
 {
 }
예제 #24
0
 internal SceneNodeObjectSetBase(DesignerContext designerContext, IPropertyInspector transactionContext)
     : base(transactionContext)
 {
     this.designerContext = designerContext;
     this.designerContext.SelectionManager.LateActiveSceneUpdatePhase += new SceneUpdatePhaseEventHandler(this.SelectionManager_LateActiveSceneUpdatePhase);
 }
 public void CreateDsl()
 {
     mapping = new PropertyMapping();
     inspector = new PropertyInspector(mapping);
 }
예제 #26
0
 private static FieldDefinitionAttribute PropertyInfoFieldCache(IPropertyInspector inspector, PropertyInfo property)
 {
     return(PropertyInfoFields.GetOrAdd(
                property,
                info => inspector.GetAttribute <FieldDefinitionAttribute>(property)));
 }
 public bool Accept(IPropertyInspector propertyMapping)
 {
     return propertyMapping.Type == typeof(string) &&
         propertyMapping.Property.Name.ToLower() == "description";
 }
예제 #28
0
 private static bool IsEnum(IPropertyInspector pi)
 {
     return(pi.Property.PropertyType.IsEnum);
 }
예제 #29
0
 private static bool IsNullableEnum(IPropertyInspector pi)
 {
     return(pi.Property.PropertyType.IsGenericType &&
            pi.Property.PropertyType.GetGenericTypeDefinition() == typeof(Nullable <>) &&
            pi.Property.PropertyType.GetGenericArguments().Single().IsEnum);
 }
예제 #30
0
        internal static Dictionary <string, List <PropertyInfo> > GetWorkItemIdentityFieldNameToIdentityPropertyMap(Type targetWorkItemType, IPropertyInspector propertyInspector)
        {
            var hashtable = IdentityPropertyTypeMap;
            var props     = (Dictionary <string, List <PropertyInfo> >)hashtable[targetWorkItemType];

            if (props != null)
            {
                return(props);
            }

            lock (hashtable)
            {
                var identityProperties =
                    propertyInspector.GetAnnotatedProperties(targetWorkItemType, typeof(IdentityFieldAttribute));
                props = new Dictionary <string, List <PropertyInfo> >(StringComparer.OrdinalIgnoreCase);
                foreach (var identityProperty in identityProperties)
                {
                    var witFieldName = propertyInspector.GetAttribute <FieldDefinitionAttribute>(identityProperty)
                                       ?.FieldName;
                    if (string.IsNullOrEmpty(witFieldName) || !identityProperty.CanWrite)
                    {
                        continue;
                    }

                    if (!props.ContainsKey(witFieldName))
                    {
                        props.Add(witFieldName, new List <PropertyInfo>());
                    }
                    props[witFieldName].Add(identityProperty);
                }

                hashtable[targetWorkItemType] = props;
                return(props);
            }
        }
 public void Init(IPropertyInspector inspector)
 {
     m_inspector = inspector;
 }
예제 #32
0
 public AttributeMapperStrategy(IPropertyInspector inspector, ITypeParser typeParser)
 {
     _inspector  = inspector;
     _typeParser = typeParser;
 }
예제 #33
0
        internal static IDictionary <string, PropertyInfo> GetWorkItemIdentityFieldNameToIdentityPropertyMap(Type targetWorkItemType, IPropertyInspector propertyInspector)
        {
            var identityProperties = propertyInspector.GetAnnotatedProperties(targetWorkItemType, typeof(IdentityFieldAttribute));

            return
                (identityProperties
                 .Select(
                     p =>
                     new
            {
                IdentityProperty = p,
                WitFieldName = propertyInspector.GetAttribute <FieldDefinitionAttribute>(p)?.FieldName
            })
                 .Where(p => !string.IsNullOrEmpty(p.WitFieldName) && p.IdentityProperty.CanWrite)
                 .ToDictionary(x => x.WitFieldName, x => x.IdentityProperty));
        }