/// <summary> /// Constructs a client for executing all api commands. /// </summary> /// <param name="subdomain">The harvest account subdomain</param> /// <param name="username">The harvest account username (optional for OAuth)</param> /// <param name="password">The harvest account password (optional for OAuth)</param> /// <param name="clientId">The harvest account client OAuth ID (optional for basic auth)</param> /// <param name="clientSecret">The harvest account client OAuth secret (optional for basic auth)</param> /// <param name="accessToken">The harvest account OAuth token (optional for basic auth)</param> /// <param name="dateFormat">The date format of the harvest account (default: yyyy-MM-dd)</param> private HarvestRestClient(string subdomain, string username, string password, string clientId, string clientSecret, string accessToken, string dateFormat, IAssemblyInformation assemblyInformation, IEnvironmentInformation environmentInformation, IRestSharpFactory restSharpFactory) { this.Username = username; this.Password = password; this.ClientId = clientId; this.ClientSecret = clientSecret; this.AccessToken = accessToken; this.DateFormat = dateFormat ?? "yyyy-MM-dd"; this.BaseUrl = "https://" + subdomain + ".harvestapp.com/"; var assemblyVersion = assemblyInformation.Version; var environmentVersion = environmentInformation.Version; var userAgent = string.Format("harvest.net/{0} (.NET {1})", assemblyVersion, environmentVersion); if (username != null && password != null) { _client = restSharpFactory.GetWebClient(BaseUrl, userAgent, username, password); } else if (accessToken != null) { _client = restSharpFactory.GetWebClient(BaseUrl, userAgent, accessToken); } else { _client = restSharpFactory.GetWebClient(BaseUrl, userAgent); } }
private static void ProcessCustomAttributes(IAssemblyInformation asm, Dictionary <string, string[]> aliases) { foreach ( var attr in asm.CustomAttributes.Where(a => a.TypeFullName == "Avalonia.Metadata.XmlnsDefinitionAttribute" || a.TypeFullName == "Portable.Xaml.Markup.XmlnsDefinitionAttribute")) { var ns = attr.ConstructorArguments[1].Value.ToString(); var current = new[] { attr.ConstructorArguments[0].Value.ToString() }; string[] allns = null; if (aliases.TryGetValue(ns, out allns)) { allns = allns.Union(current).Distinct().ToArray(); } aliases[ns] = allns ?? current; } }
/// <summary> /// Initializes a new client using basic HTTP authentication and non-default dependencies /// </summary> /// <param name="subdomain">The subdomain of the harvest account to connect to</param> /// <param name="username">The username to authenticate with</param> /// <param name="password">The password to authenticate with</param> public HarvestRestClient(string subdomain, string username, string password, IAssemblyInformation assemblyInformation, IEnvironmentInformation environmentInformation, IRestSharpFactory restSharpFactory) : this(subdomain, username, password, null, null, null, null, assemblyInformation, environmentInformation, restSharpFactory) { }
/// <summary> /// Initializes a new instance of the <see cref="AboutBox"/> class. /// Default constructor is protected so callers must use one with a parent. /// </summary> /// <param name="loadedAssemblies">The loaded assemblies.</param> /// <param name="entryAssembly">The entry assembly.</param> protected AboutBox(IEnumerable <IAssemblyInformation> loadedAssemblies, IAssemblyInformation entryAssembly) { this.InitializeComponent(); this.DataContext = new AboutBoxVm(loadedAssemblies, entryAssembly); }
/// <summary> /// Initializes a new instance of the <see cref="AboutBox"/> class. /// Constructor that takes a parent for this AboutBox dialog. /// </summary> /// <param name="parent">The parent.</param> /// <param name="loadedAssemblies">The loaded assemblies.</param> /// <param name="entryAssembly">The entry assembly.</param> public AboutBox(Window parent, IEnumerable <IAssemblyInformation> loadedAssemblies, IAssemblyInformation entryAssembly) : this(loadedAssemblies, entryAssembly) { this.Owner = parent; }
public bool Equals(IAssemblyInformation other) { return(this.UniqueName.Equals(other.UniqueName)); }
private static void ProcessWellKnownAliases(IAssemblyInformation asm, Dictionary <string, string[]> aliases) { //look like we don't have xmlns for avalonia.layout TODO: add it in avalonia //may be don 't remove it for avalonia 0.7 or below for support completion for layout enums etc. aliases["Avalonia.Layout"] = new[] { "https://github.com/avaloniaui" }; }
private static void ProcessAvaloniaResources(IAssemblyInformation asm, ITypeInformation[] asmTypes, List <AvaresInfo> avaresValues) { const string avaresToken = "Build:"; //or "Populate:" should work both ways void registeravares(string localUrl, string returnTypeFullName = "") { var globalUrl = $"avares://{asm.Name}{localUrl}"; if (!avaresValues.Any(v => v.GlobalUrl == globalUrl)) { var avres = new AvaresInfo { Assembly = asm, LocalUrl = localUrl, GlobalUrl = globalUrl, ReturnTypeFullName = returnTypeFullName }; avaresValues.Add(avres); } } var resType = asmTypes.FirstOrDefault(t => t.FullName == "CompiledAvaloniaXaml.!AvaloniaResources"); if (resType != null) { foreach (var res in resType.Methods.Where(m => m.Name.StartsWith(avaresToken))) { registeravares(res.Name.Replace(avaresToken, ""), res.ReturnTypeFullName ?? ""); } } //try add avares Embedded resources like image,stream and x:Class if (asm.ManifestResourceNames.Contains("!AvaloniaResources")) { try { using (var avaresStream = asm.GetManifestResourceStream("!AvaloniaResources")) using (var r = new BinaryReader(avaresStream)) { var ms = new MemoryStream(r.ReadBytes(r.ReadInt32())); var br = new BinaryReader(ms); int version = br.ReadInt32(); if (version == 1) { var assetDoc = XDocument.Load(ms); var ns = assetDoc.Root.GetDefaultNamespace(); var avaResEntries = assetDoc.Root.Element(ns.GetName("Entries")).Elements(ns.GetName("AvaloniaResourcesIndexEntry")) .Select(entry => new { Path = entry.Element(ns.GetName("Path")).Value, Offset = int.Parse(entry.Element(ns.GetName("Offset")).Value), Size = int.Parse(entry.Element(ns.GetName("Size")).Value) }).ToArray(); var xClassEntries = avaResEntries.FirstOrDefault(v => v.Path == "/!AvaloniaResourceXamlInfo"); //get information about x:Class resources if (xClassEntries != null && xClassEntries.Size > 0) { try { avaresStream.Seek(xClassEntries.Offset, SeekOrigin.Current); var xClassDoc = XDocument.Load(new MemoryStream(r.ReadBytes(xClassEntries.Size))); var xClassMappingNode = xClassDoc.Root.Element(xClassDoc.Root.GetDefaultNamespace().GetName("ClassToResourcePathIndex")); if (xClassMappingNode != null) { const string arraysNs = "http://schemas.microsoft.com/2003/10/Serialization/Arrays"; var keyvalueofss = XName.Get("KeyValueOfstringstring", arraysNs); var keyName = XName.Get("Key", arraysNs); var valueName = XName.Get("Value", arraysNs); var xClassMappings = xClassMappingNode.Elements(keyvalueofss) .Where(e => e.Elements(keyName).Any() && e.Elements(valueName).Any()) .Select(e => new { Type = e.Element(keyName).Value, Path = e.Element(valueName).Value, }).ToArray(); foreach (var xcm in xClassMappings) { var resultType = asmTypes.FirstOrDefault(t => t.FullName == xcm.Type); //if we need another check //if (resultType?.Methods?.Any(m => m.Name == "!XamlIlPopulate") ?? false) if (resultType != null) { //we set here base class like Style, Styles, UserControl so we can manage //resources in a common way later registeravares(xcm.Path, resultType.GetBaseType()?.FullName ?? ""); } } } } catch (Exception xClassEx) { Console.WriteLine($"Failed fetch avalonia x:class resources in {asm.Name}, {xClassEx.Message}"); } } //add other img/stream resources foreach (var entry in avaResEntries.Where(v => !v.Path.StartsWith("/!"))) { registeravares(entry.Path); } } } } catch (Exception ex) { Console.WriteLine($"Failed fetch avalonia resources in {asm.Name}, {ex.Message}"); } } }
public bool Equals(IAssemblyInformation other) => this.UniqueName.Equals(other.UniqueName);
/// <summary> /// Initializes a new instance of the <see cref="AboutBoxVm"/> class. /// </summary> /// <param name="loadedAssemblies">The loaded assemblies.</param> /// <param name="entryAssembly">The entry assembly.</param> public AboutBoxVm(IEnumerable <IAssemblyInformation> loadedAssemblies, IAssemblyInformation entryAssembly) { this.AssemblyInfoList = new AssemblyInfoListVm(loadedAssemblies); this.EntryAssembly = entryAssembly; }