aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common.Implementations
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2013-04-07 18:09:48 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2013-04-07 18:09:48 -0400
commitf5620c81beedc73cfec486adfd74b640961b3ccc (patch)
treee32e765e168b241e2fbeb44f60759d0c188e62ac /MediaBrowser.Common.Implementations
parent8308528e6ccb834e5fabe1ea1de7e2aa43265783 (diff)
removed unneeded startup processes
Diffstat (limited to 'MediaBrowser.Common.Implementations')
-rw-r--r--MediaBrowser.Common.Implementations/BaseApplicationHost.cs36
-rw-r--r--MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj1
-rw-r--r--MediaBrowser.Common.Implementations/Serialization/ProtobufSerializer.cs158
3 files changed, 2 insertions, 193 deletions
diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
index 0c8646508..017f69b62 100644
--- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
+++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
@@ -117,37 +117,6 @@ namespace MediaBrowser.Common.Implementations
public bool IsFirstRun { get; private set; }
/// <summary>
- /// The _protobuf serializer initialized
- /// </summary>
- private bool _protobufSerializerInitialized;
- /// <summary>
- /// The _protobuf serializer sync lock
- /// </summary>
- private object _protobufSerializerSyncLock = new object();
- /// <summary>
- /// Gets a dynamically compiled generated serializer that can serialize protocontracts without reflection
- /// </summary>
- private IProtobufSerializer _protobufSerializer;
- /// <summary>
- /// Gets the protobuf serializer.
- /// </summary>
- /// <value>The protobuf serializer.</value>
- protected IProtobufSerializer ProtobufSerializer
- {
- get
- {
- // Lazy load
- LazyInitializer.EnsureInitialized(ref _protobufSerializer, ref _protobufSerializerInitialized, ref _protobufSerializerSyncLock, () => Serialization.ProtobufSerializer.Create(AllTypes));
- return _protobufSerializer;
- }
- private set
- {
- _protobufSerializer = value;
- _protobufSerializerInitialized = value != null;
- }
- }
-
- /// <summary>
/// Gets the kernel.
/// </summary>
/// <value>The kernel.</value>
@@ -299,7 +268,6 @@ namespace MediaBrowser.Common.Implementations
RegisterSingleInstance(Logger);
RegisterSingleInstance(TaskManager);
- RegisterSingleInstance(ProtobufSerializer);
HttpClient = new HttpClientManager.HttpClientManager(ApplicationPaths, Logger);
@@ -372,6 +340,8 @@ namespace MediaBrowser.Common.Implementations
protected void RegisterSingleInstance<T>(T obj, bool manageLifetime = true)
where T : class
{
+ Logger.Info("Registering " + obj.GetType().Name);
+
Container.RegisterSingle(obj);
if (manageLifetime)
@@ -380,8 +350,6 @@ namespace MediaBrowser.Common.Implementations
if (disposable != null)
{
- Logger.Info("Registering " + disposable.GetType().Name);
-
DisposableParts.Add(disposable);
}
}
diff --git a/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj b/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj
index f5b6ab56c..c1304f39c 100644
--- a/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj
+++ b/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj
@@ -84,7 +84,6 @@
<Compile Include="ScheduledTasks\Tasks\SystemUpdateTask.cs" />
<Compile Include="Security\PluginSecurityManager.cs" />
<Compile Include="Serialization\JsonSerializer.cs" />
- <Compile Include="Serialization\ProtobufSerializer.cs" />
<Compile Include="Serialization\XmlSerializer.cs" />
<Compile Include="Updates\ApplicationUpdater.cs" />
<Compile Include="Updates\PackageManager.cs" />
diff --git a/MediaBrowser.Common.Implementations/Serialization/ProtobufSerializer.cs b/MediaBrowser.Common.Implementations/Serialization/ProtobufSerializer.cs
deleted file mode 100644
index 85325f3c1..000000000
--- a/MediaBrowser.Common.Implementations/Serialization/ProtobufSerializer.cs
+++ /dev/null
@@ -1,158 +0,0 @@
-using MediaBrowser.Model.Serialization;
-using ProtoBuf;
-using ProtoBuf.Meta;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-
-namespace MediaBrowser.Common.Implementations.Serialization
-{
- /// <summary>
- /// Creates a compiled protobuf serializer based on a set of assemblies
- /// </summary>
- public class ProtobufSerializer : IProtobufSerializer
- {
- /// <summary>
- /// Gets or sets the type model.
- /// </summary>
- /// <value>The type model.</value>
- private TypeModel TypeModel { get; set; }
-
- /// <summary>
- /// Serializes to stream.
- /// </summary>
- /// <param name="obj">The obj.</param>
- /// <param name="stream">The stream.</param>
- /// <exception cref="System.ArgumentNullException">obj</exception>
- public void SerializeToStream(object obj, Stream stream)
- {
- if (obj == null)
- {
- throw new ArgumentNullException("obj");
- }
- if (stream == null)
- {
- throw new ArgumentNullException("stream");
- }
-
- TypeModel.Serialize(stream, obj);
- }
-
- /// <summary>
- /// Deserializes from stream.
- /// </summary>
- /// <param name="stream">The stream.</param>
- /// <param name="type">The type.</param>
- /// <returns>System.Object.</returns>
- /// <exception cref="System.ArgumentNullException">stream</exception>
- public object DeserializeFromStream(Stream stream, Type type)
- {
- if (stream == null)
- {
- throw new ArgumentNullException("stream");
- }
-
- return TypeModel.Deserialize(stream, null, type);
- }
-
- /// <summary>
- /// Deserializes from stream.
- /// </summary>
- /// <typeparam name="T"></typeparam>
- /// <param name="stream">The stream.</param>
- /// <returns>``0.</returns>
- public T DeserializeFromStream<T>(Stream stream)
- where T : class
- {
- return DeserializeFromStream(stream, typeof(T)) as T;
- }
-
- /// <summary>
- /// Serializes to file.
- /// </summary>
- /// <typeparam name="T"></typeparam>
- /// <param name="obj">The obj.</param>
- /// <param name="file">The file.</param>
- /// <exception cref="System.ArgumentNullException">file</exception>
- public void SerializeToFile<T>(T obj, string file)
- {
- if (string.IsNullOrEmpty(file))
- {
- throw new ArgumentNullException("file");
- }
-
- using (Stream stream = File.Open(file, FileMode.Create))
- {
- SerializeToStream(obj, stream);
- }
- }
-
- /// <summary>
- /// Deserializes from file.
- /// </summary>
- /// <typeparam name="T"></typeparam>
- /// <param name="file">The file.</param>
- /// <returns>``0.</returns>
- /// <exception cref="System.ArgumentNullException">file</exception>
- public T DeserializeFromFile<T>(string file)
- where T : class
- {
- if (string.IsNullOrEmpty(file))
- {
- throw new ArgumentNullException("file");
- }
-
- using (Stream stream = File.OpenRead(file))
- {
- return DeserializeFromStream<T>(stream);
- }
- }
-
- /// <summary>
- /// Serializes to bytes.
- /// </summary>
- /// <typeparam name="T"></typeparam>
- /// <param name="obj">The obj.</param>
- /// <returns>System.Byte[][].</returns>
- /// <exception cref="System.ArgumentNullException">obj</exception>
- public byte[] SerializeToBytes<T>(T obj)
- where T : class
- {
- if (obj == null)
- {
- throw new ArgumentNullException("obj");
- }
-
- using (var stream = new MemoryStream())
- {
- SerializeToStream(obj, stream);
- return stream.ToArray();
- }
- }
-
- /// <summary>
- /// Creates the specified assemblies.
- /// </summary>
- /// <returns>DynamicProtobufSerializer.</returns>
- /// <exception cref="System.ArgumentNullException">assemblies</exception>
- public static ProtobufSerializer Create(IEnumerable<Type> types)
- {
- if (types == null)
- {
- throw new ArgumentNullException("types");
- }
-
- var model = TypeModel.Create();
- var attributeType = typeof(ProtoContractAttribute);
-
- // Find all ProtoContracts in the current assembly
- foreach (var type in types.Where(t => Attribute.IsDefined(t, attributeType)))
- {
- model.Add(type, true);
- }
-
- return new ProtobufSerializer { TypeModel = model.Compile() };
- }
- }
-}