Ejemplo n.º 1
0
        public async void Update(Node.Node Node)
        {
            while (this.locked)
            {
                await Task.Delay(1);
            }

            this.locked = true;

            Node.TopologyId = TopologyId;


            Node.Node existingNode = Nodes.Find(n => n.IgpRouterIdentifier == Node.IgpRouterIdentifier);

            if (existingNode == null && Node.OperationalStatus)
            {
                Nodes.Add(Node);
            }
            else
            {
                if (Node.OperationalStatus)
                {
                    Nodes[Nodes.IndexOf(existingNode)] = Node;
                }
                else
                {
                    Nodes.Remove(existingNode);
                }
            }

            this.OnNodeUpdateCallback?.Invoke(Node);

            this.locked = false;
        }
Ejemplo n.º 2
0
        private static void unToggleEventsThatAreTooClose(DateTime time)
        {
            for (int i = 0; i < toggledNodes.Count; i++)
            {
                ToggleButton button = toggledNodes[i];

                if (button.GetType() == typeof(Node.Node))
                {
                    Node.Node node      = (Node.Node)button;
                    DateTime  nodesTime = node.GetBlockTime();
                    if (EventIsTooClose(nodesTime, time))
                    {
                        node.ToggleBlock();
                        toggledNodes.Remove(node);
                        i--;
                    }
                }
                else if (button.GetType() == typeof(StackedNodes))
                {
                    StackedNodes node      = (StackedNodes)button;
                    DateTime     nodesTime = node.GetBlockTime();
                    if (EventIsTooClose(nodesTime, time))
                    {
                        node.ToggleBlock();
                        toggledNodes.Remove(node);
                        i--;
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public DataChain(int chainId, uint chainIndex, Node.Node node, CoreChain coreChain, ServiceChain serviceChain, ChainKeyStore keyStore, int attachementKey) : base(ChainType.Data, chainId, chainIndex, node)
        {
            _coreChain    = coreChain;
            _serviceChain = serviceChain;
            Attachements  = node.AttachementManager;

            ChainKeyIndex = keyStore.KeyIndex;
            ChainKey      = keyStore.DecryptedKey;
            KeyStore      = keyStore;

            AttachementKey = attachementKey;

            var endPoints = new HashSet <AvailableEndPoint>();

            var chainInfo = _coreChain.GetChainInfo(ChainId);

            if (chainInfo != null)
            {
                var cep = chainInfo.GetPublicEndpoints();
                foreach (var ep in cep)
                {
                    var e = new Uri(ep);
                    if (IsValidAvailableEndPoint(e))
                    {
                        endPoints.Add(new AvailableEndPoint(e));
                    }
                }
            }

            AvailableEndpoints = new List <AvailableEndPoint>(endPoints);
        }
        private object FetchValue(Element item, string attributeName, string elementName, string query,
                                  bool arePersistentObjects, bool attach, TypeCache typeCache, TypeConverter typeConverter, Cache cache)
        {
            object value = null;

            if (!String.IsNullOrEmpty(attributeName))
            {
                Node.Attribute attribute = item.Attribute(attributeName);
                value = attribute == null ? null : GetObjectFromString(attribute.Value, null, null, typeCache.Type, typeConverter);
            }
            else
            {
                object result = !String.IsNullOrEmpty(query) ? item.EvalSingle(query)
                    : item.Children.OfType <Element>().FirstOrDefault(e => e.Name.Equals(elementName));
                if (arePersistentObjects)
                {
                    // Get, attach, and fetch the persistent object instance
                    Element element = result as Element;
                    if (element == null)
                    {
                        throw new Exception("Persistent value node must be an element.");
                    }
                    value = cache.GetObject(typeCache, element, attach);
                }
                else
                {
                    Node.Node itemNode = result as Node.Node;
                    value = GetObjectFromString(itemNode != null ? itemNode.Value
                        : result == null ? null : result.ToString(), null, null, typeCache.Type, typeConverter);
                }
            }
            return(value);
        }
Ejemplo n.º 5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected void removeDependencyEdge(org.maltparser.core.syntaxgraph.node.Node head, org.maltparser.core.syntaxgraph.node.Node dependent) throws org.maltparser.core.exception.MaltChainedException
        protected internal virtual void removeDependencyEdge(Node.Node head, Node.Node dependent)
        {
            if (head == null || dependent == null)
            {
                throw new SyntaxGraphException("Head or dependent node is missing.");
            }
            else if (!dependent.Root)
            {
                IEnumerator <Edge.Edge> ie = dependent.IncomingEdgeIterator;

                while (ie.MoveNext())
                {
                    Edge.Edge e = ie.Current;
                    if (e.Source == head)
                    {
                        graphEdges.remove(e);
//JAVA TO C# CONVERTER TODO TASK: .NET enumerators are read-only:
                        ie.remove();
                        edgePool.checkIn(e);
                    }
                }
            }
            else
            {
                throw new SyntaxGraphException("Head node is not a root node or a terminal node.");
            }
        }
Ejemplo n.º 6
0
        private static object IncludeMultiple(Engine Engine, string Name)
        {
            var Parts = Name.Split('\\', '/');

            if (Parts.Length == 0)
            {
                return(false);
            }

            var Files     = Directory.GetFiles(Parts[0], Name.Substring(Parts[0].Length + 1), SearchOption.TopDirectoryOnly);
            var Container = new Node.Node();

            foreach (var FileName in Files)
            {
                var Result = Include(Engine, FileName);

                if (Result != null)
                {
                    var jsRes = Result as Data.jsObject;
                    if (jsRes != null && !jsRes.IsEmpty)
                    {
                        Container.Add(Result);
                    }
                }
            }

            return(Container);
        }
Ejemplo n.º 7
0
        public static void Init()
        {
            System = new TestSystem();
            System.Start();

            DataContext = System.Configuration.Container.Get<IDataAccessContext>();
        }
Ejemplo n.º 8
0
        public void Apply(ref List <Node.Node> nodes)
        {
            if (names.Length == 1 && names[0].Equals(string.Empty))
            {
                return;
            }

            for (int i = nodes.Count - 1; i >= 0; i--) //iterate backwards because iterating forwards would be an issue with a list of changing size.
            {
                Node.Node node   = nodes[i];
                IEvent    nEvent = node.aEvent;

                bool acceptableName = false;
                foreach (string name in names)
                {
                    if (nEvent.Name.Equals(name))
                    {
                        acceptableName = true;
                        break;
                    }
                }

                if (!acceptableName)
                {
                    node.Visibility = System.Windows.Visibility.Collapsed;
                }
            }
        }
Ejemplo n.º 9
0
        public void Apply(ref List <Node.Node> nodes)
        {
            if (eventTypes.Length == 0)
            {
                return; //dont apply filter if no filters
            }

            for (int i = nodes.Count - 1; i >= 0; i--)//iterate backwards because iterating forwards would be an issue with a list of changing size.
            {
                Node.Node node   = nodes[i];
                IEvent    nEvent = node.aEvent;

                bool acceptableType = false;
                foreach (string type in eventTypes)
                {
                    if (nEvent.EventType.Trim().Equals(type, StringComparison.OrdinalIgnoreCase))
                    {
                        acceptableType = true;
                        break;
                    }
                }

                if (!acceptableType)
                {
                    node.Visibility = System.Windows.Visibility.Collapsed;
                }
            }
        }
Ejemplo n.º 10
0
        public void BasicSetter()
        {
            var str = "12345";

            var node = new Node.Node
            {
                Pattern    = "(?<v1>.*)",
                ChildNodes = new List <INode>
                {
                    new Node.Node
                    {
                        FromVariable   = "v1",
                        TargetVariable = "v1",
                        Setter         = "|OLD| |NEW|"
                    },
                    new Node.Node
                    {
                        FromVariable = "v1",
                        Target       = "StringProperty"
                    }
                }
            };

            var parser = new Parser.Parser();
            var obj    = parser.Text2Object <TestObj1>(node, str);

            obj.Result.StringProperty.ShouldBe("12345 12345");
        }
Ejemplo n.º 11
0
        public ServiceChain(int chainId, Node.Node node, CoreChain coreChain, ChainKeyStore keyStore) : base(ChainType.Service, chainId, 0, node)
        {
            CoreChain = coreChain;

            var endPoints = new HashSet <AvailableEndPoint>();

            _chainKeyIndex = keyStore.KeyIndex;
            _chainKey      = keyStore.DecryptedKey;
            KeyStore       = keyStore;

            var chainInfo = CoreChain.GetChainInfo(ChainId);

            if (chainInfo != null)
            {
                var cep = chainInfo.GetPublicEndpoints();
                foreach (var ep in cep)
                {
                    var e = new Uri(ep);
                    if (IsValidAvailableEndPoint(e))
                    {
                        endPoints.Add(new AvailableEndPoint(e));
                    }
                }
            }

            AvailableEndpoints = new List <AvailableEndPoint>(endPoints);
        }
Ejemplo n.º 12
0
        public void Apply(ref List <Node.Node> nodes)
        {
            if (shellItems.Length == 0)
            {
                return;
            }

            for (int i = nodes.Count - 1; i >= 0; i--)//iterate backwards because iterating forwards would be an issue with a list of changing size.
            {
                Node.Node node   = nodes[i];
                IEvent    nEvent = node.aEvent;

                bool acceptableParent = false;
                foreach (var parent in shellItems)
                {
                    if (nEvent.Parent.Equals(parent))
                    {
                        acceptableParent = true;
                        break;
                    }
                }

                if (!acceptableParent)
                {
                    node.Visibility = System.Windows.Visibility.Collapsed;
                }
            }
        }
Ejemplo n.º 13
0
        public void CollectionTest04()
        {
            var str  = "a1b2a3b4a5b6";
            var node = new Node.Node
            {
                Target     = "ArrayProperty",
                ChildNodes = new List <Node.INode>
                {
                    new Node.Node
                    {
                        Pattern      = "a(?<a>.)",
                        Target       = "IntegerField",
                        FromVariable = "a"
                    },
                    new Node.Node
                    {
                        Pattern      = "b(?<b>.)",
                        Target       = "IntegerField",
                        FromVariable = "b"
                    }
                }
            };
            var parser = new Parser.Parser();
            var obj    = parser.Text2Object <TestObj1>(node, str);

            obj.Result.ArrayProperty.Count().ShouldBe(6);
            obj.Result.ArrayProperty.Select(x => x.IntegerField).Distinct().Count().ShouldBe(6);
            obj.Result.ArrayProperty.Select(x => x.IntegerField).Min().ShouldBe(1);
            obj.Result.ArrayProperty.Select(x => x.IntegerField).Max().ShouldBe(6);
        }
Ejemplo n.º 14
0
        public void Apply(ref List <Node.Node> nodes)
        {
            if (acceptableUsers.Count == 0)
            {
                return; //dont apply filter if no users to filter on
            }

            //iterate backwards because iterating forwards would be an issue with a list of changing size.
            for (int i = nodes.Count - 1; i >= 0; i--)
            {
                Node.Node  node    = nodes[i];
                IShellItem nParent = node.aEvent.Parent;

                var props   = nParent.GetAllProperties();
                var keyName = "RegistryOwner";

                //check for the property and if it exists, verify its a user we want
                if (props.ContainsKey(keyName))
                {
                    if (!acceptableUsers.Contains(props[keyName]))
                    {
                        node.Visibility = Visibility.Collapsed;
                    }
                }
                else
                {
                    node.Visibility = Visibility.Collapsed;
                }
            }
        }
Ejemplo n.º 15
0
 public SyncManager(Node.Node node)
 {
     _pubSub        = node.PubSub;
     _chainManager  = node.ChainManager;
     _coreChain     = _chainManager.CoreChain;
     _storage       = node.Storage;
     _configuration = node.NodeConfiguration;
     _host          = node.Host;
 }
Ejemplo n.º 16
0
        internal override object FetchValue(Element element, object target, TypeCache typeCache, Cache cache)
        {
            // Get the primary element
            Element child;

            if (!GetNodeFromQuery(Query, null, element, out child))
            {
                child = element.Children.OfType <Element>().Where(e => e.Name.Equals(Name)).FirstOrDefault();
            }

            if (child == null)
            {
                return(null);
            }

            // Get all the item nodes
            IList <object> items = new List <object>(!String.IsNullOrEmpty(ItemQuery) ? child.Eval(ItemQuery)
                : child.Children.OfType <Element>().Where(e => e.Name.Equals(ItemName)).Cast <object>());

            // Create the collection (or reuse it if appropriate)
            object collection = _getCollection(target, items.Count);

            // Populate with values
            int c = 0;

            foreach (object item in items)
            {
                if (ItemsArePersistentObjects)
                {
                    // Get, attach, and fetch the persistent object instance
                    Element itemElement = item as Element;
                    if (itemElement == null)
                    {
                        throw new Exception("Persistent value node must be an element.");
                    }
                    object itemObject = cache.GetObject(_itemTypeCache, itemElement, AttachItems);
                    if (itemObject != null)
                    {
                        _setCollectionItem(collection, c++, itemObject);
                    }
                }
                else
                {
                    Node.Node itemNode   = item as Node.Node;
                    object    itemObject = GetObjectFromString(
                        itemNode != null ? itemNode.Value : item.ToString(), null, null, _itemTypeCache.Type, _itemTypeConverter);
                    if (itemObject != null)
                    {
                        _setCollectionItem(collection, c++, itemObject);
                    }
                }
            }

            return(collection);
        }
Ejemplo n.º 17
0
        public ServiceBlockCouncil(Node.Node node, int chainId, ServiceChain serviceChain, MaintainChain maintainChain, short keyIndex, Key key) : base(node, Chain.ChainType.Service, chainId, 0, keyIndex, key)
        {
            _serviceChain  = serviceChain;
            _maintainChain = maintainChain;

            var chainInfo = node.ChainManager.CoreChain.GetChainInfo(chainId);

            if (chainInfo != null)
            {
                _chainAccountId = chainInfo.AccountId;
            }
        }
Ejemplo n.º 18
0
 public void DateTimeNoFormatter()
 {
     var str  = "aaa2019-02-03 11:33:44bbb";
     var node = new Node.Node
     {
         Pattern      = "aaa(?<dt>.*?)bbb",
         Target       = "DateTimeProperty",
         FromVariable = "dt"
     };
     var parser = new Parser.Parser();
     var obj    = parser.Text2Object <TestObj1>(node, str);
 }
Ejemplo n.º 19
0
        public ClientServer(Node.Node node)
        {
            _chainManager       = node.ChainManager;
            _configuration      = node.NodeConfiguration;
            _attachementManager = node.AttachementManager;
            _transactionManager = node.TransactionManager;
            _pubsub             = node.PubSub;

            _pubsub.Subscribe <BlockEvent <CoreBlock> >(this, NewCoreBlock);
            _pubsub.Subscribe <BlockEvent <ServiceBlock> >(this, NewServiceBlock);
            _pubsub.Subscribe <BlockEvent <DataBlock> >(this, NewDataBlock);
        }
Ejemplo n.º 20
0
        internal override object FetchValue(Element element, object target, TypeCache typeCache, Cache cache)
        {
            object result = element.EvalSingle(Query);

            if (result == null)
            {
                return(null);
            }
            Node.Node node = result as Node.Node;
            return(GetObjectFromString(
                       node != null ? node.Value : result.ToString(), Default, target, typeCache.Type, _typeConverter));
        }
Ejemplo n.º 21
0
        public void ReplaceTest()
        {
            var node = new Node.Node
            {
                Process = "Replace(hello,goodbye)",
                Target  = "StringProperty"
            };
            var parser = new Parser.Parser();
            var obj    = parser.Text2Object <TestObj1>(node, "hello hello hello");

            obj.Result.StringProperty.ShouldBe("goodbye goodbye goodbye");
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Sets the edge with a source node, a target node and a type (DEPENDENCY_EDGE, PHRASE_STRUCTURE_EDGE
        /// or SECONDARY_EDGE).
        /// </summary>
        /// <param name="source"> a source node </param>
        /// <param name="target"> a target node </param>
        /// <param name="type"> a type (DEPENDENCY_EDGE, PHRASE_STRUCTURE_EDGE or SECONDARY_EDGE) </param>
        /// <exception cref="MaltChainedException"> </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void setEdge(org.maltparser.core.syntaxgraph.node.Node source, org.maltparser.core.syntaxgraph.node.Node target, int type) throws org.maltparser.core.exception.MaltChainedException
        public virtual void setEdge(Node.Node source, Node.Node target, int type)
        {
            this.source = source;
            this.target = target;
            if (type >= Edge_Fields.DEPENDENCY_EDGE && type <= Edge_Fields.SECONDARY_EDGE)
            {
                this.type = type;
            }
            this.source.addOutgoingEdge(this);
            this.target.addIncomingEdge(this);
            setChanged();
            notifyObservers(this);
        }
Ejemplo n.º 23
0
        public void SimpleStringWholeMatch()
        {
            var str  = "hello";
            var node = new Node.Node
            {
                Pattern = "(.*)",
                Target  = "StringProperty"
            };
            var parser = new Parser.Parser();
            var obj    = parser.Text2Object <TestObj1>(node, str);

            obj.Result.StringProperty.ShouldBe(str);
        }
Ejemplo n.º 24
0
        public void ToLowerTest()
        {
            var node = new Node.Node
            {
                Process = "ToLower()",
                Target  = "StringProperty"
            };
            var parser = new Parser.Parser();
            var str    = "UPPERCASE lowercase";
            var obj    = parser.Text2Object <TestObj1>(node, str);

            obj.Result.StringProperty.ShouldBe(str.ToLower());
        }
Ejemplo n.º 25
0
        public void SimpleIntFromVariable()
        {
            var str  = "12345";
            var node = new Node.Node
            {
                Pattern      = "12(?<v1>3)45",
                Target       = "IntegerProperty",
                FromVariable = "v1"
            };
            var parser = new Parser.Parser();
            var obj    = parser.Text2Object <TestObj1>(node, str);

            obj.Result.IntegerProperty.ShouldBe(3);
        }
Ejemplo n.º 26
0
        public void Apply(ref List <Node.Node> events)
        {
            for (int i = events.Count - 1; i >= 0; i--) //iterate backwards because iterating forwards would be an issue with a list of changing size.
            {
                Node.Node node   = events[i];
                IEvent    nEvent = node.aEvent;

                //if the event falls outside of our two DateTime bounds
                if (DateTime.Compare(startDate, nEvent.EventTime) > 0 || DateTime.Compare(nEvent.EventTime, endDate) > 0)
                {
                    node.Visibility = System.Windows.Visibility.Collapsed;
                }
            }
        }
Ejemplo n.º 27
0
        public void SimpleStringFromVariable()
        {
            var str  = "hello";
            var node = new Node.Node
            {
                Pattern      = "he(?<v1>ll)o",
                Target       = "StringProperty",
                FromVariable = "v1"
            };
            var parser = new Parser.Parser();
            var obj    = parser.Text2Object <TestObj1>(node, str);

            obj.Result.StringProperty.ShouldBe("ll");
        }
Ejemplo n.º 28
0
        public void SimpleDecimalFromVariable()
        {
            var str  = "123.45";
            var node = new Node.Node
            {
                Pattern      = "12(?<v1>3.4)5",
                Target       = "DecimalProperty",
                FromVariable = "v1"
            };
            var parser = new Parser.Parser();
            var obj    = parser.Text2Object <TestObj1>(node, str);

            obj.Result.DecimalProperty.ShouldBe(3.4M);
        }
Ejemplo n.º 29
0
        public Types.Object Run(Node.Node node)
        {
            System.Diagnostics.Stopwatch t = new System.Diagnostics.Stopwatch();
            t.Start();

            Types.Object e = Evaluate(node);

            t.Stop();
            Console.BackgroundColor = ConsoleColor.Yellow;
            Console.ForegroundColor = ConsoleColor.Black;
            Console.WriteLine("Returned: " + e.ToString() + " in " + t.ElapsedMilliseconds);
            Console.ResetColor();
            return(e);
        }
Ejemplo n.º 30
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void clear() throws org.maltparser.core.exception.MaltChainedException
        public override void clear()
        {
            base.clear();
            if (source != null)
            {
                source.removeOutgoingEdge(this);
            }
            if (target != null)
            {
                target.removeIncomingEdge(this);
            }
            source = null;
            target = null;
            type   = -1;
        }
Ejemplo n.º 31
0
        protected Council(Node.Node node, ChainType chainType, int chainId, uint chainIndex, short keyIndex, Key key)
        {
            ChainType  = chainType;
            ChainId    = chainId;
            ChainIndex = chainIndex;

            RequiresChainVoteKeyFlags = Block.GetRequiredChainVoteKeyFlags(ChainType);
            RequiresChainKeyFlags     = Block.GetRequiredChainKeyFlags(ChainType);
            LocalKeyIndex             = keyIndex;
            _localKey = key;

            _node         = node;
            _coreChain    = node.ChainManager.CoreChain;
            _blockStorage = node.ChainManager.GetChain(ChainType, ChainId, chainIndex).BlockStorage;
        }