Browse Source

Addendum

feature/linux-automation
Jumar Macato 2 years ago
parent
commit
0f9a856e96
  1. 1
      Avalonia.Desktop.slnf
  2. 7
      Avalonia.sln
  3. 2
      src/Avalonia.FreeDesktop/Avalonia.FreeDesktop.csproj
  4. 1063
      src/Linux/Tmds.DBus/Connection2.cs
  5. 179
      src/Linux/Tmds.DBus/ObjectPath2.cs

1
Avalonia.Desktop.slnf

@ -41,6 +41,7 @@
"src\\Linux\\Avalonia.LinuxFramebuffer\\Avalonia.LinuxFramebuffer.csproj",
"src\\Linux\\Tmds.DBus.Protocol\\Tmds.DBus.Protocol.csproj",
"src\\Linux\\Tmds.DBus.SourceGenerator\\Tmds.DBus.SourceGenerator.csproj",
"src\\Linux\\Tmds.DBus\\Tmds.DBus.csproj",
"src\\Markup\\Avalonia.Markup.Xaml.Loader\\Avalonia.Markup.Xaml.Loader.csproj",
"src\\Markup\\Avalonia.Markup.Xaml\\Avalonia.Markup.Xaml.csproj",
"src\\Markup\\Avalonia.Markup\\Avalonia.Markup.csproj",

7
Avalonia.sln

@ -306,6 +306,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tmds.DBus.Protocol", "src\L
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tmds.DBus.SourceGenerator", "src\Linux\Tmds.DBus.SourceGenerator\Tmds.DBus.SourceGenerator.csproj", "{FFE8B040-B467-424A-9DDB-6155DC1EB62E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tmds.DBus", "src\Linux\Tmds.DBus\Tmds.DBus.csproj", "{1ABAB94E-D687-4E3B-8489-39EDCFA91653}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -714,6 +716,10 @@ Global
{FFE8B040-B467-424A-9DDB-6155DC1EB62E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FFE8B040-B467-424A-9DDB-6155DC1EB62E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FFE8B040-B467-424A-9DDB-6155DC1EB62E}.Release|Any CPU.Build.0 = Release|Any CPU
{1ABAB94E-D687-4E3B-8489-39EDCFA91653}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1ABAB94E-D687-4E3B-8489-39EDCFA91653}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1ABAB94E-D687-4E3B-8489-39EDCFA91653}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1ABAB94E-D687-4E3B-8489-39EDCFA91653}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -803,6 +809,7 @@ Global
{9AE1B827-21AC-4063-AB22-C8804B7F931E} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B}
{18B242C7-33BC-4B40-B12C-82B20F2BF638} = {86C53C40-57AA-45B8-AD42-FAE0EFDF0F2B}
{FFE8B040-B467-424A-9DDB-6155DC1EB62E} = {86C53C40-57AA-45B8-AD42-FAE0EFDF0F2B}
{1ABAB94E-D687-4E3B-8489-39EDCFA91653} = {86C53C40-57AA-45B8-AD42-FAE0EFDF0F2B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {87366D66-1391-4D90-8999-95A620AD786A}

2
src/Avalonia.FreeDesktop/Avalonia.FreeDesktop.csproj

@ -20,6 +20,8 @@
OutputItemType="Analyzer"
ReferenceOutputAssembly="false"
PrivateAssets="all"/>
<ProjectReference Include="..\Linux\Tmds.DBus\Tmds.DBus.csproj" />
</ItemGroup>
<ItemGroup>

1063
src/Linux/Tmds.DBus/Connection2.cs

File diff suppressed because it is too large

179
src/Linux/Tmds.DBus/ObjectPath2.cs

@ -0,0 +1,179 @@
// Copyright 2006 Alp Toker <alp@atoker.com>
// Copyright 2010 Alan McGovern <alan.mcgovern@gmail.com>
// This software is made available under the MIT License
// See COPYING for details
using System;
namespace Tmds.DBus
{
/// <summary>
/// Path to D-Bus object.
/// </summary>
public struct ObjectPath2 : IComparable, IComparable<ObjectPath2>, IEquatable<ObjectPath2>
{
/// <summary>
/// Root path (<c>"/"</c>).
/// </summary>
public static readonly ObjectPath2 Root = new ObjectPath2("/");
internal readonly string Value;
/// <summary>
/// Creates a new ObjectPath.
/// </summary>
/// <param name="value">path.</param>
public ObjectPath2(string value)
{
if (value == null)
throw new ArgumentNullException("value");
Validate(value);
this.Value = value;
}
static void Validate(string value)
{
if (!value.StartsWith("/", StringComparison.Ordinal))
throw new ArgumentException("value");
if (value.EndsWith("/", StringComparison.Ordinal) && value.Length > 1)
throw new ArgumentException("ObjectPath cannot end in '/'");
bool multipleSlash = false;
foreach (char c in value)
{
bool valid = (c >= 'a' && c <= 'z')
|| (c >= 'A' && c <= 'Z')
|| (c >= '0' && c <= '9')
|| c == '_'
|| (!multipleSlash && c == '/');
if (!valid)
{
var message = string.Format("'{0}' is not a valid character in an ObjectPath", c);
throw new ArgumentException(message, "value");
}
multipleSlash = c == '/';
}
}
/// <summary>
/// Compares the current instance with another object of the same type and returns an integer that
/// indicates whether the current instance precedes, follows, or occurs in the same position in
/// the sort order as the other object.
/// </summary>
public int CompareTo(ObjectPath2 other)
{
return Value.CompareTo(other.Value);
}
/// <summary>
/// Compares the current instance with another object of the same type and returns an integer that
/// indicates whether the current instance precedes, follows, or occurs in the same position in
/// the sort order as the other object.
/// </summary>
public int CompareTo(object otherObject)
{
var other = otherObject as ObjectPath2?;
if (other == null)
return 1;
return Value.CompareTo(other.Value.Value);
}
/// <summary>
/// Determines whether the specified object is equal to the current object.
/// </summary>
public bool Equals(ObjectPath2 other)
{
return Value == other.Value;
}
/// <summary>
/// Determines whether the specified object is equal to the current object.
/// </summary>
public override bool Equals(object o)
{
var b = o as ObjectPath2?;
if (b == null)
return false;
return Value.Equals(b.Value.Value, StringComparison.Ordinal);
}
/// <summary>
/// Determines whether two specified ObjectPaths have the same value.
/// </summary>
public static bool operator==(ObjectPath2 a, ObjectPath2 b)
{
return a.Value == b.Value;
}
/// <summary>
/// Determines whether two specified ObjectPaths have different values.
/// </summary>
public static bool operator!=(ObjectPath2 a, ObjectPath2 b)
{
return !(a == b);
}
/// <summary>
/// Returns the hash code for this ObjectPath.
/// </summary>
public override int GetHashCode()
{
if (Value == null)
{
return 0;
}
return Value.GetHashCode();
}
/// <summary>
/// Returns a string that represents the current object.
/// </summary>
public override string ToString()
{
return Value;
}
/// <summary>
/// Creates the ObjectPath that is represented by the string value.
/// </summary>
/// <param name="value">path.</param>
public static implicit operator ObjectPath2(string value)
{
return new ObjectPath2(value);
}
//this may or may not prove useful
internal string[] Decomposed
{
get
{
return Value.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
}
}
internal ObjectPath2 Parent
{
get
{
if (Value == Root.Value)
return null;
string par = Value.Substring(0, Value.LastIndexOf('/'));
if (par == String.Empty)
par = "/";
return new ObjectPath2(par);
}
}
}
}
Loading…
Cancel
Save