Example #1
0
 // TODO: removed ValidSince
 /**
  * @param fields
  *            A List of <code>Field</code> objects
  * @param type
  *            type is a string and one of "friend", "family", "work",
  *            "other"
  * @param subtype
  *            `subtype` is a string and is not restricted to a specific list
  *            of possible values (for example, if type_ is "family" then
  *            subtype can be "Father", "Mother", "Son" and many other
  *            things).
  */
 public Relationship(IEnumerable<Field> fields = null, 
     RelationshipTypes? type = null, string subtype = null)
     : base(fields)
 {
     this.Type = type;
     this.Subtype = subtype;
 }
Example #2
0
 public PropertyInfo <T> Create <T>(Type type, string name, string friendlyName,
                                    T defaultValue, RelationshipTypes relationship)
 {
     return(new PropertyInformationUsingOriginalValue <T>(name, friendlyName,
                                                          defaultValue, relationship));
 }
Example #3
0
        /// <summary>
        /// Indicates that the specified property belongs
        /// to the business object type.
        /// </summary>
        /// <typeparam name="P">Type of property</typeparam>
        /// <param name="propertyLambdaExpression">Property Expression</param>
        /// <param name="friendlyName">Friendly description for a property to be used in databinding</param>
        /// <param name="defaultValue">Default Value for the property</param>
        /// <param name="relationship">Relationship with
        /// referenced object.</param>
        /// <returns></returns>
        protected static PropertyInfo <P> RegisterProperty <P>(Expression <Func <T, object> > propertyLambdaExpression, string friendlyName, P defaultValue, RelationshipTypes relationship)
        {
            PropertyInfo reflectedPropertyInfo = Reflect <T> .GetProperty(propertyLambdaExpression);

            return(RegisterProperty(reflectedPropertyInfo.Name, friendlyName, defaultValue, relationship));
        }
Example #4
0
        protected static PropertyInfo <P> RegisterProperty <P>(Expression <Func <T, object> > propertyLambdaExpression, string friendlyName, RelationshipTypes relationship)
        {
            PropertyInfo reflectedPropertyInfo = Reflect <T> .GetProperty(propertyLambdaExpression);

            return(RegisterProperty(Csla.Core.FieldManager.PropertyInfoFactory.Factory.Create <P>(typeof(T), reflectedPropertyInfo.Name, friendlyName, relationship)));
        }
Example #5
0
 /// <summary>
 /// Creates a new instance of this class.
 /// </summary>
 /// <param name="name">Name of the property.</param>
 /// <param name="relationship">Relationship with referenced object.</param>
 public PropertyInfo(string name, RelationshipTypes relationship) : this(name, string.Empty)
 {
     _relationshipType = relationship;
 }
        public static PropertyInfo <T> Register <TTarget, T>(Expression <Func <TTarget,
                                                                               object> > propertyLambdaExpression, RelationshipTypes relationship)
        {
            var property = new PropertyInfo <T>(
                Reflect <TTarget> .GetProperty(propertyLambdaExpression).Name, relationship);

            return(BusinessBase.RegisterProperty <T>(typeof(TTarget), property));
        }
Example #7
0
 /// <summary>
 /// Creates a new instance of this class.
 /// </summary>
 /// <param name="name">Name of the property.</param>
 /// <param name="relationship">Relationship with referenced object.</param>
 public PropertyInfo(string name, RelationshipTypes relationship)
     : this(name, null, null, DataBindingFriendlyDefault(), relationship)
 {
 }
Example #8
0
 /// <summary>
 /// Indicates that the specified property belongs
 /// to the business object type.
 /// </summary>
 /// <typeparam name="P">Type of property</typeparam>
 /// <param name="propertyName">Property name from nameof()</param>
 /// <param name="relationship">Relationship with property value.</param>
 /// <returns></returns>
 protected static PropertyInfo<P> RegisterProperty<P>(string propertyName, RelationshipTypes relationship)
 {
   return RegisterProperty(Csla.Core.FieldManager.PropertyInfoFactory.Factory.Create<P>(typeof(T), propertyName, string.Empty, relationship));
 }
