Exemple #1
0
 private void AddInterface(ITypeDefinition interfce, StringBuilder key)
 {
     if (interfce.Namespace == "")
     {
         lock (Interfaces)
         {
             foreach (var typeArg in interfce.TypeParameters)
             {
                 foreach (var constraint in typeArg.DirectBaseTypes)
                 {
                     key.Append(constraint.Name);
                 }
             }
             if (Interfaces.ContainsKey(key.ToString()))
             {
                 return;
             }
             Interfaces.Add(key.ToString(), new InterfaceProperties(interfce));
         }
     }
     else
     {
         AddNamespace(key, interfce);
     }
 }
        public void AddInterface(InterfaceDeclarationSyntax syntax)
        {
            string interfaceName = syntax.Identifier.Text;

            if (Interfaces.ContainsKey(interfaceName))
            {
                throw new ArgumentException($"Interface: {interfaceName} already exist.");
            }

            Interfaces.Add(interfaceName, syntax);
        }
Exemple #3
0
        /// <summary>
        /// Adds a route to the host's routing table.
        /// </summary>
        /// <param name="cidrNetworkId">The destination subnet specified in CIDR notation.</param>
        /// <param name="gateway">The gateway through which the destination network can be
        /// reached.</param>
        /// <param name="ifName">The name of the local interface through which the gateway
        /// can be reached.</param>
        /// <param name="metric">The added cost of using the route.</param>
        /// <param name="index">The index or row number at which to insert the route into
        /// the routing table. If this is null, the route is appended to the end of the
        /// routing table.</param>
        public void AddRoute(string cidrNetworkId, string gateway,
                             string ifName, int metric, int?index = null)
        {
            if (!Interfaces.ContainsKey(ifName))
            {
                throw new ArgumentException("The interface '" + ifName + "' " +
                                            "could not be found", nameof(ifName));
            }
            var ifc = Interfaces[ifName];

            AddRoute(cidrNetworkId, gateway, ifc, metric, index);
        }
Exemple #4
0
 private void AddInterface(IType interfce, StringBuilder key)
 {
     lock (Interfaces)
     {
         foreach (var typeArg in interfce.TypeParameters)
         {
             foreach (var constraint in typeArg.Constraints)
             {
                 key.Append(constraint.Name);
             }
         }
         if (Interfaces.ContainsKey(key.ToString()))
         {
             return;
         }
         Interfaces.Add(key.ToString(), new InterfaceProperties(interfce));
     }
 }
 public bool IsInterface(string name) => Interfaces.ContainsKey(name);
Exemple #6
0
        /// <summary>
        /// execute the script
        /// </summary>
        private void Run(IReporter reporter)
        {
            while (Scripts.Count > 0 && !IsStopped)
            {
                // pop a script from stack
                CurrentScript = Scripts.Pop();

                // begin new section in report
                if (CurrentScript.CurrentLineNumber == 0)
                {
                    reporter.BeginScript(CurrentScript.Name);
                }

                // loop for each line of current script
                while (CurrentScript.HasNextLine && !IsStopped)
                {
                    // get a action line from script
                    ActionLine actLineRaw = CurrentScript.Next();

                    if (actLineRaw.ActionName.Length == 0)
                    {
                        continue;
                    }

                    // manipulate action line with DataSet
                    ActionLine actLine = ManipulateData(actLineRaw);

                    // notify about action that is going to be performed
                    if (ActionPerforming != null)
                    {
                        string summary = actLine.ActionName;
                        if (actLine.WindowName != null)
                        {
                            summary += "\t[window:" + actLine.WindowName + "]";
                        }
                        if (actLine.ControlName != null)
                        {
                            summary += "\t[control:" + actLine.ControlName + "]";
                        }
                        foreach (string key in actLine.Arguments.Keys)
                        {
                            summary += "\t[" + key + ":" + actLine.Arguments[key] + "]";
                        }
                        ActionPerforming(summary);
                    }

                    // the action is 'use interface'
                    if (actLine.ActionName == Constants.Keywords.ActionUseInterface)
                    {
                        if (!Interfaces.ContainsKey(actLine.Arguments[Constants.Keywords.KeywordInterface].ToLower()))
                        {
                            IInterface newInterface = new Interface(Parser.NewInstance);
                            newInterface.FileName = actLine.Arguments[Constants.Keywords.KeywordInterface] + Parser.FileExtension;
                            Interfaces.Add(newInterface.Name, newInterface);
                        }
                    }
                    // the action is 'run script'
                    else if (actLine.ActionName == Constants.Keywords.ActionStartScript)
                    {
                        Script newScript = new Script(Parser.NewInstance);
                        newScript.FileName = actLine.Arguments[Constants.Keywords.KeywordScript] + Parser.FileExtension;

                        // push current script to stack and run new script
                        Scripts.Push(CurrentScript);
                        CurrentScript = newScript;

                        // begin new section in report
                        reporter.BeginScript(CurrentScript.Name);
                    }
                    else
                    {
                        try
                        {
                            IAction action = getAction(actLine);
                            if (action == null)
                            {
                                throw new Exception(Constants.Messages.Error_Executing_NoAction);
                            }

                            if (!action.IsValid())
                            {
                                throw new Exception(Constants.Messages.Error_Executing_InvalidArg);
                            }

                            // execute the action
                            int ret = action.Execute();

                            // write result of executing to report
                            reporter.WriteLine(actLine, action.Result);

                            // reset the action state
                            action.Reset();
                        }
                        catch (Exception e)
                        {
                            reporter.WriteError(actLine, e.Message);
                            InteruptWithError(e.Message);
                        }
                    }

                    // if the automation is paused, just sleep
                    CheckPaused();

                    // check if user interupt the automation
                    if (!CheckStopped())
                    {
                        ProcessSpeed();
                    }
                }

                // if the automation is paused, just sleep
                CheckPaused();

                // check if user interupt the automation
                CheckStopped();

                // end section in report
                if (CurrentScript.CurrentLineNumber > 0)
                {
                    reporter.EndScript(CurrentScript.Name);
                }
            }
        }