Пример #1
0
        /// <summary>
        /// Projections require a new resolved attribute to be created multiple times
        /// This function allows us to create new resolved attributes based on a input attribute
        /// </summary>
        /// <param name="projCtx"></param>
        /// <param name="attrCtxUnder"></param>
        /// <param name="targetAttr"></param>
        /// <param name="overrideDefaultName"></param>
        /// <param name="addedSimpleRefTraits"></param>
        /// <returns></returns>
        internal static ResolvedAttribute CreateNewResolvedAttribute(
            ProjectionContext projCtx,
            CdmAttributeContext attrCtxUnder,
            CdmAttribute targetAttr,
            string overrideDefaultName         = null,
            List <string> addedSimpleRefTraits = null)
        {
            ResolvedAttribute newResAttr = new ResolvedAttribute(
                projCtx.ProjectionDirective.ResOpt,
                targetAttr,
                !string.IsNullOrWhiteSpace(overrideDefaultName) ? overrideDefaultName : targetAttr.GetName(), attrCtxUnder);

            if (addedSimpleRefTraits != null)
            {
                foreach (string trait in addedSimpleRefTraits)
                {
                    if (targetAttr.AppliedTraits.Item(trait) == null)
                    {
                        targetAttr.AppliedTraits.Add(trait, true);
                    }
                }
            }

            ResolvedTraitSet resTraitSet = targetAttr.FetchResolvedTraits(projCtx.ProjectionDirective.ResOpt);

            // Create deep a copy of traits to avoid conflicts in case of parameters
            if (resTraitSet != null)
            {
                newResAttr.ResolvedTraits = resTraitSet.DeepCopy();
            }

            return(newResAttr);
        }
Пример #2
0
 internal CdmAttribute CopyAtt(ResolveOptions resOpt, CdmAttribute copy)
 {
     copy.Purpose            = this.Purpose != null ? (CdmPurposeReference)this.Purpose.Copy(resOpt) : null;
     copy.ResolutionGuidance = this.ResolutionGuidance != null ? (CdmAttributeResolutionGuidance)this.ResolutionGuidance.Copy(resOpt) : null;
     foreach (var trait in this.AppliedTraits)
     {
         copy.AppliedTraits.Add(trait);
     }
     this.CopyDef(resOpt, copy);
     return(copy);
 }
Пример #3
0
 internal CdmAttribute CopyAtt(ResolveOptions resOpt, CdmAttribute copy)
 {
     copy.Purpose            = this.Purpose?.Copy(resOpt) as CdmPurposeReference;
     copy.ResolutionGuidance = this.ResolutionGuidance?.Copy(resOpt) as CdmAttributeResolutionGuidance;
     copy.AppliedTraits.Clear();
     foreach (var trait in this.AppliedTraits)
     {
         copy.AppliedTraits.Add(trait.Copy(resOpt) as CdmTraitReferenceBase);
     }
     this.CopyDef(resOpt, copy);
     return(copy);
 }
Пример #4
0
 /// <summary>
 /// CardinalitySettings constructor
 /// </summary>
 public CardinalitySettings(CdmAttribute owner)
 {
     Owner = owner;
     Ctx   = owner?.Ctx;
 }