Example #9
0
 public PropertyInformationUsingOriginalValue(Type containingType, string name, string friendlyName,
                                              T defaultValue, RelationshipTypes relationship)
     : base(name, friendlyName, defaultValue, relationship)
 {
     this.ContainingType = containingType;
 }
 /// <summary>
 /// Creates a new instance of PropertyInfo.
 /// </summary>
 /// <param name="containingType">
 /// Type of business class that contains the property
 /// declaration.
 /// </param>
 /// <param name="name">Name of the property.</param>
 /// <param name="friendlyName">
 /// Friendly display name for the property.
 /// </param>
 /// <param name="defaultValue">
 /// Default value for the property.
 /// </param>
 /// <param name="relationship">Relationship with
 /// referenced object.</param>
 public Csla.PropertyInfo <T> Create <T>(Type containingType, string name, string friendlyName, T defaultValue, RelationshipTypes relationship)
 {
     return(new Csla.PropertyInfo <T>(name, friendlyName, containingType, defaultValue, relationship));
 }
 public PropertyInfo <T> Create <T>(Type containingType, string name, string friendlyName,
                                    RelationshipTypes relationship)
 {
     return(new PropertyInformationUsingOriginalValue <T>(containingType, name, friendlyName,
                                                          relationship));
 }
        /// <summary>
        /// Creates a new instance of PropertyInfo.
        /// </summary>
        /// <param name="containingType">
        /// Type of business class that contains the property
        /// declaration.
        /// </param>
        /// <param name="name">Name of the property.</param>
        /// <param name="friendlyName">
        /// Friendly display name for the property.
        /// </param>
        /// <param name="relationship">Relationship with
        /// referenced object.</param>
        public Csla.PropertyInfo <T> Create <T>(Type containingType, string name, string friendlyName, RelationshipTypes relationship)
        {
            if (string.IsNullOrWhiteSpace(friendlyName))
            {
                friendlyName = GetFriendlyNameFromAttributes(containingType, name);
            }

            return(new Csla.PropertyInfo <T>(name, friendlyName, relationship));
        }
 /// <summary>
 /// Creates a new instance of PropertyInfo.
 /// </summary>
 /// <param name="containingType">
 /// Type of business class that contains the property
 /// declaration.
 /// </param>
 /// <param name="name">Name of the property.</param>
 /// <param name="friendlyName">
 /// Friendly display name for the property.
 /// </param>
 /// <param name="relationship">Relationship with
 /// referenced object.</param>
 public Csla.PropertyInfo <T> Create <T>(Type containingType, string name, string friendlyName, RelationshipTypes relationship)
 {
     return(new Csla.PropertyInfo <T>(name, friendlyName, containingType, PropertyInfo <T> .DataBindingFriendlyDefault(), relationship));
 }
Example #14
0
        /// <summary>
        /// Creates a new instance of PropertyInfo.
        /// </summary>
        /// <param name="containingType">
        /// Type of business class that contains the property
        /// declaration.
        /// </param>
        /// <param name="name">Name of the property.</param>
        /// <param name="friendlyName">
        /// Friendly display name for the property.
        /// </param>
        /// <param name="defaultValue">
        /// Default value for the property.
        /// </param>
        /// <param name="relationship">Relationship with
        /// referenced object.</param>
        public Csla.PropertyInfo <T> Create <T>(Type containingType, string name, string friendlyName, T defaultValue, RelationshipTypes relationship)
        {
#if WINDOWS_PHONE
            if (string.IsNullOrEmpty(friendlyName))
#else
            if (string.IsNullOrWhiteSpace(friendlyName))
#endif
            { friendlyName = GetFriendlyNameFromAttributes(containingType, name); }

            return(new Csla.PropertyInfo <T>(name, friendlyName, defaultValue, relationship));
        }
Example #15
0
        /// <summary>
        /// Creates a new instance of this class.
        /// </summary>
        /// <param name="name">Name of the property.</param>
        /// <param name="friendlyName">
        /// Friendly display name for the property.
        /// </param>
        /// <param name="containingType">
        /// Factory to provide display name from attributes.
        /// </param>
        /// <param name="defaultValue">
        /// Default value for the property.
        /// </param>
        /// <param name="relationship">Relationship with
        /// referenced object.</param>
        public PropertyInfo(string name, string friendlyName, Type containingType, T defaultValue, RelationshipTypes relationship)
        {
            Name              = name;
            _friendlyName     = friendlyName;
            _relationshipType = relationship;
            if (containingType != null)
            {
                _propertyInfo = containingType.GetProperty(Name);
            }

            // if T is string we need an empty string, not null, for data binding
            if (typeof(T).Equals(typeof(string)) && defaultValue == null)
            {
                _defaultValue = (T)((object)string.Empty);
            }
            else
            {
                _defaultValue = defaultValue;
            }
        }
        public void Init(string id, string reltype)
        {
            RelType           = reltype;
            IndexClientId     = id;
            AddPersonLabel    = $"Register New {RelType}";
            RelationshipTypes = _lookupService.GetRelationshipTypes().ToList().Where(x => x.Description.ToLower() == RelType.ToLower()).ToList();

            if (!string.IsNullOrEmpty(RelType))
            {
                _settings.AddOrUpdateValue("RelType", RelType);
            }
            if (!string.IsNullOrEmpty(RelType))
            {
                _settings.AddOrUpdateValue("rIndexClientId", IndexClientId);
            }
            if (!string.IsNullOrEmpty(RelType))
            {
                _settings.AddOrUpdateValue("AddPersonLabel", AddPersonLabel);
            }
            if (RelationshipTypes.ToList().Count > 0)
            {
                _settings.AddOrUpdateValue("RelationshipTypes", JsonConvert.SerializeObject(RelationshipTypes.ToList()));
            }
        }
