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; }
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)); } }
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); } }
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); }
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); }
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)); }
public abstract void SetObjectFieldFromInfo(DomainObject pobj, DomainObjectInfo info, IPersistenceContext pctx);
protected void SetInfoFieldValue(DomainObjectInfo info, object value) { _infoFieldSetter(info, value); }
protected object GetInfoFieldValue(DomainObjectInfo info) { return _infoFieldGetter(info); }
protected object GetInfoFieldValue(DomainObjectInfo info) { return(_infoFieldGetter(info)); }