jellyfin/Emby.Dlna/ConnectionManager/ServiceActionListBuilder.cs
Erwin de Haan ec1f5dc317 Mayor code cleanup
Add Argument*Exceptions now use proper nameof operators.

Added exception messages to quite a few Argument*Exceptions.

Fixed rethorwing to be proper syntax.

Added a ton of null checkes. (This is only a start, there are about 500 places that need proper null handling)

Added some TODOs to log certain exceptions.

Fix sln again.

Fixed all AssemblyInfo's and added proper copyright (where I could find them)

We live in *current year*.

Fixed the use of braces.

Fixed a ton of properties, and made a fair amount of functions static that should be and can be static.

Made more Methods that should be static static.

You can now use static to find bad functions!

Removed unused variable. And added one more proper XML comment.
2019-01-10 20:38:53 +01:00

206 lines
5.6 KiB
C#

using Emby.Dlna.Common;
using System.Collections.Generic;
namespace Emby.Dlna.ConnectionManager
{
public class ServiceActionListBuilder
{
public IEnumerable<ServiceAction> GetActions()
{
var list = new List<ServiceAction>
{
GetCurrentConnectionInfo(),
GetProtocolInfo(),
GetCurrentConnectionIDs(),
ConnectionComplete(),
PrepareForConnection()
};
return list;
}
private static ServiceAction PrepareForConnection()
{
var action = new ServiceAction
{
Name = "PrepareForConnection"
};
action.ArgumentList.Add(new Argument
{
Name = "RemoteProtocolInfo",
Direction = "in",
RelatedStateVariable = "A_ARG_TYPE_ProtocolInfo"
});
action.ArgumentList.Add(new Argument
{
Name = "PeerConnectionManager",
Direction = "in",
RelatedStateVariable = "A_ARG_TYPE_ConnectionManager"
});
action.ArgumentList.Add(new Argument
{
Name = "PeerConnectionID",
Direction = "in",
RelatedStateVariable = "A_ARG_TYPE_ConnectionID"
});
action.ArgumentList.Add(new Argument
{
Name = "Direction",
Direction = "in",
RelatedStateVariable = "A_ARG_TYPE_Direction"
});
action.ArgumentList.Add(new Argument
{
Name = "ConnectionID",
Direction = "out",
RelatedStateVariable = "A_ARG_TYPE_ConnectionID"
});
action.ArgumentList.Add(new Argument
{
Name = "AVTransportID",
Direction = "out",
RelatedStateVariable = "A_ARG_TYPE_AVTransportID"
});
action.ArgumentList.Add(new Argument
{
Name = "RcsID",
Direction = "out",
RelatedStateVariable = "A_ARG_TYPE_RcsID"
});
return action;
}
private static ServiceAction GetCurrentConnectionInfo()
{
var action = new ServiceAction
{
Name = "GetCurrentConnectionInfo"
};
action.ArgumentList.Add(new Argument
{
Name = "ConnectionID",
Direction = "in",
RelatedStateVariable = "A_ARG_TYPE_ConnectionID"
});
action.ArgumentList.Add(new Argument
{
Name = "RcsID",
Direction = "out",
RelatedStateVariable = "A_ARG_TYPE_RcsID"
});
action.ArgumentList.Add(new Argument
{
Name = "AVTransportID",
Direction = "out",
RelatedStateVariable = "A_ARG_TYPE_AVTransportID"
});
action.ArgumentList.Add(new Argument
{
Name = "ProtocolInfo",
Direction = "out",
RelatedStateVariable = "A_ARG_TYPE_ProtocolInfo"
});
action.ArgumentList.Add(new Argument
{
Name = "PeerConnectionManager",
Direction = "out",
RelatedStateVariable = "A_ARG_TYPE_ConnectionManager"
});
action.ArgumentList.Add(new Argument
{
Name = "PeerConnectionID",
Direction = "out",
RelatedStateVariable = "A_ARG_TYPE_ConnectionID"
});
action.ArgumentList.Add(new Argument
{
Name = "Direction",
Direction = "out",
RelatedStateVariable = "A_ARG_TYPE_Direction"
});
action.ArgumentList.Add(new Argument
{
Name = "Status",
Direction = "out",
RelatedStateVariable = "A_ARG_TYPE_ConnectionStatus"
});
return action;
}
private ServiceAction GetProtocolInfo()
{
var action = new ServiceAction
{
Name = "GetProtocolInfo"
};
action.ArgumentList.Add(new Argument
{
Name = "Source",
Direction = "out",
RelatedStateVariable = "SourceProtocolInfo"
});
action.ArgumentList.Add(new Argument
{
Name = "Sink",
Direction = "out",
RelatedStateVariable = "SinkProtocolInfo"
});
return action;
}
private ServiceAction GetCurrentConnectionIDs()
{
var action = new ServiceAction
{
Name = "GetCurrentConnectionIDs"
};
action.ArgumentList.Add(new Argument
{
Name = "ConnectionIDs",
Direction = "out",
RelatedStateVariable = "CurrentConnectionIDs"
});
return action;
}
private ServiceAction ConnectionComplete()
{
var action = new ServiceAction
{
Name = "ConnectionComplete"
};
action.ArgumentList.Add(new Argument
{
Name = "ConnectionID",
Direction = "in",
RelatedStateVariable = "A_ARG_TYPE_ConnectionID"
});
return action;
}
}
}