Example #17
0
 /// <summary>
 /// Creates a new instance of this class.
 /// </summary>
 /// <param name="name">Name of the property.</param>
 /// <param name="relationship">Relationship with referenced object.</param>
 public PropertyInfo(string name, RelationshipTypes relationship)
     : this(name, null, null, default(T), relationship)
 {
 }
Example #18
0
 private static TRelation[] FilterRelationsByType <TRelation>(IQueryable <PersonRelationship> relations, RelationshipTypes type) where TRelation : class
 {
     return
         ((
              from rel in relations
              where rel.RelationshipTypeId == (int)type
              select typeof(TRelation) == typeof(PersonRelationType) ? rel.ToPersonRelationType() as TRelation : rel.ToPersonFlerRelationType() as TRelation
              ).ToArray());
 }
Example #19
0
        /// <summary>
        /// Creates a new instance of this class.
        /// </summary>
        /// <param name="name">Name of the property.</param>
        /// <param name="friendlyName">
        /// Friendly display name for the property.
        /// </param>
        /// <param name="containingType">
        /// Factory to provide display name from attributes.
        /// </param>
        /// <param name="defaultValue">
        /// Default value for the property.
        /// </param>
        /// <param name="relationship">Relationship with
        /// referenced object.</param>
        public PropertyInfo(string name, string friendlyName, Type containingType, T defaultValue, RelationshipTypes relationship)
        {
            Name              = name;
            _friendlyName     = friendlyName;
            _relationshipType = relationship;
            if (containingType != null)
            {
                _propertyInfo = containingType.GetProperty(Name);
            }

            _defaultValue = defaultValue;
        }
Example #20
0
 private static PersonRelationship[] ListFromXmlType(PersonFlerRelationType[] oio, RelationshipTypes relType)
 {
     if (oio != null)
     {
         return(oio.AsQueryable()
                .Where(r => r != null)
                .Select(
                    r => new PersonRelationship()
         {
             CommentText = r.CommentText,
             Effect = Effect.FromVirkningType(r.Virkning),
             PersonRelationshipId = Guid.NewGuid(),
             RelatedPersonUuid = new Guid(r.ReferenceID.Item),
             RelationshipTypeId = (int)relType
         }
                    )
                .ToArray());
     }
     return(new PersonRelationship[0]);
 }
Example #21
0
    public void SetRelationship(Name principalModel, IEnumerable <Name> principalFields, Name dependantModel, IEnumerable <Name> dependantFields, RelationshipTypes principalType = RelationshipTypes.One, RelationshipTypes dependantType = RelationshipTypes.Many, string?linkTable = null)
    {
        if (principalFields is null)
        {
            throw new ArgumentNullException(nameof(principalFields));
        }
        if (dependantFields is null)
        {
            throw new ArgumentNullException(nameof(dependantFields));
        }

        PrincipalModel = principalModel ?? throw new ArgumentNullException(nameof(principalModel));
        DependantModel = dependantModel ?? throw new ArgumentNullException(nameof(dependantModel));
        PrincipalFields.AddRange(principalFields);
        DependantFields.AddRange(dependantFields);
        PrincipalType = principalType;
        DependantType = dependantType;

        LinkTable = PrincipalType == RelationshipTypes.Many && DependantType == RelationshipTypes.Many && string.IsNullOrWhiteSpace(linkTable)
            ? principalModel.Value + dependantModel.Value
            : linkTable;
    }
