/// <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);
        }
예제 #3
0
파일: Story.cs 프로젝트: KasumiL5x/novella
        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);
        }
예제 #5
0
        public Linkable popFront()
        {
            Linkable next = tail.next;

            if (next == tail)
            {
                return(null);
            }

            next.unlink();
            return(next);
        }
예제 #6
0
        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;
        }
예제 #7
0
        public void unlink()
        {
            if (previous == null)
            {
                return;
            }

            previous.next = next;
            next.previous = previous;
            next          = null;
            previous      = null;
        }
예제 #8
0
        public Linkable getPrevious()
        {
            Linkable node = current;

            if (node == tail)
            {
                current = null;
                return(null);
            }

            current = node.previous;
            return(node);
        }
예제 #9
0
        public Linkable peekBack()
        {
            Linkable node = tail.previous;

            if (node == tail)
            {
                current = null;
                return(null);
            }

            current = node.previous;
            return(node);
        }
예제 #10
0
        public Linkable peekFront()
        {
            Linkable node = tail.next;

            if (node == tail)
            {
                current = null;
                return(null);
            }

            current = node.next;
            return(node);
        }
예제 #11
0
        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;
            }
        }
예제 #12
0
        public Linkable getNext()
        {
            Linkable node = current;

            if (node == tail)
            {
                current = null;
                return(null);
            }

            current = node.next;
            return(node);
        }
예제 #13
0
        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();
        }
예제 #14
0
파일: Link.cs 프로젝트: KasumiL5x/novella
        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;
        }
예제 #15
0
        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);
        }
예제 #16
0
파일: Link.cs 프로젝트: KasumiL5x/novella
        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);
        }
예제 #17
0
        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;
        }
예제 #18
0
파일: Story.cs 프로젝트: KasumiL5x/novella
        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);
        }
예제 #19
0
        public void clear()
        {
            if (tail.next == tail)
            {
                return;
            }

            while (true)
            {
                Linkable next = tail.next;

                if (next == tail)
                {
                    return;
                }

                next.unlink();
            }
        }
예제 #20
0
        /// <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);
        }
예제 #21
0
 public DoubleEndedQueue()
 {
     tail          = new Linkable();
     tail.next     = tail;
     tail.previous = tail;
 }