From f5620c81beedc73cfec486adfd74b640961b3ccc Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 7 Apr 2013 18:09:48 -0400 Subject: removed unneeded startup processes --- .../BaseApplicationHost.cs | 36 +---- .../MediaBrowser.Common.Implementations.csproj | 1 - .../Serialization/ProtobufSerializer.cs | 158 --------------------- 3 files changed, 2 insertions(+), 193 deletions(-) delete mode 100644 MediaBrowser.Common.Implementations/Serialization/ProtobufSerializer.cs (limited to 'MediaBrowser.Common.Implementations') 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 @@ -116,37 +116,6 @@ namespace MediaBrowser.Common.Implementations /// true if this instance is first run; otherwise, false. public bool IsFirstRun { get; private set; } - /// - /// The _protobuf serializer initialized - /// - private bool _protobufSerializerInitialized; - /// - /// The _protobuf serializer sync lock - /// - private object _protobufSerializerSyncLock = new object(); - /// - /// Gets a dynamically compiled generated serializer that can serialize protocontracts without reflection - /// - private IProtobufSerializer _protobufSerializer; - /// - /// Gets the protobuf serializer. - /// - /// The protobuf serializer. - 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; - } - } - /// /// Gets the kernel. /// @@ -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 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 @@ - 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 -{ - /// - /// Creates a compiled protobuf serializer based on a set of assemblies - /// - public class ProtobufSerializer : IProtobufSerializer - { - /// - /// Gets or sets the type model. - /// - /// The type model. - private TypeModel TypeModel { get; set; } - - /// - /// Serializes to stream. - /// - /// The obj. - /// The stream. - /// obj - 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); - } - - /// - /// Deserializes from stream. - /// - /// The stream. - /// The type. - /// System.Object. - /// stream - public object DeserializeFromStream(Stream stream, Type type) - { - if (stream == null) - { - throw new ArgumentNullException("stream"); - } - - return TypeModel.Deserialize(stream, null, type); - } - - /// - /// Deserializes from stream. - /// - /// - /// The stream. - /// ``0. - public T DeserializeFromStream(Stream stream) - where T : class - { - return DeserializeFromStream(stream, typeof(T)) as T; - } - - /// - /// Serializes to file. - /// - /// - /// The obj. - /// The file. - /// file - public void SerializeToFile(T obj, string file) - { - if (string.IsNullOrEmpty(file)) - { - throw new ArgumentNullException("file"); - } - - using (Stream stream = File.Open(file, FileMode.Create)) - { - SerializeToStream(obj, stream); - } - } - - /// - /// Deserializes from file. - /// - /// - /// The file. - /// ``0. - /// file - public T DeserializeFromFile(string file) - where T : class - { - if (string.IsNullOrEmpty(file)) - { - throw new ArgumentNullException("file"); - } - - using (Stream stream = File.OpenRead(file)) - { - return DeserializeFromStream(stream); - } - } - - /// - /// Serializes to bytes. - /// - /// - /// The obj. - /// System.Byte[][]. - /// obj - public byte[] SerializeToBytes(T obj) - where T : class - { - if (obj == null) - { - throw new ArgumentNullException("obj"); - } - - using (var stream = new MemoryStream()) - { - SerializeToStream(obj, stream); - return stream.ToArray(); - } - } - - /// - /// Creates the specified assemblies. - /// - /// DynamicProtobufSerializer. - /// assemblies - public static ProtobufSerializer Create(IEnumerable 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() }; - } - } -} -- cgit v1.2.3