/// <summary> /// Add a batch operation /// </summary> /// <param name="id"></param> /// <param name="sourceModel"></param> /// <param name="linkRel"></param> /// <param name="method"></param> /// <param name="requestModel"></param> /// <returns></returns> public BatchRequestBuilder AddOperation <T>(string id, Linkable sourceModel, string linkRel, string method, T requestModel) { string uri = GetUriFromLinkRelation(sourceModel, linkRel); this.AddOperation(id, "", uri, method, null, requestModel); return(this); }
/// <summary> /// Add a batch operation /// </summary> /// <param name="id"></param> /// <param name="description"></param> /// <param name="sourceModel"></param> /// <param name="linkRel"></param> /// <param name="method"></param> /// <param name="headers"></param> /// <param name="requestModel"></param> /// <returns></returns> public BatchRequestBuilder AddOperation <T>(string id, string description, Linkable sourceModel, string linkRel, string method, List <BatchOperationHeader> headers, T requestModel) { string uri = GetUriFromLinkRelation(sourceModel, linkRel); this.AddOperation(id, description, uri, method, headers, requestModel); return(this); }
public Link makeLink(Linkable origin, Linkable destination, Guid?id = null) { var link = new Link(id.HasValue ? id.Value : Guid.NewGuid(), origin, destination); _identifiables.Add(link); // Console.WriteLine(String.Format("Created Link ({0}).", link.ID.ToString())); return(link); }
private static string GetUriFromLinkRelation(Linkable sourceModel, string linkRel) { string uri = LinkRelations.FindLinkAsString(sourceModel.Links, linkRel); if (uri != null && uri.Contains("{")) { uri = uri.Substring(0, uri.IndexOf("{")); } return(uri); }
public Linkable popFront() { Linkable next = tail.next; if (next == tail) { return(null); } next.unlink(); return(next); }
public void pushFront(Linkable item) { if (item.previous != null) { item.unlink(); } item.previous = tail; item.next = tail.next; item.previous.next = item; item.next.previous = item; }
public void unlink() { if (previous == null) { return; } previous.next = next; next.previous = previous; next = null; previous = null; }
public Linkable getPrevious() { Linkable node = current; if (node == tail) { current = null; return(null); } current = node.previous; return(node); }
public Linkable peekBack() { Linkable node = tail.previous; if (node == tail) { current = null; return(null); } current = node.previous; return(node); }
public Linkable peekFront() { Linkable node = tail.next; if (node == tail) { current = null; return(null); } current = node.next; return(node); }
public LinkableHashMap(int size) { this.size = size; this.entries = new Linkable[size]; for (int i = 0; i < size; i++) { Linkable entry = new Linkable(); entry.next = entry; entry.previous = entry; entries[i] = entry; } }
public Linkable getNext() { Linkable node = current; if (node == tail) { current = null; return(null); } current = node.next; return(node); }
public Chain(Story story, Linkable start) { this._story = story; this._stalemate = false; this._finished = false; this._items = new List <Linkable>(); this._activeItemValidOutputs = new List <Link>(); this._previousHub = null; this._items.Add(start); start.addDelegate(this); start.tryActivate(); }
public void setDestination(Linkable dest) { if (dest != null && dest == _origin) { Console.WriteLine(String.Format("ERROR: Tried to set Link ({0}) destination to its origin ({1}).", _id.ToString(), dest.ID)); return; } var prevID = (null == _destination) ? "null" : _destination.ID.ToString(); var newID = (null == dest) ? "null" : dest.ID.ToString(); // Console.WriteLine(String.Format("Link ({0}) destination changed ({1} -> {2}).", _id.ToString(), prevID, newID)); _destination = dest; }
public Linkable get(long key) { Linkable start = entries[(int)(key & size - 1)]; for (Linkable next = start.next; next != start; next = next.next) { if (next.id == key) { return(next); } } return(null); }
public Link(Guid id, Linkable origin, Linkable destination) { this._id = id; this._origin = origin; if (null == origin || !origin.canBeOrigin()) { var originID = (null == origin) ? "null" : origin.ID.ToString(); Console.WriteLine(String.Format("ERROR: Link ({0}) has invalid origin ({1})!", id.ToString(), originID)); this._origin = null; } setDestination(destination); }
public void put(long key, Linkable item) { if (item.previous != null) { item.unlink(); } Linkable current = entries[(int)(key & size - 1)]; item.previous = current.previous; item.next = current; item.previous.next = item; item.next.previous = item; item.id = key; }
public List <Link> getValidOutputsFor(Linkable obj) { var result = new List <Link>(); foreach (var link in Links) { if (link.Origin == obj) { if (null == link.Condition || link.Condition.evaluate()) { result.Add(link); } } } return(result); }
public void clear() { if (tail.next == tail) { return; } while (true) { Linkable next = tail.next; if (next == tail) { return; } next.unlink(); } }
/// <summary> /// Gets the results of a request and converts them to a LIST /// </summary> /// <typeparam name="T">The type of list to be returned</typeparam> /// <param name="feed">The feed to be converted</param> /// <param name="fetchFullObject">Whether or not to fetch the full object(s) or just convert the feed to a list</param> /// <returns></returns> public static List <T> getFeedAsList <T>(Feed <T> feed, bool fetchFullObject) { List <T> list = new List <T>(); List <Entry <T> > entries = feed.Entries; foreach (Entry <T> entry in entries) { T content = entry.Content; T fullContent = default(T); { if (content is Linkable && fetchFullObject) { Linkable linkable = content as Linkable; if (linkable.Links.Count > 0) { Link self = LinkRelations.FindLink((content as Linkable).Links, LinkRelations.SELF.Rel); if (self == null) { self = (content as Linkable).Links[0]; } fullContent = feed.Client.Get <T>(self.Href, null); } else { fullContent = content; } } else { fullContent = content; } } if (content is Executable) { (fullContent as Executable).SetClient(feed.Client); } list.Add(fullContent); } return(list); }
public DoubleEndedQueue() { tail = new Linkable(); tail.next = tail; tail.previous = tail; }