/// <summary> /// Creates a CollectionSupport object with the contents specified in array. /// </summary> /// <param name="array">The array containing the elements used to populate the new CollectionSupport object.</param> /// <returns>A CollectionSupport object populated with the contents of array.</returns> public static CollectionSupport ToCollectionSupport(System.Object[] array) { CollectionSupport tempCollectionSupport = new CollectionSupport(); tempCollectionSupport.AddAll(array); return(tempCollectionSupport); }
public virtual bool CanEnterContainer(PlacementOperation operation) { if (ExtendedItem.ContentProperty.IsCollection) { return(CollectionSupport.CanCollectionAdd(ExtendedItem.ContentProperty.ReturnType, operation.PlacedItems.Select(p => p.Item.Component))); } if (ExtendedItem.View is ContentControl) { if (!CanContentControlAdd((ContentControl)ExtendedItem.View)) { return(false); } } if (!ExtendedItem.ContentProperty.IsSet) { return(true); } object value = ExtendedItem.ContentProperty.ValueOnInstance; // don't overwrite non-primitive values like bindings return(ExtendedItem.ContentProperty.Value == null && (value is string && string.IsNullOrEmpty(value as string))); }
[TestMethod] public void Collection() { Assert.AreEqual(loc1.Equals(loc2), true); Assert.AreEqual(loc1.Equals(loc3), false); Assert.AreEqual(list.Contains(loc1), true); Assert.AreEqual(list.Contains(loc2), true); Assert.AreEqual(CollectionSupport.ContainsObject(list, loc1), true); Assert.AreEqual(CollectionSupport.ContainsObject(list, loc2), false); }
private bool internalCanEnterContainer(PlacementOperation operation) { InfoTextEnterArea.Stop(ref infoTextEnterArea); if (ExtendedItem.Component is Expander) { if (!((Expander)ExtendedItem.Component).IsExpanded) { ((Expander)ExtendedItem.Component).IsExpanded = true; } } if (ExtendedItem.Component is UserControl && ExtendedItem.ComponentType != typeof(UserControl)) { return(false); } if (ExtendedItem.Component is Decorator) { return(((Decorator)ExtendedItem.Component).Child == null); } if (ExtendedItem.ContentProperty.IsCollection) { return(CollectionSupport.CanCollectionAdd(ExtendedItem.ContentProperty.ReturnType, operation.PlacedItems.Select(p => p.Item.Component))); } if (ExtendedItem.View is ContentControl) { if (!CanContentControlAdd((ContentControl)ExtendedItem.View)) { return(false); } } if (ExtendedItem.ContentProperty.ReturnType == typeof(string)) { return(false); } if (!ExtendedItem.ContentProperty.IsSet) { return(true); } object value = ExtendedItem.ContentProperty.ValueOnInstance; // don't overwrite non-primitive values like bindings return(ExtendedItem.ContentProperty.Value == null && (value is string && string.IsNullOrEmpty(value as string))); }
/// <summary> /// Removes all the elements that aren't contained into the specified collection. /// </summary> /// <param name="collection">The collection used to verify the elements that will be retained.</param> /// <returns>Returns true if all the elements were successfully removed. Otherwise returns false.</returns> public virtual bool RetainAll(ICollection collection) { bool result = false; IEnumerator tempEnumerator = this.GetEnumerator(); CollectionSupport tempCollection = new CollectionSupport(); tempCollection.AddAll(collection); while (tempEnumerator.MoveNext()) { if (!tempCollection.Contains(tempEnumerator.Current)) { result = this.Remove(tempEnumerator.Current); if (result == true) { tempEnumerator = this.GetEnumerator(); } } } return(result); }
/// <summary> /// Paste items from clipboard into the designer. /// </summary> public void Paste() { bool pasted = false; string combinedXaml = Clipboard.GetText(TextDataFormat.Xaml); IEnumerable <string> xamls = combinedXaml.Split(_delimeter); xamls = xamls.Where(xaml => xaml != ""); DesignItem parent = _context.Services.Selection.PrimarySelection; DesignItem child = _context.Services.Selection.PrimarySelection; XamlDesignItem rootItem = _context.RootItem as XamlDesignItem; var pastedItems = new Collection <DesignItem>(); foreach (var xaml in xamls) { var obj = XamlParser.ParseSnippet(rootItem.XamlObject, xaml, _settings); if (obj != null) { DesignItem item = _context._componentService.RegisterXamlComponentRecursive(obj); if (item != null) { pastedItems.Add(item); } } } if (pastedItems.Count != 0) { var changeGroup = _context.OpenGroup("Paste " + pastedItems.Count + " elements", pastedItems); while (parent != null && pasted == false) { if (parent.ContentProperty != null) { if (parent.ContentProperty.IsCollection) { if (CollectionSupport.CanCollectionAdd(parent.ContentProperty.ReturnType, pastedItems.Select(item => item.Component)) && parent.GetBehavior <IPlacementBehavior>() != null) { AddInParent(parent, pastedItems); pasted = true; } } else if (pastedItems.Count == 1 && parent.ContentProperty.Value == null && parent.ContentProperty.ValueOnInstance == null && parent.View is ContentControl) { AddInParent(parent, pastedItems); pasted = true; } if (!pasted) { parent = parent.Parent; } } else { parent = parent.Parent; } } while (pasted == false) { if (child.ContentProperty != null) { if (child.ContentProperty.IsCollection) { foreach (var col in child.ContentProperty.CollectionElements) { if (col.ContentProperty != null && col.ContentProperty.IsCollection) { if (CollectionSupport.CanCollectionAdd(col.ContentProperty.ReturnType, pastedItems.Select(item => item.Component))) { pasted = true; } } } break; } else if (child.ContentProperty.Value != null) { child = child.ContentProperty.Value; } else if (pastedItems.Count == 1) { child.ContentProperty.SetValue(pastedItems.First().Component); pasted = true; break; } else { break; } } else { break; } } foreach (var pastedItem in pastedItems) { _context._componentService.RaiseComponentRegisteredAndAddedToContainer(pastedItem); } changeGroup.Commit(); } }
/// <summary> /// Removes all the elements that aren't contained into the specified collection. /// </summary> /// <param name="collection">The collection used to verify the elements that will be retained.</param> /// <returns>Returns true if all the elements were successfully removed. Otherwise returns false.</returns> public virtual bool RetainAll(CollectionSupport collection) { return(this.RetainAll((System.Collections.ICollection)collection)); }
/// <summary> /// Removes all the elements that aren't contained into the specified collection. /// </summary> /// <param name="collection">The collection used to verify the elements that will be retained.</param> /// <returns>Returns true if all the elements were successfully removed. Otherwise returns false.</returns> public virtual bool RetainAll(CollectionSupport collection) { return this.RetainAll((System.Collections.ICollection) collection); }
/// <summary> /// Adds all the elements contained in the specified support class collection. /// </summary> /// <param name="collection">The collection used to extract the elements that will be added.</param> /// <returns>Returns true if all the elements were successfuly added. Otherwise returns false.</returns> public virtual bool AddAll(CollectionSupport collection) { return(this.AddAll((ICollection)collection)); }
/// <summary> /// Adds all the elements contained into the specified support class collection, starting at the specified position. /// </summary> /// <param name="index">Position at which to add the first element from the specified collection.</param> /// <param name="list">The list used to extract the elements that will be added.</param> /// <returns>Returns true if all the elements were successfuly added. Otherwise returns false.</returns> public virtual bool AddAll(int index, CollectionSupport collection) { return this.AddAll(index,(System.Collections.IList)collection); }
/// <summary> /// Removes all the elements that aren't contained into the specified collection. /// </summary> /// <param name="collection">The collection used to verify the elements that will be retained.</param> /// <returns>Returns true if all the elements were successfully removed. Otherwise returns false.</returns> public virtual bool RetainAll(System.Collections.ICollection collection) { bool result = false; System.Collections.IEnumerator tempEnumerator = this.GetEnumerator(); CollectionSupport tempCollection = new CollectionSupport(); tempCollection.AddAll(collection); while (tempEnumerator.MoveNext()) if (!tempCollection.Contains(tempEnumerator.Current)) { result = this.Remove(tempEnumerator.Current); if (result == true) { tempEnumerator = this.GetEnumerator(); } } return result; }
/// <summary> /// Creates a CollectionSupport object with the contents specified in array. /// </summary> /// <param name="array">The array containing the elements used to populate the new CollectionSupport object.</param> /// <returns>A CollectionSupport object populated with the contents of array.</returns> public static CollectionSupport ToCollectionSupport(System.Object[] array) { CollectionSupport tempCollectionSupport = new CollectionSupport(); tempCollectionSupport.AddAll(array); return tempCollectionSupport; }
/// <summary> /// Adds all the elements contained in the specified support class collection. /// </summary> /// <param name="collection">The collection used to extract the elements that will be added.</param> /// <returns>Returns true if all the elements were successfuly added. Otherwise returns false.</returns> public virtual bool AddAll(CollectionSupport collection) { return this.AddAll(this.Count,collection); }
/// <summary> /// Adds all the elements contained into the specified support class collection, starting at the specified position. /// </summary> /// <param name="index">Position at which to add the first element from the specified collection.</param> /// <param name="collection">The list used to extract the elements that will be added.</param> /// <returns>Returns true if all the elements were successfuly added. Otherwise returns false.</returns> public virtual bool AddAll(int index, CollectionSupport collection) { return(this.AddAll(index, (IList)collection)); }
/// <summary> /// Verifies if all the elements of the specified collection are contained into the current collection. /// </summary> /// <param name="collection">The collection used to extract the elements that will be verified.</param> /// <returns>Returns true if all the elements are contained in the collection. Otherwise returns false.</returns> public virtual bool ContainsAll(CollectionSupport collection) { return(this.ContainsAll((ICollection)collection)); }
public void LineBreakNoCollection() { var isCollection = CollectionSupport.IsCollectionType(typeof(LineBreak)); Assert.IsFalse(isCollection); }
/// <summary> /// Removes all the elements contained into the specified collection. /// </summary> /// <param name="collection">The collection used to extract the elements that will be removed.</param> /// <returns>Returns true if all the elements were successfuly removed. Otherwise returns false.</returns> public virtual bool RemoveAll(CollectionSupport collection) { return(this.RemoveAll((ICollection)collection)); }
/// <summary> /// Removes all the elements contained into the specified collection. /// </summary> /// <param name="collection">The collection used to extract the elements that will be removed.</param> /// <returns>Returns true if all the elements were successfuly removed. Otherwise returns false.</returns> public virtual bool RemoveAll(CollectionSupport collection) { return this.RemoveAll((ICollection) collection); }
/// <summary> /// Verifies if all the elements of the specified collection are contained into the current collection. /// </summary> /// <param name="collection">The collection used to extract the elements that will be verified.</param> /// <returns>Returns true if all the elements are contained in the collection. Otherwise returns false.</returns> public virtual bool ContainsAll(CollectionSupport collection) { return this.ContainsAll((ICollection) collection); }
/// <summary> /// Adds all the elements contained in the specified support class collection. /// </summary> /// <param name="collection">The collection used to extract the elements that will be added.</param> /// <returns>Returns true if all the elements were successfuly added. Otherwise returns false.</returns> public virtual bool AddAll(CollectionSupport collection) { return this.AddAll((ICollection) collection); }