/// <summary> /// Constructor for gate class /// </summary> /// <param name="gatename">String containing the gate name</param> /// <param name="gatetype">Gates Enum containing gatetype</param> /// <param name="outputs">List of pins containing gate outputs</param> /// <param name="inputs">List of pins containing gate inputs</param> /// <param name="bussize">Int containing gate bussize</param> public Gate(String gatename, SymbolTypes gateType, List <Pin> outputs, List <Pin> inputs, int bussize) { this.gateType = gateType; this.outputs = outputs; this.inputs = inputs; this.gatename = gatename; this.bussize = bussize; }
public TypeFilter(SymbolTypes?type) { if (type.HasValue) { Enabled = true; _type = type.Value; } }
public static bool AddSymbol(string value, SymbolTypes type) { if (!All.TryGetValue(value, out var s)) { var tmp = new Symbol(value, type); All.Add(value, tmp); Added.Add(value, tmp); return(true); } return(false); }
//Use addgate() with gatename, gatetype, a single output, and a List of inputs. //to add a gate to the module. Valid gatetypes are "and","or","xor","nand","nor","xnor","not", and is not case sensitive. //The "not" gate may only recieve one input. /// <summary> /// This method adds an individual gate to the circuit /// </summary> /// <param name="gateName">String containing the unique gate name</param> /// <param name="gateType">Gate.Gates enum containing gate type</param> /// <param name="outs">List of Pin.Pins containing the outputs of the gate</param> /// <param name="ins">List of Pin.Pins containing the inputs to the gate</param> /// <returns>Boolean indicating whether the gate was successfully added</returns> public Boolean addGate(string gateName, SymbolTypes gateType, List <Pin> outs, List <Pin> ins) { //if the gate is invalidate, return false if (gateName == null || outs == null || ins == null) { return(false); } //log the gatename gateOrder.Add(gateName); //Construct the gate and add it to the dictionary Gate newGate = new Gate(gateName, gateType, outs, ins, outs[0].bussize); gateData.Add(gateName, newGate); return(true); }
private static string GetString(this Random random, int length, SymbolTypes symbolTypes = SymbolTypes.Digits | SymbolTypes.Latin) { if (length < 0) { throw new ArgumentException("Length should be greater or equal than zero.", nameof(length)); } if (length == 0) { return(string.Empty); } var builder = new StringBuilder(); for (int i = 0; i < length; i++) { builder.Append(random.GetChar(symbolTypes)); } return(builder.ToString()); }
private static char GetChar(this Random random, SymbolTypes symbolTypes) { var numberOfTypes = 0; if (symbolTypes.HasFlag(SymbolTypes.Digits)) { numberOfTypes++; } if (symbolTypes.HasFlag(SymbolTypes.Latin)) { numberOfTypes++; } if (symbolTypes.HasFlag(SymbolTypes.Cyrillic)) { numberOfTypes++; } var power = random.Next(numberOfTypes); var concreteType = (SymbolTypes)Math.Pow(2, power); switch (concreteType) { case SymbolTypes.Digits: return(random.GetDigitChar()); case SymbolTypes.Latin: return(random.GetLatinChar()); case SymbolTypes.Cyrillic: return(random.GetCyrillicChar()); default: throw new ArgumentOutOfRangeException(nameof(concreteType)); } }
public Symbol(SymbolTypes type, string identifier) { this.type = type; this.identifier = identifier; }
public Symbol(SymbolTypes type, double value) { this.type = type; this.value = value; }
public string identifier; //for Parameter and Function types public Symbol(SymbolTypes type, char keyword) { this.type = type; this.keyword = keyword; }
public Symbol(string value, SymbolTypes type) { this.Value = value; this.Type = type; }
/// <summary> /// This creates a wrapper class encapsulates one of the available subclasses for /// symbol, enumerating the different options. /// </summary> /// <param name="type">The type to use for this symbol.</param> public Symbol(SymbolTypes type) { SetInnerSymbol(type); }
private void SetInnerSymbol(SymbolTypes type) { ISymbol newSymbol = null; // If this class is acting as a wrapper class, then it should update the internal IStroke. switch (type) { case SymbolTypes.Character: newSymbol = new CharacterSymbol(); break; case SymbolTypes.Picture: newSymbol = new PictureSymbol(); break; case SymbolTypes.Simple: newSymbol = new SimpleSymbol(); break; } if (newSymbol != null) { if (_innerSymbol != null) newSymbol.CopyPlacement(_innerSymbol); } _innerSymbol = newSymbol; }
public static char GetChar(SymbolTypes symbolTypes) { return(DefaultRandom.GetChar(symbolTypes)); }
public static string GetString(int length, SymbolTypes symbolTypes = SymbolTypes.Digits | SymbolTypes.Latin) { return(DefaultRandom.GetString(length, symbolTypes)); }