Ejemplo n.º 1
0
 public TypeAndDomainObjectKey(Type handlerType, DomainObjectInfo infoIdentifier1, DomainObjectInfo infoIdentifier2)
 {
     Debug.Assert(typeof(ModelingEventArgs).IsAssignableFrom(handlerType), "Not a valid event handler type");
     myHandlerType     = handlerType;
     myInfoIdentifier1 = infoIdentifier1;
     myInfoIdentifier2 = infoIdentifier2;
 }
Ejemplo n.º 2
0
 public override void SetInfoFieldFromObject(DomainObject pobj, DomainObjectInfo info, IPersistenceContext pctx)
 {
     Entity entity = (Entity)GetClassFieldValue(pobj);
     if (entity != null && pctx.IsProxyLoaded(entity))
     {
         SetInfoFieldValue(info, _entityConversion.GetInfoFromObject(entity, pctx));
     }
 }
Ejemplo n.º 3
0
        public override void SetInfoFieldFromObject(DomainObject pobj, DomainObjectInfo info, IPersistenceContext pctx)
        {
            Entity entity = (Entity)GetClassFieldValue(pobj);

            if (entity != null && pctx.IsProxyLoaded(entity))
            {
                SetInfoFieldValue(info, _entityConversion.GetInfoFromObject(entity, pctx));
            }
        }
Ejemplo n.º 4
0
 public override void SetObjectFieldFromInfo(DomainObject pobj, DomainObjectInfo info, IPersistenceContext pctx)
 {
     EntityInfo entityInfo = (EntityInfo)GetInfoFieldValue(info);
     if (entityInfo != null && entityInfo.GetEntityRef() != null)
     {
         // don't copy any information from the referenced EntityInfo
         // only take its reference
         Entity entity = pctx.Load(entityInfo.GetEntityRef(), EntityLoadFlags.Proxy);    // proxy, no version check!
         SetClassFieldValue(pobj, entity);
     }
 }
Ejemplo n.º 5
0
        public override void SetObjectFieldFromInfo(DomainObject pobj, DomainObjectInfo info, IPersistenceContext pctx)
        {
            EntityInfo entityInfo = (EntityInfo)GetInfoFieldValue(info);

            if (entityInfo != null && entityInfo.GetEntityRef() != null)
            {
                // don't copy any information from the referenced EntityInfo
                // only take its reference
                Entity entity = pctx.Load(entityInfo.GetEntityRef(), EntityLoadFlags.Proxy);    // proxy, no version check!
                SetClassFieldValue(pobj, entity);
            }
        }
Ejemplo n.º 6
0
        public override void SetInfoFieldFromObject(DomainObject pobj, DomainObjectInfo info, IPersistenceContext pctx)
        {
            IEnumerable pobjCollection = (IEnumerable)GetClassFieldValue(pobj);

            if (pobjCollection != null && pctx.IsCollectionLoaded(pobjCollection))
            {
                List <TInfoElement> infoCollection = new List <TInfoElement>();
                foreach (object element in pobjCollection)
                {
                    infoCollection.Add((TInfoElement)_elementConversion.GetInfoFromObject(element, pctx));
                }
                SetInfoFieldValue(info, infoCollection);
            }
        }
        public static DomainObjectInfo GetResourceInfo(this IDomainObject resource)
        {
            var resourceAttr = resource.GetType().GetTypeInfo().GetCustomAttribute <DomainObjectAttribute>();

            if (resourceAttr == null)
            {
                throw new AttributeNotFountException(typeof(DomainObjectAttribute), resource);
            }

            var info = new DomainObjectInfo
            {
                Id       = resource.Id,
                Name     = resource.Name,
                TypeId   = resourceAttr.Id,
                TypeName = resourceAttr.Name
            };

            return(info);
        }
Ejemplo n.º 8
0
        public static DomainObjectInfo GetResourceInfo(this IDomainObject resource)
        {
            var resourceAttr = resource.GetType().GetTypeInfo().GetCustomAttribute <DomainObjectAttribute>();

            if (resourceAttr == null)
            {
                throw new ArgumentException($"Тип аргумента не помечен атрибутом {nameof(DomainObjectAttribute)}", "resource");
            }

            var info = new DomainObjectInfo
            {
                InstanceId   = resource.Id,
                InstanceName = resource.Name,
                TypeId       = resourceAttr.TypeId,
                TypeName     = resourceAttr.TypeName
            };

            return(info);
        }
Ejemplo n.º 9
0
        public override void SetObjectFieldFromInfo(DomainObject pobj, DomainObjectInfo info, IPersistenceContext pctx)
        {
            IList infoCollection = (IList)GetInfoFieldValue(info);

            if (infoCollection != null)
            {
                IEnumerable pobjCollection = (IEnumerable)GetClassFieldValue(pobj);
                foreach (object element in infoCollection)
                {
                    if (pobjCollection is IList)
                    {
                        (pobjCollection as IList).Add(_elementConversion.GetObjectFromInfo(element, pctx));
                    }
                    else if (pobjCollection is ISet)
                    {
                        (pobjCollection as ISet).Add(_elementConversion.GetObjectFromInfo(element, pctx));
                    }
                }
            }
        }
 public override void SetObjectFieldFromInfo(DomainObject pobj, DomainObjectInfo info, IPersistenceContext pctx)
 {
     SetClassFieldValue(pobj, _valueConversion.GetObjectFromInfo(GetInfoFieldValue(info), pctx));
 }
Ejemplo n.º 11
0
 public override void SetObjectFieldFromInfo(DomainObject pobj, DomainObjectInfo info, IPersistenceContext pctx)
 {
     SetClassFieldValue(pobj, _valueConversion.GetObjectFromInfo(GetInfoFieldValue(info), pctx));
 }
Ejemplo n.º 12
0
 public abstract void SetObjectFieldFromInfo(DomainObject pobj, DomainObjectInfo info, IPersistenceContext pctx);
Ejemplo n.º 13
0
 protected void SetInfoFieldValue(DomainObjectInfo info, object value)
 {
     _infoFieldSetter(info, value);
 }
Ejemplo n.º 14
0
 protected object GetInfoFieldValue(DomainObjectInfo info)
 {
     return _infoFieldGetter(info);
 }
Ejemplo n.º 15
0
 public abstract void SetObjectFieldFromInfo(DomainObject pobj, DomainObjectInfo info, IPersistenceContext pctx);
Ejemplo n.º 16
0
 protected object GetInfoFieldValue(DomainObjectInfo info)
 {
     return(_infoFieldGetter(info));
 }
Ejemplo n.º 17
0
 protected void SetInfoFieldValue(DomainObjectInfo info, object value)
 {
     _infoFieldSetter(info, value);
 }