public static IGraphType CreateGraphType(IConnectionType connectionType) { var graphType = Substitute.For <IGraphType>(); graphType.FindConnectionType(Arg.Any <Type>(), Arg.Any <Type>()).ReturnsForAnyArgs(connectionType); return(graphType); }
// The constructor creates a Connection from the source to the destination public Connection(IConnectable source, string sourceOutput, IConnectable destination, string destinationInput, Color typeColor) { Source = source; SourceOutput = sourceOutput; Destination = destination; DestinationInput = destinationInput; ConnectionType = ConnectionTypeFactory.GetType(typeColor); }
public static void RegisterType(Color color, IConnectionType type) { if (m_types.ContainsKey(color)) { throw new TypeAlreadyRegisteredException(color, m_types[color], type); } m_types.Add(color, type); }
public static Color GetColor(IConnectionType type) { var color = m_types.FirstOrDefault(kvp => kvp.Value == type).Key; if (color == default(Color)) { throw new NoSuchTypeException(type); } return(color); }
public QueryAsync ( ILoggerFactory loggerFactory, IConnectionType s7ConnectionTypeRepository, ICpuType s7CpuTypeRepository, IArea s7AreaRepository, IWordLen s7WordLenRepository, IConnection s7ConnectionRepository ) { _logger = loggerFactory.CreateLogger <QueryAsync>(); _s7ConnectionTypeRepository = s7ConnectionTypeRepository; _s7CpuTypeRepository = s7CpuTypeRepository; _s7AreaRepository = s7AreaRepository; _s7WordLenRepository = s7WordLenRepository; _s7ConnectionRepository = s7ConnectionRepository; }
/// <summary> /// Prüft anhand der XML - Datei, ob eine neue Version verfügbar ist /// </summary> /// <param name="xmlLink"></param> URL or path of the xml file that contains information about latest version of the application. public static async void Start(string xmlLink) { try { XmlLink = new Uri(xmlLink); UpdateInfoEventArgs updateInfo = null; if (XmlLink.Scheme.Equals(Uri.UriSchemeHttp) || XmlLink.Scheme.Equals(Uri.UriSchemeHttps)) { connectionType = new ConnectionTypeWeb(); } else if (XmlLink.Scheme.Equals(Uri.UriSchemeFile)) { connectionType = new ConnectionTypeFile(); } updateInfo = await connectionType.ReadXmlFileAsync(XmlLink); bool IsUpdateAvailable = CheckForUpdate(updateInfo); // TODO: Wollen Sie das Update durchführen? Uri downloadLink = new Uri(updateInfo.DownloadURL); if (downloadLink.Scheme.Equals(Uri.UriSchemeHttp) || downloadLink.Scheme.Equals(Uri.UriSchemeHttps)) { connectionType = new ConnectionTypeWeb(); } else if (downloadLink.Scheme.Equals(Uri.UriSchemeFile)) { connectionType = new ConnectionTypeFile(); } connectionType.DownloadProgressChanged += DownloadUpdateProgressChanged; await connectionType.StartDownloadAsync(updateInfo.DownloadURL, Path.GetFullPath(updateInfo.DownloadFileName)); Console.WriteLine($"***** {updateInfo.DownloadURL} *****"); } catch (Exception exception) { ShowError(exception); } }
public IConnection Connect(IConnectable destination, string outputName, string inputName, IConnectionType type) { return(Connect(destination, outputName, inputName, ConnectionTypeFactory.GetColor(type))); }
public IConnection Connect(IConnectable destination, string outputName, string inputName, IConnectionType type) { return(NullConnection.Instance); }
public TypeAlreadyRegisteredException(Color color, IConnectionType existingType, IConnectionType newType) : base(string.Format("Color \"{0}\" has already been registered by type \"{1} ({2})\" and cannot be registered by type \"{3} ({4})\"", color.ToString(), (existingType as IJavaType).Name, (existingType as ICPPType).Name, (newType as IJavaType).Name, (newType as ICPPType).Name)) { }
public NoSuchTypeException(IConnectionType type) : base(string.Format("No color is associated to connection type \"{0} ({1})\"", (type as IJavaType).Name, (type as ICPPType).Name)) { }