-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
173 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
FluentProtobufNet/Exceptions/FieldIdAlreadyUsedException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
using ProtoBuf.Meta; | ||
|
||
namespace FluentProtobufNet.Exceptions | ||
{ | ||
public class FieldIdAlreadyUsedException : Exception | ||
{ | ||
public FieldIdAlreadyUsedException(int fieldId, MetaType usedBy): base("The field ID " + fieldId + " has already been used by " + usedBy.Name) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
|
||
namespace FluentProtobufNet | ||
{ | ||
public class InstantiationException : Exception | ||
{ | ||
public string Message { get; set; } | ||
public Exception Exception { get; set; } | ||
public Type Type { get; set; } | ||
|
||
public InstantiationException(string message, Exception exception, Type type) | ||
{ | ||
Message = message; | ||
Exception = exception; | ||
Type = type; | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
FluentProtobufNet/Exceptions/MissingConstructorException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
|
||
namespace FluentProtobufNet.Exceptions | ||
{ | ||
public class MissingConstructorException : Exception | ||
{ | ||
public Type Type { get; set; } | ||
|
||
public MissingConstructorException(Type type) | ||
{ | ||
Type = type; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
FluentProtobufNet/Helpers/LinqExtensions.cs → FluentProtobufNet/Helpers/Extensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Reflection; | ||
|
||
namespace FluentProtobufNet.Helpers | ||
{ | ||
public class ReflectHelper | ||
{ | ||
public const BindingFlags AnyVisibilityInstance = BindingFlags.Instance | BindingFlags.Public | | ||
BindingFlags.NonPublic; | ||
private static readonly Type[] NoClasses = Type.EmptyTypes; | ||
|
||
public static ConstructorInfo GetDefaultConstructor(Type type) | ||
{ | ||
if (IsAbstractClass(type)) | ||
return null; | ||
|
||
try | ||
{ | ||
ConstructorInfo constructor = | ||
type.GetConstructor(AnyVisibilityInstance, null, CallingConventions.HasThis, NoClasses, null); | ||
return constructor; | ||
} | ||
catch (Exception e) | ||
{ | ||
throw new InstantiationException("A default (no-arg) constructor could not be found for: ", e, type); | ||
} | ||
} | ||
|
||
public static bool IsAbstractClass(System.Type type) | ||
{ | ||
return (type.IsAbstract || type.IsInterface); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace FluentProtobufNet | ||
{ | ||
public interface IDiagnosticLogger | ||
{ | ||
void Flush(); | ||
void FluentMappingDiscovered(Type type); | ||
void ConventionDiscovered(Type type); | ||
void LoadedFluentMappingsFromSource(ITypeSource source); | ||
void LoadedConventionsFromSource(ITypeSource source); | ||
void AutomappingSkippedType(Type type, string reason); | ||
void AutomappingCandidateTypes(IEnumerable<Type> types); | ||
void BeginAutomappingType(Type type); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using ProtoBuf.Meta; | ||
|
||
namespace FluentProtobufNet | ||
{ | ||
public interface IMappingProvider | ||
{ | ||
RuntimeTypeModel GetRuntimeTypeModel(RuntimeTypeModel protobufModel); | ||
// HACK: In place just to keep compatibility until verdict is made | ||
//HibernateMapping GetHibernateMapping(); | ||
//IEnumerable<Member> GetIgnoredProperties(); | ||
bool CanBeResolvedUsing(RuntimeTypeModel protobufModel); | ||
} | ||
} |
Oops, something went wrong.