public VersionId_I NewVersionId() { var id = new VersionId() { }; XIdentification.IssueId(id); return(id); }
public object New(Type type) { try { var x = type.GetConstructor(System.Type.EmptyTypes); if (x == null) { // Need to be using an log message type so that the exceptions can be filtered by a more advnced logging package. This gets rid of the need to pass in a global context, // as a more advanced logging system can filter the messages by type if it needed to adjust the verbosity. XLogBase.LogError(null, new NoPublicConstructorsWithEmptyArguementsLogMessage() { Message = new Message() { Value = $"There are no public empty argument constructors for type '{type.AssemblyQualifiedName}'. An instance could not be created." } }); //XLogBase.LogError(XContextualBase.GetGlobal(), $"There are no public empty argument constructors for type '{type.AssemblyQualifiedName}'. An instance could not be created."); return(null); } var result = x.Invoke(null); var resultId = result as Ided_I; if (resultId != null) { resultId.Id = XIdentification.IssueId(); } var typed = result as Typed_I; if (typed != null) { if (typed?.TypeId == null) { typed.TypeId = XTypeIdentification.GetTypeId(type); } } return(result); } catch (System.Exception exception) { //XLogBase.LogException(XContextualBase.GetGlobal(), exception); XLogBase.LogException(null, exception); return(null); } }
private TypeId_I GetStandardTypeIdTypeId(TypeGlobalContext_I context) { lock (context.SyncRoot) { if (context.StandardTypeIdTypeId == null) { StandardTypeId id = new StandardTypeId(); XIdentification.IssueId(id); id.TypeId = id; context.StandardTypeIdTypeId = id; } return(context.StandardTypeIdTypeId); } }
public TypeId_I AddTypeId(RuntimeTypeHandle typeHandle) { var context = GetGlobalContext(); lock (context.SyncRoot) { var standardType = new StandardTypeId() { TypeId = GetStandardTypeIdTypeId(context) }; XIdentification.IssueId(standardType); context.TypeIdsByTypeHandle.Add(typeHandle, standardType); context.TypeHandles.Add(standardType.Value, typeHandle); return(standardType); } }