Exemple #1
0
 public AdvisedSupport(IEnumerable <Type> interfaces) : this()
 {
     if (interfaces != null)
     {
         foreach (var @interface in interfaces)
         {
             Interfaces.Add(@interface);
         }
     }
 }
Exemple #2
0
        public BuilderType AddInterface(ReferenceBuilder reference)
        {
            if (Interfaces == null)
            {
                Interfaces = new List <ReferenceBuilder>();
            }

            Interfaces.Add(reference);
            return((BuilderType)this);
        }
        private void UpdateInterfacesList()
        {
            Interfaces.Clear();
            var adapters = AUTD.EnumerateAdapters();

            foreach (var adapter in adapters)
            {
                Interfaces.Add($"{adapter}");
            }
        }
        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 #5
0
        /// <summary>
        /// Adds a new interface with the given IP and subnetmask
        /// </summary>
        /// <param name="Ip">The IP of the interface. Ignored if used with switch</param>
        /// <param name="Subnetmask">The subnetmask. Ignored if used with switch </param>
        /// <param name="PortNum">Number of port. Only for project loading purpose. </param>
        /// <returns>The newly added Interface</returns>
        public override Interface AddInterface(IPAddress Ip, IPAddress Subnetmask, int PortNum = -1)
        {
            if (PortNum == -1)
            {
                PortNum = getNewInterfaceNumber();
            }

            Interface interfaceObj = new Interface(null, null, PortNum);

            Interfaces.Add(interfaceObj);
            return(interfaceObj);
        }
Exemple #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Workstation" /> class.
 /// The IP address of the standardgateway must be set seperatly.
 /// </summary>
 /// <param name="Name">The Name.</param>
 public Workstation(string Name) : base(Name)
 {
     Layerstack.AddLayer(new PhysicalLayer(0));
     Layerstack.AddLayer(new DataLinkLayer(1));
     Layerstack.AddLayer(new NetworkLayer(2));
     Layerstack.AddLayer(new TransportLayer(3));
     Layerstack.AddLayer(new SessionLayer(4));
     Layerstack.AddLayer(new PresentationLayer(5));
     Layerstack.AddLayer(new ApplicationLayer(6));
     Interfaces.Add(new Interface(new IPAddress(new byte[] { 192, 168, 0, 1 }), new IPAddress(new byte[] { 255, 255, 255, 0 }), getNewInterfaceNumber()));
     StandardGateway     = null;
     StandardGatewayPort = null;
 }
Exemple #7
0
        public BuilderType AddInterface(string name, bool is_dotted)
        {
            if (Interfaces == null)
            {
                Interfaces = new List <ReferenceBuilder>();
            }

            Interfaces.Add(new TypeReferenceBuilder()
            {
                Name = name, IsDotted = is_dotted
            });
            return((BuilderType)this);
        }
Exemple #8
0
        /// <summary>
        /// Registers a new network interface with the host.
        /// </summary>
        /// <param name="ifc"></param>
        /// <exception cref="ArgumentNullException">Thrown if any of the
        /// arguments is null.</exception>
        public void RegisterInterface(Interface ifc)
        {
            ifc.ThrowIfNull("ifc");
            Interfaces.Add(ifc.Name, ifc);

            ifc.Hostname = Hostname;

            // Delegate the interface's events to the network stack.
            ifc.DataReceivedEvent += (sender, args) =>
                                     Network.OnInput(sender as Interface, args.Data, args.Type);
            ifc.SendFifoEmptyEvent += (sender, args) =>
                                      Network.OnAvailableToSent(sender as Interface);
        }
Exemple #9
0
            private async Task GetAllInterfaces()
            {
                //if (KernelVersion > WindowsKernelVersions.Windows2012And8)
                //{
                //    //ActiveMaximumTransmissionUnit
                //    //MtuSize
                //    //
                //    //Speed
                //}

                const string query = @"
SELECT Name,
       DeviceID,
       NetConnectionID,
       Description,
       MACAddress,
       Speed
  FROM Win32_NetworkAdapter
 WHERE NetConnectionStatus = 2"; //connected adapters.

                //'AND PhysicalAdapter = True' causes exceptions with old windows versions.

                using (var q = Wmi.Query(Name, query))
                {
                    foreach (var data in await q.GetDynamicResult())
                    {
                        string id = $"{data.DeviceID}";
                        var    i  = Interfaces.FirstOrDefault(x => x.Id == id);
                        if (i == null)
                        {
                            i = new Interface();
                            Interfaces.Add(i);
                        }

                        i.Id              = $"{data.DeviceID}";
                        i.Alias           = "!alias";
                        i.Caption         = data.NetConnectionID == "Ethernet" ? data.Name : data.NetConnectionID;
                        i.FullName        = data.Description;
                        i.IfName          = data.Name;
                        i.NodeId          = Id;
                        i.Index           = 0;
                        i.IsTeam          = false; //TODO: Fix
                        i.LastSync        = DateTime.UtcNow;
                        i.Name            = data.Name;
                        i.PhysicalAddress = data.MACAddress;
                        i.Speed           = data.Speed;
                        i.Status          = NodeStatus.Active;
                        i.TypeDescription = "";
                    }
                }
            }
