Пример #1
0
 /// <summary>
 /// To specify that this (primtive) property is a reference to another model found from another API or service
 /// </summary>
 /// <typeparam name="TS"></typeparam>
 /// <param name="serviceName"></param>
 /// <param name="node"></param>
 /// <returns></returns>
 public AnalyticalChild <TParent, T> GetFromService <TS>(string serviceName, AnalyticalObject <TS> node) where TS : class
 {
     PopulateServiceMaps(serviceName, parentName + "_" + Name, node.Name);
     foreach (var entry in node.TypeMap)
     {
         this.TypeMap.Add(entry);
     }
     return(this);
 }
Пример #2
0
        /// <summary>
        /// Pass in a property by LINQ expression so that it can be defined by modifying the resulting AnalyticalChild
        /// The AnalyticalChild constructor will try to guess the type.
        /// </summary>
        /// <typeparam name="TProperty">Type of property to be defined</typeparam>
        /// <param name="propertyExpression"></param>
        /// <param name="directParent">Direct parent, this should not be set by the user</param>
        /// <returns></returns>
        public AnalyticalChild <T, TProperty> Property <TProperty>(Expression <Func <T, TProperty> > propertyExpression,
                                                                   AnalyticalObject <T> directParent = null)
        {
            var    expression = (MemberExpression)propertyExpression.Body;
            string name       = expression.Member.Name;
            Type   childType  = propertyExpression.ReturnType;
            var    child      = new AnalyticalChild <T, TProperty>(directParent ?? this, name, childType, this.TypeMap);

            return(child);
        }
Пример #3
0
 /// <summary>
 /// Defines an AnalyticalChild and tries to guess the type if it's a primtive type or string. It adds its parents and grandparents to keep track of them.
 /// </summary>
 /// <param name="analyticalObject"></param>
 /// <param name="childName"></param>
 /// <param name="childType"></param>
 /// <param name="typeMapsReference"></param>
 /// <param name="grandParentName"></param>
 public AnalyticalChild(AnalyticalObject <TParent> analyticalObject, string childName, Type childType, TypeMap typeMapsReference = null, string grandParentName = null) : base(analyticalObject.TypeMap)
 {
     this.DirectParent = analyticalObject;
     this.Name         = childName;
     this.childType    = childType;
     this.parentName   = grandParentName == null? analyticalObject.Name : grandParentName + "_" + analyticalObject.Name;
     this.TypeMap      = typeMapsReference ?? base.TypeMap;
     if (TypeUtils.TryGuessInternalType(childType, out this.sqlType))
     {
         PopulateTypeMaps(sqlType, childName);
     }
 }
Пример #4
0
        /// <summary>
        /// Override default behavior to modify parent passing
        /// </summary>
        /// <typeparam name="TProperty"></typeparam>
        /// <param name="propertyExpression"></param>
        /// <param name="directParent"></param>
        /// <returns></returns>
        public new AnalyticalChild <T, TProperty> Property <TProperty>(Expression <Func <T, TProperty> > propertyExpression,
                                                                       AnalyticalObject <T> directParent = null)
        {
            var    expression = (MemberExpression)propertyExpression.Body;
            string name       = expression.Member.Name;
            Type   childType  = propertyExpression.ReturnType;
            AnalyticalChild <T, TProperty> child;

            // Passing the type maps down to the child, so that all children/grandchildren share the same type dictionary
            child = new AnalyticalChild <T, TProperty>(this, name, childType, this.TypeMap, this.parentName);
            return(child);
        }
Пример #5
0
        /// <summary>
        /// To specify that this (primtive) property is a reference to another model found from another API or service
        /// </summary>
        /// <typeparam name="TS"></typeparam>
        /// <param name="serviceName"></param>
        /// <param name="node"></param>
        /// <returns></returns>
        public AnalyticalChild <TParent, T> GetFromService <TS>(string serviceName, AnalyticalObject <TS> node)
            where TS : class
        {
            PopulateTypeMaps(new NodeProperties()
            {
                ServiceName = serviceName,
                NodeName    = node.Name,
            }, parentName, Name, true);

            foreach (var entry in node.TypeMap)
            {
                string key = Namer.EnsureMinimumUniqueKey(Name.ToLower() + "_" + entry.Key, TypeMap, true);
                TypeMap[key] = entry.Value;
            }

            return(this);
        }
Пример #6
0
 /// <summary>
 /// Defines an AnalyticalChild and tries to guess the type if it's a primtive type or string. It adds its parents and grandparents to keep track of them.
 /// </summary>
 /// <param name="analyticalObject"></param>
 /// <param name="childName"></param>
 /// <param name="childType"></param>
 /// <param name="typeMapsReference"></param>
 /// <param name="grandParentName"></param>
 public AnalyticalChild(AnalyticalObject <TParent> analyticalObject, string childName, Type childType,
                        TypeMap typeMapsReference = null, string grandParentName = null)
     : base(analyticalObject.TypeMap, analyticalObject.minimumKeyToHierarchy)
 {
     this.DirectParent = analyticalObject;
     this.Name         = childName;
     this.childType    = childType;
     this.parentName   = grandParentName == null
         ? analyticalObject.Name
         : grandParentName + "_" + analyticalObject.Name;
     this.TypeMap = typeMapsReference ?? base.TypeMap;
     if (TypeUtils.TryGuessInternalType(childType, out this.sqlType))
     {
         base.PopulateTypeMaps(
             new NodeProperties()
         {
             InternalType = sqlType
         },
             parentName, childName, true);
     }
 }
Пример #7
0
        public AnalyticalChild <T, TProperty> Property <TProperty>(string propertyName, AnalyticalObject <TProperty> type)
        {
            var child = new AnalyticalChild <T, TProperty>(this, propertyName, type.AnalyzedType, this.TypeMap);

            PopulateTypeMaps(new NodeProperties()
            {
                InternalType = InternalType.NEVER
            }, Name, propertyName);

            foreach (var kv in type.TypeMap)
            {
                PopulateTypeMaps(kv.Value, $"{propertyName}_{kv.Key}", true);
            }

            return(child);
        }