Example #22
0
 /// <summary>
 /// Defines a data relationship.
 /// </summary>
 /// <param name="relationType"></param>
 public RelationshipAttribute(RelationshipTypes relationType)
 {
     RelationType = relationType;
 }
Example #23
0
 /// <summary>
 /// Creates a new instance of this class.
 /// </summary>
 /// <param name="name">Name of the property.</param>
 /// <param name="friendlyName">
 /// Friendly display name for the property.
 /// </param>
 /// <param name="defaultValue">
 /// Default value for the property.
 /// </param>
 /// <param name="relationship">Relationship with
 /// referenced object.</param>
 public PropertyInfo(string name, string friendlyName, T defaultValue, RelationshipTypes relationship) : this(name, friendlyName, defaultValue)
 {
     _relationshipType = relationship;
 }
Example #24
0
 /// <summary>
 /// Defines a data relationship.
 /// </summary>
 /// <param name="entityType">The type of the child entity.</param>
 /// <param name="relationType">The relationship type can be "One" or "Many".</param>
 public RelationshipAttribute(Type entityType, RelationshipTypes relationType)
 {
     EntityType = entityType;
     RelationType = relationType;
 }
Example #25
0
        /// <summary>
        /// Indicates that the specified property belongs
        /// to the business object type.
        /// </summary>
        /// <typeparam name="P">Type of property</typeparam>
        /// <param name="propertyLambdaExpression">Property Expression</param>
        /// <param name="relationship">Relationship with
        /// referenced object.</param>
        /// <returns></returns>
        protected static PropertyInfo <P> RegisterProperty <P>(Expression <Func <T, object> > propertyLambdaExpression, RelationshipTypes relationship)
        {
            PropertyInfo reflectedPropertyInfo = Reflect <T> .GetProperty(propertyLambdaExpression);

            return(RegisterProperty <P>(reflectedPropertyInfo.Name, relationship));
        }
Example #26
0
 /// <summary>
 /// Defines a data relationship.
 /// </summary>
 /// <param name="relationType"></param>
 public RelationshipAttribute(RelationshipTypes relationType)
 {
     RelationType = relationType;
 }
Example #27
0
 /// <summary>
 /// Indicates that the specified property belongs
 /// to the business object type.
 /// </summary>
 /// <typeparam name="P">Type of property</typeparam>
 /// <param name="propertyName">Property name from nameof()</param>
 /// <param name="friendlyName">Friendly description for a property to be used in databinding</param>
 /// <param name="defaultValue">Default Value for the property</param>
 /// <param name="relationship">Relationship with
 /// referenced object.</param>
 /// <returns></returns>
 protected static PropertyInfo <P> RegisterProperty <P>(string propertyName, string friendlyName, P defaultValue, RelationshipTypes relationship)
 {
     return(RegisterProperty(Csla.Core.FieldManager.PropertyInfoFactory.Factory.Create <P>(typeof(T), propertyName, friendlyName, defaultValue, relationship)));
 }
Example #28
0
 /// <summary>
 /// Defines a data relationship.
 /// </summary>
 /// <param name="entityType">The type of the child entity.</param>
 /// <param name="relationType">The relationship type can be "One" or "Many".</param>
 public RelationshipAttribute(Type entityType, RelationshipTypes relationType)
 {
     EntityType   = entityType;
     RelationType = relationType;
 }
Example #29
0
 /// <summary>
 /// Creates a new instance of this class.
 /// </summary>
 /// <param name="name">Name of the property.</param>
 /// <param name="friendlyName">
 /// Friendly display name for the property.
 /// </param>
 /// <param name="containingType">
 /// Factory to provide display name from attributes.
 /// </param>
 /// <param name="relationship">Relationship with referenced object.</param>
 public PropertyInfo(string name, string friendlyName, Type containingType, RelationshipTypes relationship)
     : this(name, friendlyName, null, DataBindingFriendlyDefault(), relationship)
 {
 }
Example #30
0
 public static Model AddRelation(this Model model, string[] principalFields, string dependant, string[] dependantFields, RelationshipTypes principalType, RelationshipTypes dependantType, string?linkTable)
 {
     model.Relationships.Add(new Relationship()
     {
         PrincipalFields = principalFields.Select(f => new Name(f)).ToList(),
         PrincipalModel  = model.Name,
         PrincipalType   = principalType,
         DependantFields = dependantFields.Select(f => new Name(f)).ToList(),
         DependantModel  = new Name(dependant),
         DependantType   = dependantType,
         LinkTable       = linkTable
     });
     return(model);
 }