Exemple #10
0
        private void ReflectOutInterfaces()
        {
            //do interfaces
            if (ShowInterfaces)
            {
                Type[] tiArray = TypeInAssembly.GetInterfaces();
                foreach (Type ii in tiArray)
                {
                    Interfaces.Add(ii.Name.ToString());
                }
            }

            HasInterfaces = Interfaces.Any();
        }
Exemple #11
0
        public void GetInterfaces()
        {
            snmpResolver.SetConfig(IpAddress, Community);
            snmpResolver.GetInterfaces();

            foreach (OidRow or in snmpResolver.OidInterfaceTable)
            {
                Interfaces.Add(new InterfaceRow()
                {
                    Number      = snmpResolver.OidInterfaceTable.IndexOf(or) + 1,
                    Description = or.CurrentResult
                });
            }
        }
Exemple #12
0
        public static T Get <T>() where T : TInterface, new()
        {
            Type className = typeof(T);

            if (!Interfaces.TryGetValue(className.Name, out object interfaceObject))
            {
                T m = new T();

                Interfaces.Add(className.Name, m);

                return(m);
            }

            return((T)interfaceObject);
        }
Exemple #13
0
        public static void Initialize(Interfaces.ISiqiServer server)
        {
            for (int i = 0; i < 20; i++)
            {
                string id= (i+1).ToString();
                Room room = new Room(id,"游戏房间"+id);
                for (int k = 0; k < 50; k++)
                {

                    string deskid = (k + 1).ToString();
                    room.Add(new Desk(deskid, deskid, 4));
                }
                server.Add(room);
            }
        }
Exemple #14
0
        public TypeDefWrapper(TypeDefinition typeDef, bool isExtended = false)
        {
            InnerDefinition = typeDef;

            FullName = InnerDefinition.GetFullName();

            Name      = InnerDefinition.Name;
            Namespace = InnerDefinition.Namespace;
            ClassType = InnerDefinition.GetClassType();

            var parent = InnerDefinition.GetParent();

            if (parent.HasValue)
            {
                Parent     = new TypeDefWrapper(parent.Value, true);
                ParentName = Parent.Name;
            }

            if (isExtended)
            {
                return;
            }

            var fields = InnerDefinition.GetFields();

            if (fields != null)
            {
                Fields.AddRange(fields.Select(field => (FieldDefWrapper)field)
                                .Where(w => w.Name != "<ErrorReadingField>"));
            }
            // bug Skipping invalid fields until I solve the issue

            var interfaces = InnerDefinition.GetInterfaces();

            if (interfaces != null)
            {
                foreach (var iface in interfaces)
                {
                    Interfaces.Add(new TypeDefWrapper(iface, true));
                }
            }
            InterfacesText = Interfaces.Aggregate("", (current, iface) => current + $", {iface.Name}");

            foreach (var f in Fields)
            {
                f.Parent = this;
            }
        }
        public MyBusObject(IBusObject busObject)
        {
            Path = busObject.Path;
            if (busObject.Interfaces == null)
            {
                this.Interfaces = null;
                return;
            }

            this.Interfaces = new List <IInterface>();

            foreach (var i in busObject.Interfaces)
            {
                Interfaces.Add(new MyInterface(i));
            }
        }
        public void ResolveInterfaces(ITypeModule typeModule)
        {
            foreach (RuntimeType type in baseGenericType.Interfaces)
            {
                if (!type.ContainsOpenGenericParameters)
                {
                    Interfaces.Add(type);
                }
                else
                {
                    CilGenericType genericType = type as CilGenericType;
                    Debug.Assert(genericType != null);

                    RuntimeType matchedInterfaceType = null;

                    // -- only needs to search generic type interfaces
                    foreach (RuntimeType runtimetype in typeModule.GetAllTypes())
                    {
                        if (runtimetype.IsInterface)
                        {
                            CilGenericType runtimetypegeneric = runtimetype as CilGenericType;
                            if (runtimetypegeneric != null)
                            {
                                if (genericType.baseGenericType == runtimetypegeneric.baseGenericType)
                                {
                                    if (SigType.Equals(GenericArguments, runtimetypegeneric.GenericArguments))
                                    {
                                        matchedInterfaceType = runtimetype;
                                        //Interfaces.Add(runtimetype);
                                        break;
                                    }
                                }
                            }
                        }
                    }

                    if (matchedInterfaceType != null)
                    {
                        Interfaces.Add(matchedInterfaceType);
                    }
                    else
                    {
                        continue;
                    }
                }
            }
        }
