public RecursionTests() { boxWithKey = new Box(new List <IContainable>() { key }); }
public void Cook(IVegetable firstVegetable, IVegetable secondVegetable, IContainable bowl) { var areIngridientsAvaliable = (firstVegetable != null) && (secondVegetable != null) && (bowl != null); if (!areIngridientsAvaliable) { this.speachLog.Say("Oops, bad stuff happened with the ingredients!"); return; } this.PrepareVegetables(firstVegetable, secondVegetable); var isPreparationComplete = this.CheckIfVegetableIsReadyToCook(firstVegetable) && this.CheckIfVegetableIsReadyToCook(secondVegetable); if (isPreparationComplete) { bowl.Contents.Add(secondVegetable); bowl.Contents.Add(firstVegetable); this.speachLog.Say("Awesome we got ourselves vegetables in a bowl!"); } else { this.speachLog.Say("Oops, We Messed Up Brah!"); } }
private void AddItem(IContainable obj) { if (IsContainable()) { currentItems.Add(obj); } }
public virtual bool Place(GameObject gameObject) { IContainable container = gameObject.GetComponent <IContainable> (); if (container == null) { return(false); } IEnumerable <string> items = container.getItems().Select(item => item.name).OrderBy(x => x); if (!items.Any()) { return(false); } IEnumerable <string> order = new List <string> { "Water" }.OrderBy(x => x); Serve(items.SequenceEqual(order)); Destroy(gameObject); return(true); }
/// <summary>Export data according to shuffle definition in Definition to format Type</summary> /// <param name="container"></param> /// <param name="definition">Shuffle Definition</param> /// <param name="type">Type of target file</param> /// <param name="delimeter">Delimeter to use when exporting to Type: Text</param> /// <param name="ShuffleEventHandler">Event handler processing messages from the export. May be null.</param> /// <param name="defpath">Folder path for the shuffle definition file.</param> /// <param name="clearRemainingShuffleVars"></param> /// <param name="splitFiles">if true, it will split into seperate XmlDocuments for each record exported. </param> /// <returns>XmlDocument with exported data</returns> public static Dictionary <string, XmlDocument> QuickExport(IContainable container, XmlDocument definition, SerializationType type, char delimeter, EventHandler <ShuffleEventArgs> ShuffleEventHandler, string defpath, bool clearRemainingShuffleVars, bool splitFiles = false) { container.Logger.StartSection("QuickExport"); var shuffle = new Shuffler(container); if (ShuffleEventHandler != null) { shuffle.RaiseShuffleEvent += ShuffleEventHandler; } ShuffleHelper.VerifyShuffleVars(definition, clearRemainingShuffleVars); shuffle.Definition = definition; shuffle.definitionpath = defpath; var blocks = shuffle.ExportFromCRM(); Dictionary <string, XmlDocument> results; if (splitFiles) { results = shuffle.SplitFiles(blocks, type, delimeter); } else { results = new Dictionary <string, XmlDocument> { { string.Empty, shuffle.Serialize(blocks, type, delimeter) } }; } container.Logger.EndSection(); return(results); }
public ContentRegistration Add(IContainable containable) { Containables.Add(containable); containable.ContainerName = ContainerName; return(this); }
public void Add(IContainable item) { if (item != null) { Contents.Add(item); OnItemAdded?.Invoke(item, EventArgs.Empty); } }
public bool Remove(IContainable item) { if (Contents.Remove(item)) { OnItemRemoved?.Invoke(this, EventArgs.Empty); return(true); } return(false); }
protected virtual void Press(object sender, MouseEventArgs e) { IContainable c = Contents.GetItemAtPoint(e.Position); if (c != null) { if (c is IInteractive) { _pressedItem = (IInteractive)c; _pressedItem.Press(e); } } }
// // Files the Containable object (i.e. Document, CustomObject) in // specified Folder. // public IReferentialContainmentRelationship FileContainable(IContainable c, String folder) { IFolder f = Factory.Folder.FetchInstance(os, folder, null); IReferentialContainmentRelationship rcr = null; if (c is IDocument) { rcr = f.File((IDocument)c, AutoUniqueName.AUTO_UNIQUE, "DocEntryFile", DefineSecurityParentage.DO_NOT_DEFINE_SECURITY_PARENTAGE); } else { rcr = f.File((ICustomObject)c, AutoUniqueName.AUTO_UNIQUE, "DocEntryFile", DefineSecurityParentage.DO_NOT_DEFINE_SECURITY_PARENTAGE); } return(rcr); }
public override bool IsWithin(IContainable shape) { var topLeft = GetTopLeftPoint(); var topRight = GetTopRightPoint(); var bottomLeft = GetBottomLeftPoint(); var bottomRight = GetBottomRightPoint(); bool isWithin = ( shape.DoesContainThePoint(topLeft) && shape.DoesContainThePoint(topRight) && shape.DoesContainThePoint(bottomLeft) && shape.DoesContainThePoint(bottomRight) ); return(isWithin); }
public override bool IsWithin(IContainable shape) { var leftTip = new Location(Location.X - Radius, Location.Y); var rightTip = new Location(Location.X + Radius, Location.Y); var topTip = new Location(Location.X, Location.Y + Radius); var bottomTip = new Location(Location.X, Location.Y - Radius); bool isWithin = ( shape.DoesContainThePoint(leftTip) && shape.DoesContainThePoint(rightTip) && shape.DoesContainThePoint(topTip) && shape.DoesContainThePoint(bottomTip) ); return(isWithin); }
protected virtual void MoveStart(object sender, MouseEventArgs e) { IContainable c = Contents.GetItemAtPoint(e.Position); if (_movingItem == null && c != null) { if (c is IDraggable) { IDraggable movingItem = (IDraggable)c; if (movingItem.DragBounds.Contains(e.Position)) { _movingItem = (IDraggable)c; _movingItem.DragStart(e); } } } }
/// <summary>Export data according to shuffle definition in Definition to format Type</summary> /// <param name="container"></param> /// <param name="Definition">Shuffle Definition</param> /// <param name="Type">Type of target file</param> /// <param name="Delimeter">Delimeter to use when exporting to Type: Text</param> /// <param name="ShuffleEventHandler">Event handler processing messages from the export. May be null.</param> /// <param name="defpath">Folder path for the shuffle definition file.</param> /// <param name="clearRemainingShuffleVars"></param> /// <returns>XmlDocument with exported data</returns> public static XmlDocument QuickExport(IContainable container, XmlDocument Definition, SerializationType Type, char Delimeter, EventHandler <ShuffleEventArgs> ShuffleEventHandler, string defpath, bool clearRemainingShuffleVars) { container.Logger.StartSection("QuickExport"); var shuffle = new Shuffler(container); if (ShuffleEventHandler != null) { shuffle.RaiseShuffleEvent += ShuffleEventHandler; } ShuffleHelper.VerifyShuffleVars(Definition, clearRemainingShuffleVars); shuffle.Definition = Definition; shuffle.definitionpath = defpath; var blocks = shuffle.ExportFromCRM(); var result = shuffle.Serialize(blocks, Type, Delimeter); container.Logger.EndSection(); return(result); }
protected virtual void AddHeadlessChild(VisualElement element, IContainable <EvasObject> parent) { foreach (var child in (element as IVisualTreeElement).GetVisualChildren()) { if (child is VisualElement visualChild) { if (CompressedLayout.GetIsHeadless(visualChild)) { AddHeadlessChild(visualChild, parent); visualChild.IsPlatformEnabled = true; } else { var childRenderer = Platform.GetOrCreateRenderer(visualChild); parent.Children.Add(childRenderer.NativeView); } } } }
protected virtual void Click(object sender, MouseEventArgs e) { IContainable c = Contents.GetItemAtPoint(e.Position); if (_pressedItem != null) { if (c != null && c == _pressedItem) { _pressedItem.Click(e); _pressedItem = null; } } // if click was not on active item's effective bounds, // tell it there was a click if (_activatedItem != null) { _activatedItem.Click(e); } }
protected virtual void Hover(object sender, MouseEventArgs e) { IContainable c = Contents.GetItemAtPoint(e.Position); if (_hoveredItem != null) { if (_hoveredItem != (IContainable)c) { _hoveredItem.MouseOut(e); } } if (c != null) { if (c is IInteractive) { _hoveredItem = (IInteractive)c; _hoveredItem.MouseOver(e); } } }
void OnLayout() { var rect = _box.Geometry; Element.Layout(rect.ToDP()); _bgColorObject.Geometry = rect; _bgImageObject.Geometry = rect; _bgImageObject.StackAbove(_bgColorObject); EvasObject prev = _bgImageObject; IContainable <EvasObject> container = _box; foreach (var obj in container.Children) { obj.StackAbove(prev); prev = obj; } if (_actionButton != null) { var btnRect = _actionButton.Geometry; var btnW = Math.Max(_actionButton.MinimumWidth, btnRect.Width); var btnH = Math.Max(_actionButton.MinimumHeight, btnRect.Height); var btnX = (rect.Width - btnW) / 2; var btnY = rect.Height - btnH; _actionButton.Geometry = new Rect(btnX, btnY, btnW, btnH); _actionButton.StackAbove(prev); prev = _actionButton; } _surfaceLayout.Geometry = rect; _surfaceLayout.StackAbove(prev); prev = _surfaceLayout; if (_moreOption != null) { _moreOption.Geometry = Xamarin.Forms.Platform.Tizen.Forms.NativeParent.Geometry; _moreOption.StackAbove(prev); } }
void AddContainable(ItemDefinition definition, ContainableElement editable) { Type editableType = EnsureType <IEditable>(editable.Type); try { IContainable containable = Activator.CreateInstance(editableType) as IContainable; Utility.SetProperty(containable, "Name", editable.Name); Utility.SetProperty(containable, "Title", editable.Title); Utility.SetProperty(containable, "ContainerName", editable.ContainerName); Utility.SetProperty(containable, "SortOrder", editable.SortOrder); foreach (string key in editable.EditableProperties.Keys) { Utility.SetProperty(containable, key, editable.EditableProperties[key]); } definition.Add(containable); } catch (MissingMethodException ex) { throw new ConfigurationErrorsException("The type '" + editable.Type + "' defined in the configuration does not have a parameterless public constructor. This is required for the type to be configurable.", ex); } }
private IContainable FindItem(Func <IContainable, IContainable, bool> compare) { if (_contents.Count == 0) { return(default(IContainable)); } if (_contents.Count == 1) { return(_contents[0]); } IContainable found = _contents[0]; for (int i = 1; i < _contents.Count; i++) { if (compare(_contents[i], found)) { found = _contents[i]; } } return(found); }
public void CheckWithin(IContainable containableShape) { if (Shapes.Count == 0) { _writer.WriteLine("No shapes loaded!"); return; } bool isThereWithin = false; foreach (var shape in Shapes) { if (shape.IsWithin(containableShape)) { _writer.WriteLine(shape.ToString()); isThereWithin = true; } } if (!isThereWithin) { _writer.WriteLine("No shapes within the entered one!"); } }
public int CompareTo(IContainable other) { return this.SortOrder - other.SortOrder; }
int IComparable <IContainable> .CompareTo(IContainable other) { int delta = SortOrder - other.SortOrder; return(delta != 0 ? delta : Name.CompareTo(other.Name)); }
public int CompareTo(IContainable other) { return(this.SortOrder - other.SortOrder); }
/// <summary>Export data according to shuffle definition in Definition to format Type</summary> /// <param name="Definition">Shuffle Definition</param> /// <param name="Type">Type of target file</param> /// <param name="Delimeter">Delimeter to use when exporting to Type: Text</param> /// <param name="ShuffleEventHandler">Event handler processing messages from the export. May be null.</param> /// <param name="container"></param> /// <returns>XmlDocument with exported data</returns> public static XmlDocument QuickExport(XmlDocument Definition, SerializationType Type, char Delimeter, EventHandler <ShuffleEventArgs> ShuffleEventHandler, IContainable container) { return(QuickExport(Definition, Type, Delimeter, ShuffleEventHandler, container, null)); }
protected override void OnItemBoxContact(IContainable item) { ((ItemBox)item).Contact(this); }
private void HandleWallAction(WallActionType wallactiontype, WallOrientationType wallorientationtype, IContainable currentind) { switch (wallactiontype) { case Walls.WallActionType.Bounce: if(wallorientationtype == WallOrientationType.Vertical) { currentind.BounceXWall(); } else { currentind.BounceYWall(); } break; case Walls.WallActionType.Portal: if(wallorientationtype == WallOrientationType.Vertical) { currentind.TravelThroughXWall(); } else { currentind.TravelThroughYWall(); } break; } }
private void AddPropertyControlsRecursive(Control control, IContainable contained) { Control addedControl = contained.AddTo(control); if (contained is IEditor) PropertyControls.Add(contained.Name, addedControl); if (contained is IEditorContainer) foreach (IContainable subContained in ((IEditorContainer) contained).GetContained(Page.User)) AddPropertyControlsRecursive(addedControl, subContained); }
public void AddContained(IContainable containable) { _contained.Add(containable); _contained.Sort(); }
protected abstract void OnItemBoxContact(IContainable item);
public override bool IsWithin(IContainable shape) { bool isWithin = shape.DoesContainThePoint(Location) && shape.DoesContainThePoint(EndLocation); return(isWithin); }
/// <summary>Import data in Data according to shuffle definition in Definition</summary> /// <param name="Definition">Shuffle Definition</param> /// <param name="Data">Exported data</param> /// <param name="ShuffleEventHandler">Event handler processing messages from the import. May be null.</param> /// <param name="container"></param> /// <param name="defpath">Path to definition file, if not standard</param> /// <param name="clearRemainingShuffleVars"></param> /// <returns>Tuple with counters for: Created, Updated, Skipped and Failed records and a collection of entityreferences for the created/updated records</returns> public static Tuple <int, int, int, int, int, EntityReferenceCollection> QuickImport(XmlDocument Definition, XmlDocument Data, EventHandler <ShuffleEventArgs> ShuffleEventHandler, IContainable container, string defpath, bool clearRemainingShuffleVars) { container.Logger.StartSection("QuickImport"); Shuffler shuffle = new Shuffler(container); if (ShuffleEventHandler != null) { shuffle.RaiseShuffleEvent += ShuffleEventHandler; } ShuffleHelper.VerifyShuffleVars(Definition, clearRemainingShuffleVars); shuffle.Definition = Definition; shuffle.definitionpath = defpath; ShuffleBlocks blocks = shuffle.Deserialize(Data); Tuple <int, int, int, int, int, EntityReferenceCollection> result = shuffle.ImportToCRM(blocks); container.Logger.EndSection(); return(result); }
public void RemoveContained(IContainable containable) { this.ContainedEditors.Remove(containable); }
/// <summary>Adds an editor or sub-container definition to tihs container.</summary> /// <param name="subElement">The editor or sub-container to add.</param> public virtual void AddContained(IContainable subElement) { this.ContainedEditors.Add(subElement); this.ContainedEditors.Sort(); }
public void OnContentLeft(IContainable content) { if (Content == content) { Content = EmptyContent.Get(); //cType = Content.Type; } }
/// <summary>Checks whether the user is authorized to use a editable and has sufficient permissions.</summary> /// <param name="security">The security manager to query permissions on.</param> /// <param name="editorOrContainer">The editable containing security information.</param> /// <param name="user">The user to check permissions for.</param> /// <param name="item">The item to check permissions for.</param> /// <returns>True if the user is authorized for the given editable.</returns> public static bool IsAuthorized(this ISecurityManager security, IContainable editorOrContainer, IPrincipal user, ContentItem item) { return user != null && IsAuthorized(editorOrContainer, user, item) && IsPermitted(security, editorOrContainer, user, item); }
public void OnContentEntered(IContainable content) { Content = content; //cType = Content.Type; }
private IContainable ItemAt(int index) { IContainable item = index < currentItems.Count ? currentItems[index] : null; return(item); }
public int CompareTo(IContainable other) { throw new NotImplementedException(); }
public abstract bool IsWithin(IContainable shape);
/// <summary>General constructor for the Shuffler class</summary> /// <param name="container"></param> public Shuffler(IContainable container) { this.crmsvc = container.Service; this.log = container.Logger; }