public IModelConfiguration <TModel> ForMember <TProperty>(Expression <Func <TModel, TProperty> > propExpression, Action <IMemberConfiguration <TModel, TProperty> > action)
        {
            var propName = propExpression.GetFullPropertyName();
            var propInfo = ModelType.GetProperty(propName);

            if (propInfo == null)
            {
                throw new NullReferenceException(string.Format("Type '{0}' does not contain a property with name '{1}'.", ModelType, propName));
            }

            IMemberConfiguration memberConfiguration;

            if (MemberConfigurations.ContainsKey(propName))
            {
                memberConfiguration = MemberConfigurations[propName];
            }
            else
            {
                memberConfiguration = new MemberConfiguration <TModel, TProperty>(propInfo);
                BreezeConfigurator.OnSerializationMemberRuleCreated(memberConfiguration);
                MemberConfigurations[propName] = memberConfiguration;
            }
            if (action != null)
            {
                action((IMemberConfiguration <TModel, TProperty>)memberConfiguration);
            }
            return(this);
        }
Exemple #2
0
        public ITypeConfiguration <TType> ForMember <TProperty>(Expression <Func <TType, TProperty> > propExpression, Action <IFieldConfiguration <TType, TProperty> > action)
        {
            var propName = propExpression.GetFullPropertyName();
            var propInfo = ModelType.GetProperty(propName);

            if (propInfo == null)
            {
                throw new NullReferenceException(string.Format("Type '{0}' does not contain a property with name '{1}'.", ModelType, propName));
            }

            IFieldConfiguration fieldConfiguration;

            if (MemberConfigurations.ContainsKey(propName))
            {
                fieldConfiguration = MemberConfigurations[propName];
            }
            else
            {
                fieldConfiguration             = new FieldConfiguration <TType, TProperty>(propInfo);
                MemberConfigurations[propName] = fieldConfiguration;
            }

            if (action != null)
            {
                action((IFieldConfiguration <TType, TProperty>)fieldConfiguration);
            }

            return(this);
        }
        public IModelConfiguration <TModel> AddMember <TProperty>(string serializedName, Action <ICustomMemberConfiguration <TModel, TProperty> > action)
        {
            IMemberConfiguration memberConfiguration;

            if (MemberConfigurations.ContainsKey(serializedName))
            {
                memberConfiguration = MemberConfigurations[serializedName];
            }
            else
            {
                memberConfiguration = new MemberConfiguration <TModel, TProperty>(serializedName, typeof(TProperty), typeof(TModel));
                BreezeConfigurator.OnSerializationMemberRuleCreated(memberConfiguration);
                MemberConfigurations[serializedName] = memberConfiguration;
            }
            action?.Invoke((ICustomMemberConfiguration <TModel, TProperty>)memberConfiguration);
            return(this);
        }