Exemple #17
0
        /// <summary>
        /// Sets the interface count to the given value.
        /// </summary>
        /// <param name="Count">The count.</param>
        /// <returns>Returns a list of removed interfaces</returns>
        public List <Interface> SetInterfaceCount(int Count)
        {
            List <Interface> removedInterfaces = new List <Interface>();

            for (int i = Interfaces.Count; i < Count; i++)
            {
                Interfaces.Add(new Interface(null, null, getNewInterfaceNumber()));
            }
            for (int i = Interfaces.Count; i > Count; i--)
            {
                var last = Interfaces.Last();
                removedInterfaces.Add(last);
                Interfaces.Remove(last);
            }

            return(removedInterfaces);
        }
Exemple #18
0
        public TSInterface(Type type, Func <Type, string> mapType)
        {
            var ti = type.GetTypeInfo();

            _type      = type;
            _mapType   = mapType;
            ModuleName = type.Namespace;
            FullName   = ti.FullName;
            //Methods = new List<TSMethod>();
            var name = ti.IsGenericType
                            ? type.Name.Split(new[] { '`' }).First()
                            : type.Name;

            InterFaceName = ti.IsInterface
                            ? name
                            : string.Format(Settings.InterfaceFormat, name);

            //interfaces
            Interfaces = ti.GetInterfaces().Where(i => i.GetTypeInfo().Assembly == ti.Assembly && i.Name != InterFaceName).ToList();
            if (ti.BaseType != null && ti.BaseType != typeof(object))
            {
                Interfaces.Add(ti.BaseType);
            }

            //properties
            var props = ti.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);

            Properties = props.Select(p => new TSProperty(p, _mapType)).ToList();

            //fields, not properties
            var fields = ti.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);
            var addp   = fields.Select(f => new TSProperty(f, _mapType)).ToList();

            Properties.AddRange(addp);

            //generic
            //if (_type.IsGenericType)
            //{
            GenericParameters = ti.GetGenericArguments().Select(a => new TSGenericParameter(a, _mapType)).ToList();
            // }

            //methods
            var methods = ti.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly).Where(x => !x.IsSpecialName);

            Methods = methods.Select(m => new TSMethod(m, _mapType)).ToList();
        }
Exemple #19
0
        protected override void LoadContent()
        {
            // Ensure we have default textures loaded.
            TextureMapper.LoadDefaults(GraphicsDevice);

            // Load any custom textures if needed.
            TextureMapper = new TextureMapper(GraphicsDevice);
            if (UserSettings.Local.SelectedTexturePack != TexturePack.Default.Name)
            {
                TextureMapper.AddTexturePack(TexturePack.FromArchive(Path.Combine(TexturePack.TexturePackPath, UserSettings.Local.SelectedTexturePack)));
            }

            Pixel = new FontRenderer(
                new Font(Content, "Fonts/Pixel", FontStyle.Regular),
                new Font(Content, "Fonts/Pixel", FontStyle.Bold),
                null, // No support for underlined or strikethrough yet. The FontRenderer will revert to using the regular font style.
                null, // (I don't think BMFont has those options?)
                new Font(Content, "Fonts/Pixel", FontStyle.Italic));
            Interfaces.Add(ChatInterface  = new ChatInterface(Client, KeyboardComponent, Pixel));
            Interfaces.Add(DebugInterface = new DebugInterface(Client, Pixel));

            ChatInterface.IsVisible  = true;
            DebugInterface.IsVisible = true;

            OpaqueEffect = new BasicEffect(GraphicsDevice);
            OpaqueEffect.EnableDefaultLighting();
            OpaqueEffect.DirectionalLight0.SpecularColor = Color.Black.ToVector3();
            OpaqueEffect.DirectionalLight1.SpecularColor = Color.Black.ToVector3();
            OpaqueEffect.DirectionalLight2.SpecularColor = Color.Black.ToVector3();
            OpaqueEffect.TextureEnabled     = true;
            OpaqueEffect.Texture            = TextureMapper.GetTexture("terrain.png");
            OpaqueEffect.FogEnabled         = true;
            OpaqueEffect.FogStart           = 512f;
            OpaqueEffect.FogEnd             = 1000f;
            OpaqueEffect.FogColor           = Color.CornflowerBlue.ToVector3();
            OpaqueEffect.VertexColorEnabled = true;

            TransparentEffect = new AlphaTestEffect(GraphicsDevice);
            TransparentEffect.AlphaFunction      = CompareFunction.Greater;
            TransparentEffect.ReferenceAlpha     = 127;
            TransparentEffect.Texture            = TextureMapper.GetTexture("terrain.png");
            TransparentEffect.VertexColorEnabled = true;

            base.LoadContent();
        }
