public LinkedPropertyDescriptor(CustomPropertyDescriptor propertyDescriptor, LinkedDescriptorContextItem contextItem)
            : base(propertyDescriptor.EditingContext, propertyDescriptor.Component, propertyDescriptor.Name
                , PropertyWindowViewModelHelper.GetArrayFromCollection<Attribute>(propertyDescriptor.Attributes))
        {
            _wrappedCustomPropertyDescriptor = propertyDescriptor;
            _contextItem = contextItem;

            // Since we need to call the protected methods but we still want the methods to be remained protected in other cases, use the reflector to do so.
            _setEFElementValueMethod = typeof(CustomPropertyDescriptor).GetMethod(
                "SetEFElementValue", BindingFlags.Instance | BindingFlags.NonPublic);
            Debug.Assert(_setEFElementValueMethod != null, "Type CustomPropertyDescriptor does not have 'SetEFElementValue' method.");

            _resetEFElementValue = typeof(CustomPropertyDescriptor).GetMethod(
                "ResetEFElementValue", BindingFlags.Instance | BindingFlags.NonPublic);
            Debug.Assert(_resetEFElementValue != null, "Type CustomPropertyDescriptor does not have 'ResetEFElementValue' method.");
        }
        public LinkedPropertyDescriptor(CustomPropertyDescriptor propertyDescriptor, LinkedDescriptorContextItem contextItem)
            : base(propertyDescriptor.EditingContext, propertyDescriptor.Component, propertyDescriptor.Name
                   , PropertyWindowViewModelHelper.GetArrayFromCollection <Attribute>(propertyDescriptor.Attributes))
        {
            _wrappedCustomPropertyDescriptor = propertyDescriptor;
            _contextItem = contextItem;

            // Since we need to call the protected methods but we still want the methods to be remained protected in other cases, use the reflector to do so.
            _setEFElementValueMethod = typeof(CustomPropertyDescriptor).GetMethod(
                "SetEFElementValue", BindingFlags.Instance | BindingFlags.NonPublic);
            Debug.Assert(_setEFElementValueMethod != null, "Type CustomPropertyDescriptor does not have 'SetEFElementValue' method.");

            _resetEFElementValue = typeof(CustomPropertyDescriptor).GetMethod(
                "ResetEFElementValue", BindingFlags.Instance | BindingFlags.NonPublic);
            Debug.Assert(_resetEFElementValue != null, "Type CustomPropertyDescriptor does not have 'ResetEFElementValue' method.");
        }
 internal LinkedPropertyTypeDescriptor(ICustomTypeDescriptor customTypeDescriptor, LinkedDescriptorContextItem contextItem)
 {
     _wrappedCustomTypeDescriptor = customTypeDescriptor;
     _contextItem = contextItem;
     _contextItem.RegisterDescriptor(this);
 }
 internal LinkedPropertyTypeDescriptor(ICustomTypeDescriptor customTypeDescriptor, LinkedDescriptorContextItem contextItem)
 {
     _wrappedCustomTypeDescriptor = customTypeDescriptor;
     _contextItem = contextItem;
     _contextItem.RegisterDescriptor(this);
 }
        /// <summary>
        ///     The implementation of VsShell.ISelectionContainer.GetObjects in
        ///     ModelingWindowPane calls either GetSelectedObjects() or GetAllObjects()
        ///     - base calls to ModelingWindowPane
        /// </summary>
        /// <returns></returns>
        protected override void GetSelectedObjects(uint count, object[] objects)
        {
            // call the base class version first; objects will be populated with a
            // collection of DSL ModelElements
            base.GetSelectedObjects(count, objects);

            if (IsArtifactDesignerSafe() == false)
            {
                if (EdmUtils.ShouldShowByRefDebugHelpers())
                {
                    if (Context != null)
                    {
                        var artifact = EditingContextManager.GetArtifact(Context) as EntityDesignArtifact;
                        if (artifact != null)
                        {
                            // Show at least the EFEntityModelDescriptor so we can see the by-reference property extensions
                            // for the hydrated model
                            var descriptor =
                                (ObjectDescriptor)TypeDescriptor.CreateInstance(null, typeof(EFEntityModelDescriptor), null, null);
                            descriptor.Initialize(artifact.ConceptualModel, Context, true);
                            objects[0] = descriptor;
                        }
                    }
                }
                else
                {
                    for (var i = 0; i < objects.Length; i++)
                    {
                        objects[i] = null;
                    }
                }
            }
                // only show properties for single selection
            else
            {
                // now change this into an array of our item descriptors.
                var selectedModelObjects = ConvertDslModelElementArrayToItemDescriptors(objects, false);

                // if there are more than 1 selected object, convert the item descriptors to linked-item-descriptors.
                // This is so that property update can be done in 1 transaction.
                if (selectedModelObjects.Count > 1)
                {
                    var tempSelectedModelObjects = new ArrayList();
                    var contextItem = new LinkedDescriptorContextItem();
                    foreach (var customTypeDescriptor in selectedModelObjects.ToArray().OfType<ICustomTypeDescriptor>())
                    {
                        tempSelectedModelObjects.Add(new LinkedPropertyTypeDescriptor(customTypeDescriptor, contextItem));
                    }
                    selectedModelObjects = tempSelectedModelObjects;
                }

                // if the lengths are not the same, then there are items (like compartments)
                // that are being selected, so don't change the object array
                if (objects.Length == selectedModelObjects.Count)
                {
                    selectedModelObjects.CopyTo(objects, 0);
                }
            }
        }