private void ProcessMergedDictionariesElement(XamlFile xamlFile, XElement list, string indent) { int nMergedDictionary = 0; var children = list.Elements().ToArray(); foreach (var child in children) { ++nMergedDictionary; _log.Write(indent + nMergedDictionary + ": "); var source = child.Attribute("Source")?.Value.Trim(); if (source == null) { MergeCustomDictionary(child); } else { _log.Write("'" + source + "' => "); var sourceUri = new SourceUri(source); if (!IsKnownAssembly(sourceUri.Assembly)) { _log.WriteLine("UNKNOWN PATH"); Error(indent, $"Assembly {sourceUri.Assembly} is not listed. Please specify its path in the assembly list or add line {sourceUri.Assembly}=@xternal"); continue; } MergeDictionary(xamlFile, child, sourceUri, indent); } child.Remove(); } }
private void MergeDictionary(XamlFile parentXaml, XNode mdElement, SourceUri source, string indent) { if (_assemblyList.IsExternal(source.Assembly)) { // external assembly; add this merged dictionary to the md list of the root file _log.WriteLine("external dictionary"); if (IsAlreadyMerged(source.Uri, indent)) { return; } _mdInserter.Insert(mdElement); } else { // known assembly; read XAML file and copy its contents to the root resource dictionary var path = Path.GetFullPath(GetPathFromSourceUri(parentXaml.Path, source)); _log.WriteLine(path); if (IsAlreadyMerged(path, indent)) { return; } var assembly = source.Assembly ?? parentXaml.Assembly; var mergedXaml = new XamlFile(_fs, assembly).Read(path); MergeXamlFile(mergedXaml, indent + " "); } }
public override ConnectionInfo GetConnectionInfo() { if (sourceConnection != null) { return(sourceConnection.GetConnectionInfo()); } else { ConnectionStatus status; switch (StoppedReason) { case StopReason.UserReconnect: status = ConnectionStatus.Connecting; break; case StopReason.UserShutdown: status = ConnectionStatus.Idle; break; default: status = ConnectionStatus.Error; break; } IPEndPoint endpoint = null; string client_name = ""; return(new ConnectionInfoBuilder { ProtocolName = "RTMP Source", Type = ConnectionType.Source, Status = status, RemoteName = SourceUri.ToString(), RemoteEndPoint = endpoint, RemoteHostStatus = RemoteHostStatus.None, AgentName = client_name, }.Build()); } }
public override ConnectionInfo GetConnectionInfo() { ConnectionStatus status; switch (state) { case ConnectionState.Waiting: status = ConnectionStatus.Connecting; break; case ConnectionState.Connected: status = ConnectionStatus.Connecting; break; case ConnectionState.Receiving: status = ConnectionStatus.Connected; break; case ConnectionState.Error: status = ConnectionStatus.Error; break; default: status = ConnectionStatus.Idle; break; } IPEndPoint endpoint = null; if (this.connection?.Client?.Connected ?? false) { endpoint = (IPEndPoint)this.connection.Client.Client.RemoteEndPoint; } return(new ConnectionInfoBuilder { ProtocolName = "HTTP Push Source", Type = ConnectionType.Source, Status = status, RemoteName = SourceUri.ToString(), RemoteEndPoint = endpoint, RemoteHostStatus = (endpoint != null && endpoint.Address.IsSiteLocal()) ? RemoteHostStatus.Local : RemoteHostStatus.None, ContentPosition = contentSink.LastContent?.Position ?? 0, RecvRate = RecvRate, SendRate = SendRate, AgentName = clientName, }.Build()); }
public override ConnectionInfo GetConnectionInfo() { if (sourceConnection != null) { return(sourceConnection.GetConnectionInfo()); } else { ConnectionStatus status; switch (StoppedReason) { case StopReason.UserReconnect: status = ConnectionStatus.Connecting; break; case StopReason.UserShutdown: status = ConnectionStatus.Idle; break; default: status = ConnectionStatus.Error; break; } IPEndPoint endpoint = null; string server_name = ""; return(new ConnectionInfo( "HTTP Source", ConnectionType.Source, status, SourceUri.ToString(), endpoint, RemoteHostStatus.None, null, null, null, null, null, server_name)); } }
/// <summary> /// Custom Equals method. /// </summary> public override bool Equals(object o) { if (o.GetType() != typeof(ImageRequest)) { return(false); } ImageRequest request = (ImageRequest)o; return(SourceUri.Equals(request.SourceUri) && CacheChoice.Equals(request.CacheChoice) && SourceFile.FullName.Equals(request.SourceFile.FullName)); }
/// <summary> /// Serializes the object to XML. /// </summary> /// <param name="writer">The xml writer to which to serialize the object.</param> public void WriteXml(XmlWriter writer) { writer.WriteStartElement("sourceUri"); XmlSerializer xsrSerializer = new XmlSerializer(typeof(string)); xsrSerializer.Serialize(writer, SourceUri.ToString()); writer.WriteEndElement(); writer.WriteStartElement("sourcePath"); xsrSerializer = new XmlSerializer(typeof(string)); xsrSerializer.Serialize(writer, SourcePath); writer.WriteEndElement(); writer.WriteStartElement("sourceName"); foreach (string strCaption in SourceName) { xsrSerializer = new XmlSerializer(typeof(string)); xsrSerializer.Serialize(writer, strCaption); } writer.WriteEndElement(); writer.WriteStartElement("defaultSourcePath"); xsrSerializer = new XmlSerializer(typeof(string)); xsrSerializer.Serialize(writer, DefaultSourcePath); writer.WriteEndElement(); writer.WriteStartElement("status"); xsrSerializer = new XmlSerializer(typeof(TaskStatus)); xsrSerializer.Serialize(writer, Status); writer.WriteEndElement(); writer.WriteStartElement("downloadFiles"); foreach (Uri uriFile in DownloadFiles) { writer.WriteStartElement("file"); writer.WriteAttributeString("path", uriFile.ToString()); writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteStartElement("downloadedFiles"); foreach (string strFile in DownloadedFiles) { writer.WriteStartElement("file"); writer.WriteAttributeString("path", strFile); writer.WriteEndElement(); } writer.WriteEndElement(); }
private string GetPathFromSourceUri(string xamlFilePath, SourceUri sourceUri) { if (sourceUri.IsRelative) { var dir = Path.GetDirectoryName(xamlFilePath) ?? ""; return(Path.Combine(dir, sourceUri.Path)); } else { var assemblyPath = _assemblyList[sourceUri.Assembly]; if (assemblyPath == null) { throw new InvalidOperationException("Unknown assembly " + sourceUri.Assembly); } return(Path.Combine(_assemblyList.Root, assemblyPath, sourceUri.Path)); } }
public override ConnectionInfo GetConnectionInfo() { ConnectionStatus status; switch (state) { case State.SendingRequest: status = ConnectionStatus.Connecting; break; case State.WaitingResponse: status = ConnectionStatus.Connecting; break; case State.Receiving: status = ConnectionStatus.Connected; break; case State.Disconnected: status = ConnectionStatus.Error; break; default: status = ConnectionStatus.Idle; break; } IPEndPoint endpoint = null; if (client != null && client.Connected) { endpoint = (IPEndPoint)client.Client.RemoteEndPoint; } string server_name = ""; if (response == null || !response.Headers.TryGetValue("SERVER", out server_name)) { server_name = ""; } return(new ConnectionInfo( "HTTP Source", ConnectionType.Source, status, SourceUri.ToString(), endpoint, (endpoint != null && endpoint.Address.IsSiteLocal()) ? RemoteHostStatus.Local : RemoteHostStatus.None, lastPosition, RecvRate, SendRate, null, null, server_name)); }
public ConnectionInfo GetConnectionInfo() { var source_connection_info = SourceChannel?.SourceStream?.GetConnectionInfo(); ConnectionStatus status; switch (StoppedReason) { case StopReason.None: if (SourceChannel != null) { status = ConnectionStatus.Connected; } else { status = ConnectionStatus.Error; } break; case StopReason.OffAir: case StopReason.UserReconnect: case StopReason.UserShutdown: status = ConnectionStatus.Idle; break; default: status = ConnectionStatus.Error; break; } return(new ConnectionInfoBuilder { ProtocolName = "Loopback Source", Type = ConnectionType.Source, Status = status, RemoteName = SourceUri.ToString(), RemoteEndPoint = null, RemoteHostStatus = RemoteHostStatus.Local, ContentPosition = SourceChannel?.ContentPosition ?? 0, RecvRate = source_connection_info?.RecvRate ?? 0.0f, SendRate = source_connection_info?.SendRate ?? 0.0f, AgentName = "", }.Build()); }
public override ConnectionInfo GetConnectionInfo() { IPEndPoint endpoint = connection != null ? connection.RemoteEndPoint : null; string server_name = ""; if (response == null || !response.Headers.TryGetValue("SERVER", out server_name)) { server_name = ""; } return(new ConnectionInfoBuilder { ProtocolName = "HTTP Source", Type = ConnectionType.Source, Status = Status, RemoteName = SourceUri.ToString(), RemoteEndPoint = endpoint, RemoteHostStatus = (endpoint != null && endpoint.Address.IsSiteLocal()) ? RemoteHostStatus.Local : RemoteHostStatus.None, ContentPosition = contentSink.LastContent?.Position ?? 0, RecvRate = RecvRate, SendRate = SendRate, AgentName = server_name, }.Build()); }
public override ConnectionInfo GetConnectionInfo() { if (sourceConnection != null) { return(sourceConnection.GetConnectionInfo()); } else { return(new ConnectionInfoBuilder { ProtocolName = "Loopback Source", Type = ConnectionType.Source, Status = ConnectionStatus.Idle, RemoteName = SourceUri.ToString(), RemoteEndPoint = null, RemoteHostStatus = RemoteHostStatus.Local, ContentPosition = 0, RecvRate = RecvRate, SendRate = SendRate, AgentName = "", }.Build()); } }
public override ConnectionInfo GetConnectionInfo() { ConnectionStatus status; switch (state) { case ConnectionState.Waiting: status = ConnectionStatus.Connecting; break; case ConnectionState.Connected: status = ConnectionStatus.Connecting; break; case ConnectionState.Receiving: status = ConnectionStatus.Connected; break; case ConnectionState.Error: status = ConnectionStatus.Error; break; default: status = ConnectionStatus.Idle; break; } IPEndPoint endpoint = null; if (client != null && client.Connected) { endpoint = (IPEndPoint)client.Client.RemoteEndPoint; } return(new ConnectionInfo( "RTMP Source", ConnectionType.Source, status, SourceUri.ToString(), endpoint, (endpoint != null && endpoint.Address.IsSiteLocal()) ? RemoteHostStatus.Local : RemoteHostStatus.None, flvBuffer.Position, RecvRate, SendRate, null, null, clientName)); }
/// <summary> /// Sets the SerializationInfo object with the file name and additional exception information. /// </summary> /// <param name="info">The object that holds the serialized object data.</param> /// <param name="context">The contextual information about the source or destination.</param> public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); info.AddValue("SourceUri", SourceUri?.GetComponents(UriComponents.SerializationInfoString, UriFormat.SafeUnescaped), typeof(string)); }
//------------------------------------------------------ // // Public Methods // //------------------------------------------------------ #region Public Methods /// <summary> /// This method returns the list of selected PackageRelationships as per the /// given criteria, from a part in the Package provided /// </summary> /// <param name="package">Package object from which we get the relationsips</param> /// <returns></returns> /// <exception cref="ArgumentNullException">If package parameter is null</exception> public List <PackageRelationship> Select(Package package) { if (package == null) { throw new ArgumentNullException("package"); } List <PackageRelationship> relationships = new List <PackageRelationship>(0); switch (SelectorType) { case PackageRelationshipSelectorType.Id: if (SourceUri.Equals(PackUriHelper.PackageRootUri)) { if (package.RelationshipExists(SelectionCriteria)) { relationships.Add(package.GetRelationship(SelectionCriteria)); } } else { if (package.PartExists(SourceUri)) { PackagePart part = package.GetPart(SourceUri); if (part.RelationshipExists(SelectionCriteria)) { relationships.Add(part.GetRelationship(SelectionCriteria)); } } } break; case PackageRelationshipSelectorType.Type: if (SourceUri.Equals(PackUriHelper.PackageRootUri)) { foreach (PackageRelationship r in package.GetRelationshipsByType(SelectionCriteria)) { relationships.Add(r); } } else { if (package.PartExists(SourceUri)) { foreach (PackageRelationship r in package.GetPart(SourceUri).GetRelationshipsByType(SelectionCriteria)) { relationships.Add(r); } } } break; default: //Debug.Assert is fine here since the parameters have already been validated. And all the properties are //readonly Debug.Assert(false, "This option should never be called"); break; } return(relationships); }
/// <summary> /// Returns a summary of the descriptor. /// </summary> /// <returns>A summary of the descriptor.</returns> public override string ToString() { return(String.Format("{0} => {1} ({2})", SourceUri.ToString(), SourcePath, DownloadFiles.Count)); }