Exemple #20
0
        public NetworkRouter()
        {
            var devices = NpcapDeviceList.Instance;

            foreach (var device in devices)
            {
                if (device.Interface.FriendlyName != null)
                {
                    var networkInterface = new Interface(device, PacketArrival);
                    networkInterface.PropertyChanged += InterfaceChanged;
                    Interfaces.Add(networkInterface);
                }
            }

            _clock.Elapsed += ClockTickEvent;
            _clock.Elapsed += ArpTable.ClockTickEvent;
            _clock.Start();
        }
Exemple #21
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));
     }
 }
Exemple #22
0
 public void AddElement(ReflectedType type)
 {
     if (type != null)
     {
         if (type.TypeKind == Kind.Class)
         {
             Classes.Add(type);
         }
         else if (type.TypeKind == Kind.Interface)
         {
             Interfaces.Add(type);
         }
         else if (type.TypeKind == Kind.Enum || type.TypeKind == Kind.Struct)
         {
             ValueTypes.Add(type);
         }
     }
 }
Exemple #23
0
        public void AddSubNamespaceType(List <string> ns, Type type)
        {
            if (ns.Count == 0)
            {
                var ti = type.GetTypeInfo();
                if (ti.IsEnum)
                {
                    if (Settings.ConstEnumsEnabled)
                    {
                        var tsconstenum = new TSConstEnumeration(type)
                        {
                            IsExported = true
                        };
                        Enumerations.Add(tsconstenum);
                    }
                    return;
                }
                var tsinterface = new TSInterface(type, _mapType)
                {
                    IsExported = true
                };
                Interfaces.Add(tsinterface);

                return;
            }

            var root = ns.First();

            var mod = SubModules.FirstOrDefault(m => m.Name == root);

            if (mod == null)
            {
                mod = new TSModule(root, _mapType);
                SubModules.Add(mod);
            }

            ns.RemoveAt(0);

            mod.AddSubNamespaceType(ns, type);
        }
