예제 #1
0
 public ICodegenExpression CodegenUnderlyingFragment(ICodegenExpression underlyingExpression,
     ICodegenContext context)
 {
     throw VAERevisionEventPropertyGetterDeclaredGetVersioned.RevisionImplementationNotProvided();
 }
        /// <summary>Creates property descriptors for revision. </summary>
        /// <param name="spec">specifies revision</param>
        /// <param name="groups">the groups that group properties</param>
        /// <returns>map of property and descriptor</returns>
        public static IDictionary <string, RevisionPropertyTypeDesc> CreatePropertyDescriptors(
            RevisionSpec spec,
            PropertyGroupDesc[] groups)
        {
            var propsPerGroup = PropertyUtility.GetGroupsPerProperty(groups);

            IDictionary <string, RevisionPropertyTypeDesc> propertyDesc =
                new Dictionary <string, RevisionPropertyTypeDesc>();
            var count = 0;

            foreach (var property in spec.ChangesetPropertyNames)
            {
                var fullGetter         = spec.BaseEventType.GetGetter(property);
                var propertyNumber     = count;
                var propGroupsProperty = propsPerGroup.Get(property);
                var paramList          = new RevisionGetterParameters(property, propertyNumber, fullGetter, propGroupsProperty);

                // if there are no groups (full event property only), then simply use the full event getter
                var revisionGetter = new VAERevisionEventPropertyGetterDeclaredGetVersioned(paramList);

                var type             = spec.BaseEventType.GetPropertyType(property);
                var propertyTypeDesc = new RevisionPropertyTypeDesc(revisionGetter, paramList, type);
                propertyDesc.Put(property, propertyTypeDesc);
                count++;
            }

            foreach (var property in spec.BaseEventOnlyPropertyNames)
            {
                var fullGetter = ((EventTypeSPI)spec.BaseEventType).GetGetterSPI(property);

                // if there are no groups (full event property only), then simply use the full event getter
                var revisionGetter = new VAERevisionEventPropertyGetterDeclaredLast(fullGetter);

                var type             = spec.BaseEventType.GetPropertyType(property);
                var propertyTypeDesc = new RevisionPropertyTypeDesc(revisionGetter, null, type);
                propertyDesc.Put(property, propertyTypeDesc);
                count++;
            }

            count = 0;
            foreach (var property in spec.KeyPropertyNames)
            {
                var keyPropertyNumber = count;

                EventPropertyGetterSPI revisionGetter;
                if (spec.KeyPropertyNames.Length == 1)
                {
                    revisionGetter = new VAERevisionEventPropertyGetterDeclaredOneKey();
                }
                else
                {
                    revisionGetter = new VAERevisionEventPropertyGetterDeclaredNKey(keyPropertyNumber);
                }

                var type             = spec.BaseEventType.GetPropertyType(property);
                var propertyTypeDesc = new RevisionPropertyTypeDesc(revisionGetter, null, type);
                propertyDesc.Put(property, propertyTypeDesc);
                count++;
            }

            return(propertyDesc);
        }