예제 #1
0
 public static EventInfo GetEventInfo(this SystemEntity entity)
 {
     if (entity == null)
     {
         return(null);
     }
     return(Activator.CreateInstance(typeof(EventInfo <>).MakeGenericType(entity.GetType()), entity) as EventInfo);
 }
예제 #2
0
        private static Op <SystemEntityMono> RawToMono(SystemEntity systemEntity)
        {
            var type = systemEntity.GetType();

            if (_matchedFactories.ContainsKey(type))
            {
                return(Op <SystemEntityMono> .Correct(_matchedFactories[type].Invoke(systemEntity)));
            }

            return(Op <SystemEntityMono> .Error($"No mono factory for {type.Name}"));
        }
        public UniversalSearchItem GenerateItem(SystemEntity entity)
        {
            if (entity == null)
                return null;

            Type type = entity.GetType();
            if (!GetUniversalSearchItemTypes.ContainsKey(type))
                return null;

            GetUniversalSearchItemBase getUniversalSearchItem = _kernel.Get(GetUniversalSearchItemTypes[type]) as GetUniversalSearchItemBase;
            if (getUniversalSearchItem == null)
                return null;

            return getUniversalSearchItem.GetSearchItem(entity);
        }
예제 #4
0
        private SystemEntity GetOriginalVersion(SystemEntity entity)
        {
            if (entity == null)
            {
                return(null);
            }
            ISessionImplementor sessionImplementation = GetSessionImplementation();
            IPersistenceContext persistenceContext    = sessionImplementation.PersistenceContext;
            EntityEntry         entry = persistenceContext.GetEntry(entity);

            if (entry == null)
            {
                return(null);
            }
            object[] loadedState = entry.LoadedState;
            if (loadedState == null)
            {
                return(null);
            }
            Type             type            = entity.GetType();
            var              instance        = Activator.CreateInstance(type) as SystemEntity;
            IEntityPersister entityPersister = entry.Persister;

            for (int index = 0; index < entityPersister.PropertyNames.Length; index++)
            {
                string         propertyName  = entityPersister.PropertyNames[index];
                object         value         = loadedState[index];
                PropertyInfo[] propertyInfos =
                    type.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
                PropertyInfo propertyInfo = propertyInfos.FirstOrDefault(info => info.Name == propertyName);
                try
                {
                    if (propertyInfo.CanWrite)
                    {
                        propertyInfo.SetValue(instance, value);
                    }
                }
                catch
                {
                    throw new Exception(propertyName + " not found");
                }
            }
            return(instance);
        }
예제 #5
0
 public bool CanGenerate(SystemEntity entity)
 {
     return(entity != null && GetUniversalSearchItemTypes.ContainsKey(entity.GetType()));
 }
예제 #6
0
 public bool CanGenerate(SystemEntity entity)
 {
     return entity != null && GetUniversalSearchItemTypes.ContainsKey(entity.GetType());
 }
예제 #7
0
        public UniversalSearchItem GenerateItem(SystemEntity entity)
        {
            if (entity == null)
                return null;

            Type type = entity.GetType();
            if (!GetUniversalSearchItemTypes.ContainsKey(type))
                return null;

            var getUniversalSearchItem = _kernel.Get(GetUniversalSearchItemTypes[type]) as GetUniversalSearchItemBase;
            if (getUniversalSearchItem == null)
                return null;

            return getUniversalSearchItem.GetSearchItem(entity);
        }
예제 #8
0
 public static UpdatedEventInfo GetUpdatedEventInfo(this SystemEntity entity, SystemEntity original)
 {
     if (entity == null)
     {
         return(null);
     }
     return
         (Activator.CreateInstance(typeof(UpdatedEventInfo <>).MakeGenericType(entity.GetType()), entity, original)
          as UpdatedEventInfo);
 }