Exemple #24
0
        private void AnalyzeServiceAndInterfaces(Type serviceType)
        {
            foreach (var interfaceType in ReflectionTools.ExpandInterface(serviceType))
            {
                var interfaceDescription = new InterfaceDescription(interfaceType);

                string?serviceName = null;
                if (ServiceContract.IsServiceContractInterface(interfaceType))
                {
                    serviceName = ServiceContract.GetServiceName(interfaceType);
                    Services.Add(interfaceDescription);
                }
                else
                {
                    Interfaces.Add(interfaceDescription);
                }

                foreach (var method in ReflectionTools.GetMethods(interfaceType))
                {
                    string?error;

                    if (serviceName == null || !ServiceContract.IsServiceOperation(method))
                    {
                        error = "Method {0}.{1}.{2} is not service operation.".FormatWith(
                            ReflectionTools.GetNamespace(interfaceType),
                            interfaceType.Name,
                            method.Name);

                        interfaceDescription.Methods.Add(new MethodDescription(method, error));
                        continue;
                    }

                    if (TryCreateMessage(method, out var message, out error))
                    {
                        interfaceDescription.Operations.Add(new OperationDescription(
                                                                serviceName,
                                                                ServiceContract.GetServiceOperationName(method),
                                                                message));
                    }
Exemple #25
0
        private void DiffImplementedInterfaces()
        {
            // search for removed interfaces
            foreach (TypeReference baseV1 in TypeV1.Interfaces)
            {
                bool bFound = false;
                foreach (TypeReference baseV2 in TypeV2.Interfaces)
                {
                    if (baseV2.IsEqual(baseV1))
                    {
                        bFound = true;
                        break;
                    }
                }
                if (!bFound)
                {
                    Interfaces.Add(new DiffResult <TypeReference>(baseV1, new DiffOperation(false)));
                }
            }

            // search for added interfaces
            foreach (TypeReference baseV2 in TypeV2.Interfaces)
            {
                bool bFound = false;
                foreach (TypeReference baseV1 in TypeV1.Interfaces)
                {
                    if (baseV2.IsEqual(baseV1))
                    {
                        bFound = true;
                        break;
                    }
                }
                if (!bFound)
                {
                    Interfaces.Add(new DiffResult <TypeReference>(baseV2, new DiffOperation(true)));
                }
            }
        }
Exemple #26
0
        internal void Populate()
        {
            if (IsInCoreAssembly)
            {
                BaseType = _bfCache.GetBfType(_typeDefinition.BaseType);

                if (BaseType != null && BaseType.FullName != "System.Object")
                {
                    BaseType.DerivedTypes.Add(this);
                }

                _typeDefinition.Interfaces.Select(t => _bfCache.GetBfType(t))
                .Where(t => t != null)
                .ForEach(t =>
                {
                    Interfaces.Add(t);
                    t.DerivedTypes.Add(this);
                });

                _typeDefinition.Fields.ForEach(f => Fields.Add(new BfField(_bfCache, f, this)));

                _typeDefinition.Methods.ForEach(m =>
                {
                    var bfMethod = new BfMethod(_bfCache, m, this);
                    Methods.Add(bfMethod);
                    Assembly.GetMethodsDictionary().Add(bfMethod.UniqueName, bfMethod);
                });

                _typeDefinition.Events.ForEach(e => Events.Add(new BfEvent(_bfCache, e, this)));

                Interfaces.Clear();
                Fields.Clear();
                Methods.Clear();
                Events.Clear();
            }
        }
            private async Task GetAllInterfacesAsync()
            {
                const string query = @"
SELECT Name,
       PNPDeviceID,
       DeviceID,       
       NetConnectionID,
       Description,
       MACAddress,
       Speed,
       InterfaceIndex
  FROM Win32_NetworkAdapter
 WHERE NetConnectionStatus = 2"; //connected adapters.
                //'AND PhysicalAdapter = True' causes exceptions with old windows versions.

                var indexMap = new Dictionary <uint, Interface>();

                using (var q = Wmi.Query(Endpoint, query))
                {
                    foreach (var data in await q.GetDynamicResultAsync().ConfigureAwait(false))
                    {
                        string id = $"{data.DeviceID}";
                        var    i  = Interfaces.Find(x => x.Id == id) ?? new Interface();
                        indexMap[data.InterfaceIndex] = i;

                        i.Id       = id;
                        i.Alias    = "!alias";
                        i.Caption  = data.NetConnectionID;
                        i.FullName = data.Description;
                        i.NodeId   = Id;
                        i.LastSync = DateTime.UtcNow;
                        i.Name     = await GetRealAdapterName(data.PNPDeviceID).ConfigureAwait(false);

                        i.PhysicalAddress = data.MACAddress;
                        i.Speed           = data.Speed;
                        i.Status          = NodeStatus.Active;
                        i.TypeDescription = "";
                        i.IPs             = new List <IPNet>();
                        i.TeamMembers     = new List <string>();

                        if (i.Node == null)
                        {
                            i.Node = this;
                            Interfaces.Add(i);
                        }
                    }
                }

                if (_canQueryTeamingInformation)
                {
                    const string teamsQuery            = "SELECT InstanceID, Name FROM MSFT_NetLbfoTeam";
                    var          teamNamesToInterfaces = new Dictionary <string, Interface>();

                    using (var q = Wmi.Query(Endpoint, teamsQuery, @"root\standardcimv2"))
                    {
                        foreach (var data in await q.GetDynamicResultAsync().ConfigureAwait(false))
                        {
                            var teamInterface = Interfaces.Find(x => x.Caption == data.Name);

                            if (teamInterface == null)
                            {
                                continue;
                            }

                            teamNamesToInterfaces.Add(data.Name, teamInterface);
                        }
                    }

                    const string teamMembersQuery = "SELECT InstanceID, Name, Team FROM MSFT_NetLbfoTeamMember";
                    using (var q = Wmi.Query(Endpoint, teamMembersQuery, @"root\standardcimv2"))
                    {
                        foreach (var data in await q.GetDynamicResultAsync().ConfigureAwait(false))
                        {
                            var teamName = data.Team;

                            if (teamNamesToInterfaces.TryGetValue(teamName, out Interface teamInterface))
                            {
                                var adapterName     = data.Name;
                                var memberInterface = Interfaces.Find(x => x.Name == adapterName);

                                if (memberInterface == null)
                                {
                                    continue;
                                }

                                teamInterface.TeamMembers.Add(memberInterface.Id);
                            }
                        }
                    }
                }

                const string ipQuery = @"
SELECT InterfaceIndex, IPAddress, IPSubnet, DHCPEnabled
  FROM WIn32_NetworkAdapterConfiguration 
 WHERE IPEnabled = 'True'";

                using (var q = Wmi.Query(Endpoint, ipQuery))
                {
                    foreach (var data in await q.GetDynamicResultAsync().ConfigureAwait(false))
                    {
                        if (indexMap.TryGetValue(data.InterfaceIndex, out Interface i))
                        {
                            i.DHCPEnabled = data.DHCPEnabled;
                            var ips     = data.IPAddress as string[];
                            var subnets = data.IPSubnet as string[];

                            if (ips == null ||
                                subnets == null)
                            {
                                continue;
                            }

                            for (var j = 0; j < (ips?.Length).GetValueOrDefault(0); j++)
                            {
                                if (int.TryParse(subnets[j], out int cidr) && IPNet.TryParse(ips[j], cidr, out IPNet net))
                                {
                                    i.IPs.Add(net);
                                }
                                else if (IPNet.TryParse(ips[j], subnets[j], out net))
                                {
                                    i.IPs.Add(net);
                                }
                            }
                        }
                    }
                }
            }
Exemple #28
0
 /// <summary>
 /// Adds a GraphQL interface graph type to the list of GraphQL interfaces implemented by this graph type.
 /// </summary>
 public void Interface(Type type) => Interfaces.Add(type);
Exemple #29
0
 /// <summary>
 /// Adds a GraphQL interface graph type to the list of GraphQL interfaces implemented by this graph type.
 /// </summary>
 public void Interface <TInterface>()
     where TInterface : IInterfaceGraphType
 => Interfaces.Add <TInterface>();
Exemple #30
0
        /// <summary>
        /// execute the script
        /// </summary>
        private void Run()
        {
            IReporter reporter = Reporter.NewInstance;

            reporter.BeginReport("path");
            while (Scripts.Count > 0)
            {
                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)
                {
                    ActionLine actLine = CurrentScript.Next();

                    if (actLine.ActionName == Constants.ActionUseInterface)
                    {
                        Interface newInterface = new Interface(Parser);
                        newInterface.PathFile = actLine.Arguments[Constants.KeywordInterface] + Parser.FileExtension;
                        Interfaces.Add(newInterface.Name, newInterface);
                    }
                    else if (actLine.ActionName == Constants.ActionStartScript)
                    {
                        Script newScript = new Script(Parser);
                        newScript.PathFile = actLine.Arguments[Constants.KeywordScript] + Parser.FileExtension;
                        Scripts.Push(CurrentScript);
                        CurrentScript = newScript;

                        // begin new section in report
                        reporter.BeginScript(CurrentScript.Name);
                    }
                    else
                    {
                        Action action = getAction(actLine);
                        if (action == null)
                        {
                            throw new InvalidOperationException("No action named '" + actLine.ActionName + "'");
                        }
                        if (!action.IsValid())
                        {
                            throw new InvalidOperationException("Invalid arguments for action named '" + actLine.ActionName + "'");
                        }

                        int ret = action.Execute();
                        action.Reset();

                        // write result of executing to report
                        reporter.WriteLine();
                    }
                }

                // end section in report
                if (CurrentScript.CurrentLineNumber > 0)
                {
                    reporter.EndScript();
                }
            }
        }
Exemple #31
0
 public DirectModeInterface(PrinterModel printer, TerminalWindow window)  : base(window, printer)
 {
     Name = "DirectMode";
     Interfaces.Add(new ActionInterface("SetTemperature", SetTemperature));
     Interfaces.Add(new ActionInterface("G-Code", ExecuteGCODE));
 }