コード例 #1
0
 public static dynamic ToData(CdmEntityReference instance, ResolveOptions resOpt, CopyOptions options)
 {
     if (instance.ExplicitReference != null && instance.ExplicitReference.GetType() == typeof(CdmProjection))
     {
         return(ProjectionPersistence.ToData(instance.ExplicitReference as CdmProjection, resOpt, options));
     }
     else
     {
         return(CdmObjectRefPersistence.ToData(instance, resOpt, options));
     }
 }
コード例 #2
0
        public static TypeAttribute ToData(CdmTypeAttributeDefinition instance, ResolveOptions resOpt, CopyOptions options)
        {
            if (instance == null)
            {
                return(null);
            }

            TypeAttribute obj = new TypeAttribute
            {
                Explanation        = instance.Explanation,
                Description        = instance.GetProperty("description"),
                Name               = instance.Name,
                Purpose            = Utils.JsonForm(instance.Purpose, resOpt, options),
                DataType           = Utils.JsonForm(instance.DataType, resOpt, options),
                AppliedTraits      = CopyDataUtils.ListCopyData(resOpt, instance.AppliedTraits?.Where(trait => !trait.IsFromProperty), options),
                AttributeContext   = Utils.JsonForm(instance.AttributeContext, resOpt, options),
                ResolutionGuidance = Utils.JsonForm(instance.ResolutionGuidance, resOpt, options)
            };

            obj.Projection = ProjectionPersistence.ToData(instance.Projection, resOpt, options);

            var isReadOnly = instance.GetProperty("isReadOnly");

            obj.IsReadOnly = isReadOnly ? isReadOnly : null;

            var isNullable = instance.GetProperty("isNullable");

            obj.IsNullable = isNullable ? isNullable : null;

            obj.SourceName = instance.GetProperty("sourceName");

            var sourceOrdering = instance.GetProperty("sourceOrdering");

            obj.SourceOrdering = sourceOrdering != 0 ? sourceOrdering : null;

            obj.DisplayName = instance.GetProperty("displayName");
            obj.Description = instance.GetProperty("description");

            var valueConstrainedToList = instance.GetProperty("valueConstrainedToList");

            obj.ValueConstrainedToList = valueConstrainedToList ? valueConstrainedToList : null;

            var isPrimaryKey = instance.GetProperty("isPrimaryKey");

            obj.IsPrimaryKey = isPrimaryKey ? isPrimaryKey : null;

            obj.MaximumLength = instance.GetProperty("maximumLength");
            obj.MaximumValue  = instance.GetProperty("maximumValue");
            obj.MinimumValue  = instance.GetProperty("minimumValue");

            var dataFormat = instance.GetProperty("dataFormat");

            obj.DataFormat = dataFormat != CdmDataFormat.Unknown ? dataFormat.ToString() : null;

            var defaultValue = instance.GetProperty("defaultValue");

            var defValue = instance.GetProperty("defaultValue");

            if (defValue is List <object> )
            {
                obj.DefaultValue = defValue.Count > 0 ? JToken.FromObject(defValue) : null;
            }
            else
            {
                obj.DefaultValue = defValue;
            }

            return(obj);
        }