Ejemplo n.º 1
0
 protected virtual void OnHidden(bool all)
 {
     if (!IsDisposed)
     {
         Linked.AsEnumerable().ForEach(g => g.OnLinkHidden(this));
     }
 }
Ejemplo n.º 2
0
    public static string ToString <T>(NodeLink <T> list)
    {
        var p = list;

        if (!Linked.IsCyclic(p))
        {
            var sb = new StringBuilder();
            sb.Append("[");
            while (p != null && p.Next != null)
            {
                if (p.Next.Value != null)
                {
                    sb.Append($"{p.Next.Value.ToString()},");
                }
                else
                {
                    sb.Append($"(null)");
                }
                p = p.Next;
            }
            if (sb[sb.Length - 1] != '[')
            {
                sb.Remove(sb.Length - 1, 1);
            }
            sb.Append("]");
            return(sb.ToString());
        }
        else
        {
            return("[cyclic]");
        }
    }
Ejemplo n.º 3
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Linked != false)
            {
                hash ^= Linked.GetHashCode();
            }
            if (Success.Length != 0)
            {
                hash ^= Success.GetHashCode();
            }
            if (Error.Length != 0)
            {
                hash ^= Error.GetHashCode();
            }
            if (ActiveAuthProviderId.Length != 0)
            {
                hash ^= ActiveAuthProviderId.GetHashCode();
            }
            if (Provider.Length != 0)
            {
                hash ^= Provider.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Ejemplo n.º 4
0
        protected virtual void OnSendFail()
        {
            if (IsDisposed)
            {
                return;
            }

            UnregisterInstance();

            if (Parent is SuperGump)
            {
                ((SuperGump)Parent).RemoveChild(this);
            }

            if (InstancePoller != null)
            {
                InstancePoller.Dispose();
                InstancePoller = null;
            }

            Linked.ForEachReverse(g => g.OnLinkSendFail(this));

            if (OnActionSend != null)
            {
                OnActionSend(this, false);
            }
        }
Ejemplo n.º 5
0
        protected virtual void OnRefreshed()
        {
            if (IsDisposed)
            {
                return;
            }

            LastAutoRefresh = DateTime.UtcNow;

            RegisterInstance();

            if (Parent is SuperGump)
            {
                ((SuperGump)Parent).AddChild(this);
            }

            if (InstancePoller == null)
            {
                InitPollTimer();
            }
            else if (!InstancePoller.Running)
            {
                InstancePoller.Running = EnablePolling;
            }

            Linked.AsEnumerable().ForEach(g => g.OnLinkRefreshed(this));
        }
Ejemplo n.º 6
0
        protected virtual void OnSend()
        {
            if (IsDisposed)
            {
                return;
            }

            LastAutoRefresh = DateTime.UtcNow;

            RegisterInstance();

            if (Parent is SuperGump)
            {
                ((SuperGump)Parent).AddChild(this);
            }

            if (InstancePoller == null)
            {
                InitPollTimer();
            }
            else
            {
                InstancePoller.Running = EnablePolling;
            }

            Linked.ForEachReverse(g => g.OnLinkSend(this));

            PlaySendSound();

            if (OnActionSend != null)
            {
                OnActionSend(this, true);
            }
        }
Ejemplo n.º 7
0
        internal async Task SetAddress(Linked linked)
        {
            linked.CurrentState = LinksStates.Detection;
            var link = await GetLink(linked.Address);

            if (link != null)
            {
                Selected(linked, link);
            }
            else
            {
                var links = await GetLinks(linked.Address);

                if (links == null || links.Count == 0)
                {
                    links.Add(new Link()
                    {
                        Name = linked.Address, XmlUrl = linked.Address, HtmlUrl = linked.Address
                    });
                }
                else
                {
                    links = links.Distinct(EqualityComparer <Link> .Default).OrderBy(n => n.XmlUrl.ToString().Length).ToList();
                }

                links.Add(new Link());
                linked.DetectedLinks = links;
                linked.CurrentState  = LinksStates.Selection;
                linked.IsNeedToSave  = true;
            }
        }
Ejemplo n.º 8
0
        protected virtual void OnSend()
        {
            if (IsDisposed)
            {
                return;
            }

            LastAutoRefresh = DateTime.UtcNow;

            RegisterInstance();

            if (Parent is SuperGump)
            {
                ((SuperGump)Parent).AddChild(this);
                Children.TrimExcess();
            }

            if (InstancePoller == null)
            {
                InitPollTimer();
            }
            else if (!InstancePoller.Running)
            {
                InstancePoller.Running = EnablePolling;
            }

            Linked.AsEnumerable().ForEach(g => g.OnLinkSend(this));
            Linked.TrimExcess();

            if (Modal && User != null && User.Holding != null)
            {
                Timer.DelayCall(TimeSpan.FromSeconds(1.0), User.DropHolding);
            }
        }
Ejemplo n.º 9
0
                #pragma warning restore 0414

        private GroupByContext(Lookup <K, T> lookup, bool release)
        {
            this.lookup  = lookup;
            this.release = release;
            this.runner  = lookup.keys.head;

            this.bd = BacktrackDetector.Borrow();
        }
Ejemplo n.º 10
0
                #pragma warning restore 0414

        private LinkedContext(LinkedHeadTail <T> list, BacktrackDetector bd, bool release)
        {
            this.list    = list;
            runner       = list.head;
            this.release = release;

            this.bd = bd;
        }
Ejemplo n.º 11
0
 public void AddLink(INode node)
 {
     if (!node.Linked.Contains(this))
     {
         node.Linked.Add(this);
         Linked.Add(node);
     }
 }
Ejemplo n.º 12
0
 public void RemoveLink(INode node)
 {
     if (node.Linked.Contains(this))
     {
         node.Linked.Remove(this);
         Linked.Remove(node);
     }
 }
Ejemplo n.º 13
0
        protected virtual void OnHidden(bool all)
        {
            if (IsDisposed)
            {
                return;
            }

            Linked.AsEnumerable().ForEach(g => g.OnLinkHidden(this));
            Linked.TrimExcess();
        }
Ejemplo n.º 14
0
 public void AddConnector(Id <TConnector> id)
 {
     if (!m_connectors.Any(c => c.Id == id))
     {
         ConnectorDefinitionData data = new ConnectorDefinitionData("", Id <TConnectorDefinition> .ConvertFrom(id), new List <NodeData.ParameterData>(), ConnectorPosition.Bottom);
         var connector = new Output(id, data, this, new List <Parameter>(), m_rules);
         connector.Connected    += (a) => Linked.Execute();
         connector.Disconnected += (a) => Linked.Execute();
         m_connectors.Add(connector);
     }
 }
Ejemplo n.º 15
0
    // `shift` (*remove value at front*).
    public T Shift()
    {
        if (First == null)
        {
            return(default(T));
        }

        var ret = First.Value;

        First = First.Child;
        return(ret);
    }
Ejemplo n.º 16
0
        public void Dispose()
        {
            if (IsDisposed)
            {
                return;
            }

            IsDisposed = true;

            //Console.WriteLine("SuperGump Disposing: {0} (0x{1:X})", GetType(), Serial);

            //GC.SuppressFinalize(this);

            VitaNexCore.TryCatch(OnDispose);

            VitaNexCore.TryCatch(UnregisterInstance);

            NextButtonID    = 1;
            NextSwitchID    = 0;
            NextTextInputID = 0;

            if (InstancePoller != null)
            {
                VitaNexCore.TryCatch(InstancePoller.Dispose);

                InstancePoller = null;
            }

            VitaNexCore.TryCatch(
                () =>
            {
                Buttons.Clear();
                TileButtons.Clear();
                Switches.Clear();
                Radios.Clear();
                TextInputs.Clear();
                LimitedTextInputs.Clear();
                Entries.Clear();
                Entries.TrimExcess();
                Layout.Clear();
            });

            VitaNexCore.TryCatch(() => Linked.AsEnumerable().ForEach(Unlink));
            VitaNexCore.TryCatch(() => Children.AsEnumerable().ForEach(RemoveChild));

            IsOpen = false;
            Hidden = false;

            Parent = null;
            User   = null;

            VitaNexCore.TryCatch(OnDisposed);
        }
Ejemplo n.º 17
0
    // `unshift` (*insert value at front*);
    public void Unshift(T value)
    {
        var add = new Linked <T>();

        add.Value = value;

        if (First != null)
        {
            add.Child = First;
        }

        First = add;
    }
Ejemplo n.º 18
0
        public virtual void Unlink(SuperGump gump)
        {
            if (gump == null)
            {
                return;
            }

            Linked.Remove(gump);

            if (gump.Linked.Contains(this))
            {
                gump.Unlink(this);
            }
        }
Ejemplo n.º 19
0
        public virtual void Link(SuperGump gump)
        {
            if (gump == null)
            {
                return;
            }

            Linked.AddOrReplace(gump);

            if (!gump.Linked.Contains(this))
            {
                gump.Link(this);
            }
        }
        public void MainTest()
        {
            using (Domain.OpenSession()) {
                using (var t = Session.Current.OpenTransaction()) {
                    var l  = new Linked(Guid.NewGuid());
                    var l2 = new Linked2(Guid.NewGuid())
                    {
                        Entity = l
                    };

                    l.Remove();
                    // Rollback
                }
            }
        }
Ejemplo n.º 21
0
                #pragma warning restore 0414

        private JoinContext(Lookup <K, T2> lookup, Slinq <T, C> outer, Func <T, K> outerSelector, Func <T, T2, U> resultSelector, bool release)
        {
            needsMove           = false;
            this.lookup         = lookup;
            this.outerSelector  = outerSelector;
            this.resultSelector = resultSelector;
            chained             = outer;
            this.release        = release;

            LinkedHeadTail <T2> iht;

            inner = chained.current.isSome && lookup.dictionary.TryGetValue(outerSelector(chained.current.value), out iht) ? iht.head : null;

            bd = BacktrackDetector.Borrow();
        }
Ejemplo n.º 22
0
        protected virtual void OnHidden(bool all)
        {
            if (IsDisposed)
            {
                return;
            }

            Linked.ForEachReverse(g => g.OnLinkHidden(this));

            PlayHideSound();

            if (OnActionHide != null)
            {
                OnActionHide(this, all);
            }
        }
Ejemplo n.º 23
0
    // `push` (*insert value at back*);
    public void Push(T value)
    {
        var set = new Linked <T>();

        set.Value = value;

        if (First == null)
        {
            First = set;
        }
        else
        {
            var last = GetLast(First);
            last.Child = set;
        }
    }
Ejemplo n.º 24
0
        protected virtual void OnClosed(bool all)
        {
            if (IsDisposed)
            {
                return;
            }

            UnregisterInstance();

            if (InstancePoller != null)
            {
                InstancePoller.Dispose();
                InstancePoller = null;
            }

            Linked.AsEnumerable().ForEach(g => g.OnLinkClosed(this));
        }
Ejemplo n.º 25
0
        public virtual void Link(SuperGump gump)
        {
            if (gump == null)
            {
                return;
            }

            if (!Linked.Contains(gump))
            {
                Linked.Add(gump);
            }

            if (!gump.Linked.Contains(this))
            {
                gump.Link(this);
            }
        }
Ejemplo n.º 26
0
        internal void Selected(Linked linked, Link link)
        {
            if (link?.XmlUrl != null)
            {
                if (linked.Links == null)
                {
                    linked.Links = new ObservableCollection <Link>();
                }

                linked.Links.Insert(0, link);
                linked.Address       = null;
                linked.DetectedLinks = null;
            }

            linked.CurrentState = LinksStates.Normal;
            linked.IsNeedToSave = true;
        }
Ejemplo n.º 27
0
    public static int Count <T>(NodeLink <T> list)
    {
        int counter = 0;
        var p       = list;

        if (!Linked.IsCyclic(list))
        {
            while (p != null && p.Next != null)
            {
                counter++;
                p = p.Next;
            }
        }
        else
        {
            throw new Exception("List is Cyclic.");
        }
        return(counter);
    }
Ejemplo n.º 28
0
        static void Main(string[] args)
        {
            var list = new SingleLinkedList();
            var l    = new Linked();

            l.insert(4);
            l.insert(4);
            l.insert(4);
            l.display();


            // list.insertLast(112);
            // list.insertLast(12);
            // list.insertLast(123);
            // list.insertLast(123);
            // list.removeLast();



            // list.display();
        }
Ejemplo n.º 29
0
    public static NodeLink <T> CycleNode <T>(NodeLink <T> list)
    {
        if (Linked.IsCyclic(list) == false)
        {
            return(default(NodeLink <T>));
        }
        NodeLink <T> fast     = list;
        NodeLink <T> slow     = list;
        NodeLink <T> prevfast = list;

        while (fast != null && fast.Next != null)
        {
            prevfast = fast;
            fast     = fast.Next.Next;
            slow     = slow.Next;
            if (fast == slow)
            {
                return(prevfast.Next);
            }
        }
        return(default(NodeLink <T>));
    }
Ejemplo n.º 30
0
        protected virtual void OnSendFail()
        {
            if (IsDisposed)
            {
                return;
            }

            UnregisterInstance();

            if (Parent is SuperGump)
            {
                ((SuperGump)Parent).RemoveChild(this);
            }

            if (InstancePoller != null)
            {
                InstancePoller.Dispose();
                InstancePoller = null;
            }

            Linked.AsEnumerable().ForEach(g => g.OnLinkSendFail(this));
        }