Beispiel #1
0
        private static bool IsFieldValid(FieldKind fieldKind, string value, out string errorMessage)
        {
            if ((value is null) || (value.Length == 0))
            {
                errorMessage = $"{fieldKind} can't be empty";
                return(false);
            }

            short maxFieldLength;

            switch (fieldKind)
            {
            case FieldKind.FirstName: maxFieldLength = MaxFirstNameLength; break;

            case FieldKind.LastName: maxFieldLength = MaxLastNameLength; break;

            case FieldKind.Nickname: maxFieldLength = MaxNicknameLength; break;

            case FieldKind.Mailer: maxFieldLength = MaxMailerLength; break;

            case FieldKind.Note: maxFieldLength = MaxNoteLength; break;

            default: throw new ArgumentException("IsFieldValid used for a FieldKind that has its own special validator.");
            }

            var isLengthValid = value.Length <= maxFieldLength;

            errorMessage = isLengthValid ? string.Empty : $"{fieldKind} is too long";

            return(isLengthValid);
        }
Beispiel #2
0
        public void UpdateValidSpecialTests(ResourceId resourceId, FieldKind fieldKind, ValidUpdateSpecial testcase)
        {
            var properties = GenerateProperties(Commons.FieldTypeAPI, Label.Min, Caption.Min, Search.True, Match.False, Web.False, Highlight.False, Require.False, DateTimeDefault.Date);

            ValidUpdateRequestSpecialMapper[testcase](properties);
            var fieldId        = fieldKind == FieldKind.UserDefine ? PrepareUserField.Data[resourceId].FirstOrDefault() : PrepareAppField.Data[resourceId].FirstOrDefault();
            var request        = GenerateRequest(Parameters.Update, GenerateUpdateInfos(resourceId, fieldId, properties));
            var defaultManager = new DefaultManager();
            var result         = defaultManager.Send(FieldManager.FieldHandlingRelativeUrl, JsonConvert.SerializeObject(request), HttpMethod.PUT);

            PrAssert.That(result, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.NoContent), "Can not update field");

            // Check field isn't updated
            var fieldManager = new FieldManager();
            var readResult   = fieldManager.GetFieldDetails(fieldId);

            PrAssert.That(readResult, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not read field");
            if (testcase == ValidUpdateSpecial.UpdateEnabledProp)
            {
                PrAssert.That(readResult.Result.Values[fieldId].Properties.ContainsKey(properties.Last().Key), PrIs.EqualTo(false), "Value is updated");
            }
            else
            {
                var resultData = readResult.Result.Values[fieldId].Properties[properties.Last().Key];
                PrAssert.That(resultData, PrIs.Not.EqualTo(properties.Last().Value), "Value is updated");
            }
        }
Beispiel #3
0
        static void fillFields(Type rootObjectType,List<Field> fields, ParameterExpression par,Expression parent,string namePrefix, Type t,FieldKind fieldKind)
        {
            if(t.IsPrimitive || t == typeof(string) || t == typeof(DateTime)){
                var field = CreateSimpleProperty(t,t,par,parent,namePrefix,fieldKind);
                field.Name = string.IsNullOrEmpty(namePrefix) ? "x": namePrefix ;
                fields.Add(field);
            }else {
                PropertyInfo[] properties = t.GetProperties();
                foreach (var property in properties) {
                    if (property.PropertyType.IsPrimitive || property.PropertyType == typeof(string) || property.PropertyType == typeof(DateTime)) {
             					Field field = CreateSimpleProperty(rootObjectType,property.PropertyType,par,parent,property.Name,fieldKind);
                        field.Name = string.IsNullOrEmpty(namePrefix) ?  property.Name : namePrefix + "." + property.Name;
                        fields.Add(field);
                    } else {

                        if(property.PropertyType.IsArray)
                            continue;
                        if(property.PropertyType.IsGenericType){
                            var genType = property.PropertyType.GetGenericTypeDefinition();
                            if((typeof(List<>)).IsAssignableFrom(genType))
                                continue;
                        }

                        var expr = Expression.Property(parent,property.Name);
                        fillFields(rootObjectType,fields, par,expr,property.Name,property.PropertyType,fieldKind);
                    }
                }
            }
        }
        internal static string ExtractFieldNameAsInSourceCode(string name, out FieldKind kind)
        {
            string result;

            if (EvaluateCriteria(AutoPropertyMask, name, out result))
            {
                kind = FieldKind.AutoProperty;
                return(result);
            }

            if (EvaluateCriteria(AnonymousTypeFieldMask, name, out result))
            {
                kind = FieldKind.AnonymousClass;
                return(result);
            }

            // TODO: add a conditional compilation here for Mono/Xamarin
            if (EvaluateCriteria(MonoAnonymousTypeFieldMask, name, out result))
            {
                kind = FieldKind.AnonymousClass;
                return(result);
            }

            result = name;
            kind   = FieldKind.Normal;
            return(result);
        }
Beispiel #5
0
        public static bool IsShowInList(IFieldControl control, Tk5ListDetailConfig listDetail,
                                        FieldKind kind, IPageStyle style, bool isInTable)
        {
            if (control == null)
            {
                return(false);
            }
            if ((control.DefaultShow & PageStyle.List) != PageStyle.List ||
                kind != FieldKind.Data)
            {
                return(false);
            }

            if (isInTable)
            {
                var ctrl = control.GetControl(style);
                if (ctrl == ControlType.Hidden)
                {
                    return(false);
                }
                if (listDetail != null && listDetail.Search == FieldSearchMethod.Only)
                {
                    return(false);
                }
            }

            return(true);
        }
Beispiel #6
0
 public Field(PtField source, IClass container, FieldKind kind, string name)
 {
     Source    = source;
     Container = container;
     Kind      = kind;
     Name      = name;
 }
Beispiel #7
0
        public ThriftMethodExtractor(
            short fieldId, String fieldName, FieldKind fieldKind, MethodInfo method, Type fieldType)
        {
            Guard.ArgumentNullOrWhiteSpaceString(fieldName, nameof(fieldName));
            Guard.ArgumentNotNull(method, nameof(method));
            Guard.ArgumentNotNull(fieldType, nameof(fieldType));

            //    this.name = checkNotNull(fieldName, "name is null");
            //this.method = checkNotNull(method, "method is null");
            //this.fieldKind = checkNotNull(fieldKind, "fieldKind is null");
            this.Name      = fieldName;
            this.Method    = method;
            this.FieldKind = fieldKind;

            this.Type = fieldType;
            //不支持 Union
            //switch (fieldKind)
            //{
            //    case FieldKind.ThriftField:
            //        // Nothing to check
            //        break;
            //    case FieldKind.ThriftUnionId:
            //        checkArgument(fieldId == Short.MIN_VALUE, "fieldId must be Short.MIN_VALUE for thrift_union_id");
            //        break;
            //}

            this.Id = fieldId;
        }
        public ThriftFieldExtractor(
            short fieldId, String fieldName, FieldKind fieldKind, PropertyInfo field, Type fieldType)
        {
            Guard.ArgumentNotNull(fieldType, nameof(fieldType));
            Guard.ArgumentNullOrWhiteSpaceString(fieldName, nameof(fieldName));
            Guard.ArgumentNotNull(field, nameof(field));

            this.Name      = fieldName;
            this.Field     = field;
            this.FieldKind = fieldKind;
            this.Type      = field.PropertyType;

            switch (fieldKind)
            {
            case FieldKind.ThriftField:
                // nothing to check
                break;

            case FieldKind.ThriftUnionId:
                if (fieldId != short.MinValue)
                {
                    new ArgumentOutOfRangeException(nameof(fieldId), "fieldId must be short.MinValue for thrift_union_id");
                }
                break;
            }
            this.Id = fieldId;
        }
Beispiel #9
0
 public static IEnumerable<Field> CreateFields(object obj,string name, FieldKind fieldKind )
 {
     Type rootObjectType = obj.GetType();
     foreach(var field in CreateFields (rootObjectType, name,  fieldKind )){
        	field.DefaultValue = obj;
         yield return field;
     }
 }
Beispiel #10
0
        public static Field[] CreateFields(Type rootObjectType,string name, FieldKind fieldKind )
        {
            List<Field> fields = new List<Field>();

            ParameterExpression arg = Expression.Parameter(rootObjectType, name);
            fillFields(rootObjectType,fields,arg,arg,name,rootObjectType,fieldKind);
            return fields.ToArray ();
        }
Beispiel #11
0
        public FieldExtractor(PropertyInfo field, ThriftFieldAttribute annotation, FieldKind fieldKind)
            : base(annotation, fieldKind)
        {
            Guard.ArgumentNotNull(field, nameof(field));

            this.CSharpType = field.PropertyType;
            this.Field      = field;
        }
Beispiel #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EntityField" /> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="fieldKind">Kind of the field.</param>
 /// <param name="propertyType">Type of the property.</param>
 /// <param name="attributeGuid">The attribute unique identifier.</param>
 public EntityField(string name, FieldKind fieldKind, Type propertyType, Guid?attributeGuid = null) : this()
 {
     Name          = name;
     Title         = name.SplitCase();
     PropertyType  = propertyType;
     AttributeGuid = attributeGuid;
     FieldKind     = fieldKind;
 }
Beispiel #13
0
        public void UpdateValidRequireParamsTests(ResourceId resourceId, FieldKind fieldKind, Label label)
        {
            var properties = GenerateProperties(Commons.FieldTypeAPI, label, null, null, null, null, null, null, null);
            var fieldId    = fieldKind == FieldKind.UserDefine ? PrepareUserField.Data[resourceId].FirstOrDefault() : PrepareAppField.Data[resourceId].FirstOrDefault();
            var request    = GenerateRequest(Parameters.Update, GenerateUpdateInfos(resourceId, fieldId, properties));

            ExecuteUpdateTest(JsonConvert.SerializeObject(request), fieldId, properties);
        }
Beispiel #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EntityField"/> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="fieldKind">Kind of the field.</param>
 /// <param name="propertyType">Type of the property.</param>
 /// <param name="controlCount">The control count.</param>
 /// <param name="attributeId">The attribute identifier.</param>
 public EntityField(string name, FieldKind fieldKind, Type propertyType, int controlCount, int?attributeId = null)
 {
     Name         = name;
     Title        = name.SplitCase();
     FieldKind    = fieldKind;
     PropertyType = propertyType;
     ControlCount = controlCount;
     AttributeId  = attributeId;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="EntityField" /> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="fieldKind">Kind of the field.</param>
 /// <param name="propertyType">Type of the property.</param>
 /// <param name="attributeGuid">The attribute unique identifier.</param>
 public EntityField( string name, FieldKind fieldKind, Type propertyType, Guid? attributeGuid = null )
     : this()
 {
     Name = name;
     Title = name.SplitCase();
     PropertyType = propertyType;
     AttributeGuid = attributeGuid;
     FieldKind = fieldKind;
 }
Beispiel #16
0
 public Field(TokenSpan span, FieldKind kind, Identifier name, IType type, IExpression?init, String?doc)
 {
     Span = span;
     Kind = kind;
     Name = name;
     Type = type;
     Init = init;
     Doc  = doc;
 }
Beispiel #17
0
        public static IEnumerable <Field> CreateFields(object obj, string name, FieldKind fieldKind)
        {
            Type rootObjectType = obj.GetType();

            foreach (var field in CreateFields(rootObjectType, name, fieldKind))
            {
                field.DefaultValue = obj;
                yield return(field);
            }
        }
Beispiel #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EntityField"/> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="fieldKind">Kind of the field.</param>
 /// <param name="propertyType">Type of the property.</param>
 /// <param name="propertyInfo">The property information.</param>
 /// <param name="attributeGuid">The attribute unique identifier.</param>
 private EntityField(string name, FieldKind fieldKind, Type propertyType, PropertyInfo propertyInfo, Guid?attributeGuid)
 {
     FieldConfig   = new Dictionary <string, ConfigurationValue>();
     Name          = name;
     Title         = name.SplitCase();
     FieldKind     = fieldKind;
     PropertyType  = propertyType;
     PropertyInfo  = propertyInfo;
     AttributeGuid = attributeGuid;
 }
Beispiel #19
0
        public static Field[] CreateFields(Type rootObjectType, string name, FieldKind fieldKind)
        {
            List <Field> fields = new List <Field> ();


            ParameterExpression arg = Expression.Parameter(rootObjectType, name);

            fillFields(rootObjectType, fields, arg, arg, name, rootObjectType, fieldKind);
            return(fields.ToArray());
        }
Beispiel #20
0
        public void UpdateInvalidSpecialTests(ResourceId resourceId, FieldKind fieldKind, InvalidUpdateSpecial testcase)
        {
            var properties = GenerateProperties(Commons.FieldTypeAPI, null, null, null, null, null, null, null, null);

            InvalidUpdateRequestSpecialMapper[testcase](properties);
            var fieldId = fieldKind == FieldKind.UserDefine ? PrepareUserField.Data[resourceId].FirstOrDefault() : PrepareAppField.Data[resourceId].FirstOrDefault();
            var request = GenerateRequest(Parameters.Update, GenerateUpdateInfos(resourceId, fieldId, properties));
            var manager = new DefaultManager();
            var result  = manager.Send(FieldManager.FieldHandlingRelativeUrl, JsonConvert.SerializeObject(request), HttpMethod.PUT);

            PrAssert.That(result, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest), "Still update field successfull");
        }
Beispiel #21
0
        public static Field CreateSimpleProperty(Type rootObjectType,
			Type propertyType,
			ParameterExpression rootParameterExpression,
			Expression parentExpression,
			string name,
			FieldKind fieldKind)
        {
            var genericType = typeof(PropertyDataField<,>).MakeGenericType(rootObjectType, propertyType);
            var p = Activator.CreateInstance(genericType,rootParameterExpression,parentExpression,name) as Field;
            Field f = (p as Field);
            f.FieldKind = fieldKind;
            return f;
        }
Beispiel #22
0
        public static string GetFieldKindName(FieldKind fieldKind)
        {
            switch (fieldKind)
            {
            case FieldKind.FirstName: return("First name");

            case FieldKind.LastName: return("Last name");

            case FieldKind.FullName: return("Full name");

            default: return(fieldKind.ToString());
            }
        }
Beispiel #23
0
        public static Field  CreateSimpleProperty(Type rootObjectType,
                                                  Type propertyType,
                                                  ParameterExpression rootParameterExpression,
                                                  Expression parentExpression,
                                                  string name,
                                                  FieldKind fieldKind)
        {
            Field f;

            var genericType = typeof(PropertyDataField <,>).MakeGenericType(rootObjectType, propertyType);
            var p           = Activator.CreateInstance(genericType, rootParameterExpression, parentExpression, name) as Field;

            f           = (p as Field);
            f.FieldKind = fieldKind;

            return(f);
        }
Beispiel #24
0
        public void UpdateValidOptionalParamsTests(
            ResourceId resourceId,
            Label label,
            Caption caption,
            Search search,
            Match match,
            Web web,
            Highlight highlight,
            Require require,
            DateTimeDefault dateTimeDefault,
            FieldKind fieldKind)
        {
            var properties = GenerateProperties(Commons.FieldTypeAPI, label, caption, search, match, web, highlight, require, dateTimeDefault);
            var fieldId    = fieldKind == FieldKind.UserDefine ? PrepareUserField.Data[resourceId].FirstOrDefault() : PrepareAppField.Data[resourceId].FirstOrDefault();
            var request    = GenerateRequest(Parameters.Update, GenerateUpdateInfos(resourceId, fieldId, properties));

            ExecuteUpdateTest(JsonConvert.SerializeObject(request), fieldId, properties);
        }
Beispiel #25
0
        public void CreateTextBlockAtXY(string text, string fieldName, FieldKind fieldKind, double x, double y)
        {
            var point       = new Cairo.PointD(x / Zoom, y / Zoom);
            var sectionView = getSectionViewByXY(x, y);

            if (sectionView != null)
            {
                var localpoint = sectionView.PointInSectionByAbsolutePoint(point);
                ToolBoxService.SetToolByName("TextBlockTool");
                SelectedTool.CreateNewControl(sectionView);
                var textBlock = (SelectedControl.ControlModel as TextBlock);
                textBlock.Text          = fieldName;
                textBlock.FieldName     = fieldName;
                textBlock.FieldKind     = fieldKind;
                textBlock.Location      = new MonoReports.Model.Point(localpoint.X, localpoint.Y);
                SelectedTool.CreateMode = false;
            }
        }
        public ThriftFieldInjection(short id, String name, PropertyInfo field, FieldKind fieldKind)
        {
            Guard.ArgumentNullOrWhiteSpaceString(name, nameof(name));
            Guard.ArgumentNotNull(field, nameof(field));

            this.Name      = name;
            this.Field     = field;
            this.FieldKind = fieldKind;

            //不再支持 Union
            //switch (this.FieldKind)
            //{
            //    case FieldKind.ThriftField:
            //        // Nothing to check
            //        break;
            //    case FieldKind.ThriftUnionId:
            //        checkArgument(id == Short.MIN_VALUE, "fieldId must be Short.MIN_VALUE for thrift_union_id");
            //        break;
            //}

            this.Id = id;
        }
Beispiel #27
0
 public ExtendedFieldInfo(string prefix, FieldInfo info)
 {
     this.prefix = prefix;
     this.info   = info;
     if (EvaluateCriteria(AutoPropertyMask, info.Name, out this.nameInSource))
     {
         this.kind = FieldKind.AutoProperty;
     }
     else if (EvaluateCriteria(AnonymousTypeFieldMask, info.Name, out this.nameInSource))
     {
         this.kind = FieldKind.AnonymousClass;
     }
     else if (EvaluateCriteria(MonoAnonymousTypeFieldMask, info.Name, out this.nameInSource))
     {
         this.kind = FieldKind.AnonymousClass;
     }
     else
     {
         this.nameInSource = info.Name;
         this.kind         = FieldKind.Normal;
     }
 }
 private protected ResourceField(string name, FieldKind fieldType, FieldFlags flags, object defaultValue)
     : base(name, fieldType, flags | FieldFlags.Resource, defaultValue)
 {
 }
Beispiel #29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EntityField" /> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="fieldKind">Kind of the field.</param>
 /// <param name="propertyInfo">The property information.</param>
 public EntityField(string name, FieldKind fieldKind, PropertyInfo propertyInfo)
     : this(name, fieldKind, propertyInfo.PropertyType, propertyInfo, null)
 {
 }
Beispiel #30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EntityField" /> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="fieldKind">Kind of the field.</param>
 /// <param name="propertyType">Type of the property.</param>
 /// <param name="attributeGuid">The attribute unique identifier.</param>
 /// <param name="fieldType">Type of the field.</param>
 public EntityField(string name, FieldKind fieldKind, Type propertyType, Guid attributeGuid, FieldTypeCache fieldType)
     : this(name, fieldKind, propertyType, null, attributeGuid)
 {
     this.FieldType = fieldType;
 }
        //private IEnumerable<String> documentation;

        public ThriftFieldMetadata(
            short id,
            bool isRecursiveReference,
            Requiredness requiredness,
            //IEnumerable<KeyValuePair<String, String>> idlAnnotations,
            IThriftTypeReference thriftTypeReference,
            String name,
            FieldKind fieldKind,
            IEnumerable <IThriftInjection> injections       = null,
            ThriftConstructorInjection constructorInjection = null,
            ThriftMethodInjection methodInjection           = null,
            IThriftExtraction extraction = null,
            TypeCoercion coercion        = null
            )
        {
            Guard.ArgumentNotNull(thriftTypeReference, nameof(thriftTypeReference));
            Guard.ArgumentNotNull(fieldKind, nameof(fieldKind));
            Guard.ArgumentNullOrWhiteSpaceString(name, nameof(name));
            Guard.ArgumentNotNull(thriftTypeReference, nameof(thriftTypeReference));
            Guard.ArgumentNullOrWhiteSpaceString(name, nameof(name));
            //Guard.ArgumentNotNull(constructorInjection, nameof(constructorInjection));
            //Guard.ArgumentNotNull(methodInjection, nameof(methodInjection));
            //Guard.ArgumentNotNull(extraction, nameof(extraction));
            //Guard.ArgumentNotNull(coercion, nameof(coercion));

            this.IsRecursiveReference = isRecursiveReference;
            this.Required             = requiredness;
            this._thriftTypeReference = thriftTypeReference;
            this._fieldKind           = fieldKind;
            this.Name                  = name;
            this.Injections            = injections ?? Enumerable.Empty <IThriftInjection>();
            this._constructorInjection = constructorInjection;
            this._methodInjection      = methodInjection;

            this._extraction = extraction;
            this._coercion   = coercion;

            switch (fieldKind)
            {
            case FieldKind.ThriftField:
                Guard.ArgumentCondition(id >= 0, "isLegacyId must be specified on fields with negative IDs", nameof(id));

                break;

            case FieldKind.ThriftUnionId:
                Guard.ArgumentCondition(id == short.MinValue, "thrift union id must be short.MinValue", nameof(id));
                break;
            }

            Guard.ArgumentCondition(injections.Any() ||
                                    extraction != null ||
                                    constructorInjection != null ||
                                    methodInjection != null, "A thrift field must have an injection or extraction point");

            this.Id = id;

            if (extraction != null)
            {
                if (extraction is ThriftFieldExtractor)
                {
                    ThriftFieldExtractor e = (ThriftFieldExtractor)extraction;
                    //this.documentation = ThriftCatalog.getThriftDocumentation(e.getField());
                }
                else if (extraction != null && extraction is ThriftMethodExtractor)
                {
                    ThriftMethodExtractor e = (ThriftMethodExtractor)extraction;
                    //this.documentation = ThriftCatalog.getThriftDocumentation(e.getMethod());
                }
            }

            //this.idlAnnotations = idlAnnotations;
        }
Beispiel #32
0
        /// <summary>
        /// Gets <see cref="Expression"/> representing field value.
        /// </summary>
        /// <param name="name">Class constant name.</param>
        /// <param name="classCtx">Current class context. Can be <c>null</c>.</param>
        /// <param name="target">Expression representing self instance.</param>
        /// <param name="ctx">Expression representing current <see cref="Context"/>.</param>
        /// <param name="kind">Field kind.</param>
        /// <returns><see cref="Expression"/> instance or <c>null</c> if constant does not exist.</returns>
        internal Expression Bind(string name, Type classCtx, Expression target, Expression ctx, FieldKind kind)
        {
            FieldInfo fld;

            //
            if (_fields != null && _fields.TryGetValue(name, out fld))
            {
                if (fld.IsPublic && fld.IsLiteral)
                {
                    if (kind == FieldKind.Constant)
                    {
                        return Expression.Constant(fld.GetValue(null));
                    }
                }

                if (fld.IsStatic)
                {
                    if (kind == FieldKind.StaticField)
                    {
                        return Expression.Field(null, fld);
                    }
                }

                if (kind == FieldKind.InstanceField)
                {
                    Debug.Assert(target != null);
                    return Expression.Field(target, fld);
                }
            }

            //
            if (kind != FieldKind.InstanceField && _staticsFields != null && _staticsFields.TryGetValue(name, out fld))
            {
                if ((kind == FieldKind.Constant && fld.IsInitOnly) ||
                    (kind == FieldKind.StaticField))
                {
                    Debug.Assert(target == null);
                    Debug.Assert(ctx != null);

                    // Context.GetStatics<_statics>().FIELD
                    var getstatics = BinderHelpers.GetStatic_T_Method(fld.DeclaringType);
                    return Expression.Field(Expression.Call(ctx, getstatics), fld);
                }
            }

            //
            PropertyInfo p;
            if (kind != FieldKind.Constant && _properties != null && _properties.TryGetValue(name, out p))
            {
                var isstatic = p.GetMethod.IsStatic;
                if ((kind == FieldKind.StaticField) == isstatic)
                {
                    Debug.Assert(isstatic ? target == null : target != null);
                    return Expression.Property(target, p);
                }
            }

            //
            return null;
        }
Beispiel #33
0
 public EntityField( string name, FieldKind fieldKind, Type propertyType, Guid? attributeGuid = null )
     : this(name, fieldKind, propertyType, null, attributeGuid)
 {
 }
 private protected AssignmentField(string name, FieldKind fieldType, FieldFlags flags, object defaultValue)
     : base(name, fieldType, flags | FieldFlags.Assignment, defaultValue)
 {
 }
Beispiel #35
0
 public MethodExtractor(Type thriftStructType, MethodInfo method, ThriftFieldAttribute annotation, FieldKind fieldKind)
     : base(annotation, fieldKind)
 {
     this.CSharpType = thriftStructType;
     this.Method     = method;
 }
        public static void FillFields(string prefix, JToken token, List<Field> fieldsListToStore , FieldKind fieldKind)
        {
            if(token.Type ==  JTokenType.Property) {
                JProperty jp = token as JProperty;
                if(jp.Value.Type == JTokenType.Object){
                      FillFields(prefix + jp.Name + "." ,jp.Value,fieldsListToStore,fieldKind);
                }else if(jp.Value.Type == JTokenType.Array) {

                }else {
                    string propertyName = prefix + jp.Name;
                    Field f = fieldsListToStore.FirstOrDefault(theField => theField.Name == propertyName);
                    if(f == null) {
                        f = new Field();
                        fieldsListToStore.Add(f);
                    }
                    f.DefaultValue = JsonValueProvider.GetTokenVal(jp.Value, jp.Value.Type);
                    f.FieldKind = fieldKind;
                    f.FieldType = JsonValueProvider.GetTypeByTokenType(jp.Value.Type);
                    f.Name = propertyName;
                    f.DataProvider = new JsonValueProvider(jp);
                }

            } else if(token.Type ==  JTokenType.Object) {
                foreach(var c in token.Children())
                      FillFields(prefix,c,fieldsListToStore,fieldKind);
            }
        }
Beispiel #37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EntityField"/> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="fieldKind">Kind of the field.</param>
 /// <param name="propertyType">Type of the property.</param>
 /// <param name="propertyInfo">The property information.</param>
 /// <param name="attributeGuid">The attribute unique identifier.</param>
 private EntityField( string name, FieldKind fieldKind, Type propertyType, PropertyInfo propertyInfo, Guid? attributeGuid )
 {
     FieldConfig = new Dictionary<string, ConfigurationValue>();
     Name = name;
     Title = name.SplitCase();
     FieldKind = fieldKind;
     PropertyType = propertyType;
     PropertyInfo = propertyInfo;
     AttributeGuid = attributeGuid;
 }
Beispiel #38
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EntityField" /> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="fieldKind">Kind of the field.</param>
 /// <param name="propertyInfo">The property information.</param>
 public EntityField( string name, FieldKind fieldKind, PropertyInfo propertyInfo )
     : this(name, fieldKind, propertyInfo.PropertyType, propertyInfo, null)
 {
 }
Beispiel #39
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EntityField" /> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="fieldKind">Kind of the field.</param>
 /// <param name="propertyType">Type of the property.</param>
 /// <param name="controlCount">The control count.</param>
 /// <param name="attributeGuid">The attribute unique identifier.</param>
 public EntityField( string name, FieldKind fieldKind, Type propertyType, int controlCount, Guid? attributeGuid = null )
 {
     Name = name;
     Title = name.SplitCase();
     FieldKind = fieldKind;
     PropertyType = propertyType;
     ControlCount = controlCount;
     AttributeGuid = attributeGuid;
 }
Beispiel #40
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EntityField" /> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="fieldKind">Kind of the field.</param>
 /// <param name="propertyType">Type of the property.</param>
 /// <param name="attributeGuid">The attribute unique identifier.</param>
 /// <param name="fieldType">Type of the field.</param>
 public EntityField( string name, FieldKind fieldKind, Type propertyType, Guid attributeGuid, FieldTypeCache fieldType )
     : this(name, fieldKind, propertyType, null, attributeGuid)
 {
     this.FieldType = fieldType;
 }
Beispiel #41
0
        /// <summary>
        /// Gets <see cref="Expression"/> representing field value.
        /// </summary>
        /// <param name="name">Class constant name.</param>
        /// <param name="classCtx">Current class context. Can be <c>null</c>.</param>
        /// <param name="target">Expression representing self instance.</param>
        /// <param name="ctx">Expression representing current <see cref="Context"/>.</param>
        /// <param name="kind">Field kind.</param>
        /// <returns><see cref="Expression"/> instance or <c>null</c> if constant does not exist.</returns>
        internal Expression Bind(string name, Type classCtx, Expression target, Expression ctx, FieldKind kind)
        {
            FieldInfo fld;

            //
            if (_fields != null && _fields.TryGetValue(name, out fld) && TypeMembersUtils.IsVisible(fld, classCtx))
            {
                if (fld.IsPublic && fld.IsLiteral)
                {
                    if (kind == FieldKind.Constant)
                    {
                        return(Expression.Constant(fld.GetValue(null)));
                    }
                }

                if (fld.IsStatic)
                {
                    if (kind == FieldKind.InstanceField)
                    {
                        // TODO: Err: static field accessed with instance
                    }
                    return(Expression.Field(null, fld));
                }

                if (kind == FieldKind.InstanceField)
                {
                    Debug.Assert(target != null);
                    return(Expression.Field(target, fld));
                }
            }

            //
            if (kind != FieldKind.InstanceField && _staticsFields != null && _staticsFields.TryGetValue(name, out fld))
            {
                if ((kind == FieldKind.Constant && fld.IsInitOnly) ||
                    (kind == FieldKind.StaticField))
                {
                    Debug.Assert(target == null);
                    Debug.Assert(ctx != null);

                    // Context.GetStatics<_statics>().FIELD
                    var getstatics = BinderHelpers.GetStatic_T_Method(fld.DeclaringType);
                    return(Expression.Field(Expression.Call(ctx, getstatics), fld));
                }
            }

            //
            PropertyInfo p;

            if (kind != FieldKind.Constant && _properties != null && _properties.TryGetValue(name, out p))
            {
                var isstatic = p.GetMethod.IsStatic;
                if ((kind == FieldKind.StaticField) == isstatic)
                {
                    Debug.Assert((target == null) == isstatic);
                    return(Expression.Property(target, p));
                }
            }

            //
            return(null);
        }
        public void CreateTextBlockAtXY(string text, string fieldName, FieldKind fieldKind, double x, double y)
        {
            var point = new Cairo.PointD (x / (Zoom * Renderer.UnitMultipilier), y / (Zoom * Renderer.UnitMultipilier));
            var sectionView = getSectionViewByXY (point);

            if (sectionView != null) {
                IsDirty = true;
                var localpoint = sectionView.PointInSectionByAbsolutePoint (point);
                ToolBoxService.SetToolByName ("TextBlockTool");
                SelectedTool.CreateNewControl (sectionView);
                var textBlock = (SelectedControl.ControlModel as TextBlock);
                textBlock.Text = fieldName;
                textBlock.FieldName = fieldName;
                textBlock.FieldKind = fieldKind;
                textBlock.Location = new MonoReports.Model.Point (localpoint.X,localpoint.Y);
                SelectedTool.CreateMode = false;
            }
        }
Beispiel #43
0
        public void UpdateValidDuplicateParamsTests(ResourceId resourceId, Enum param, Enums.ValidDuplicated dupType, FieldKind fieldKind)
        {
            var properties      = GenerateProperties(Commons.FieldTypeAPI, Label.Min, Caption.Min, Search.True, Match.False, Web.False, Highlight.False, Require.False, DateTimeDefault.Date);
            var otherProperties = GenerateProperties(Commons.FieldTypeAPI, Label.Max, Caption.Max, Search.False, Match.True, Web.True, Highlight.True, Require.True, DateTimeDefault.Date);
            var fieldId         = fieldKind == FieldKind.UserDefine ? PrepareUserField.Data[resourceId].First() : PrepareAppField.Data[resourceId].First();
            var otherFieldId    = fieldKind == FieldKind.UserDefine ? PrepareUserField.Data[resourceId].Last() : PrepareAppField.Data[resourceId].Last();
            var request         = UpdateDuplicateRequest(resourceId, fieldId, otherFieldId, properties, otherProperties, param, dupType);
            var defaultManager  = new DefaultManager();
            var result          = defaultManager.Send(FieldManager.FieldHandlingRelativeUrl, request, HttpMethod.PUT);

            PrAssert.That(result, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.NoContent), "Can not update field with duplicate parameter value");
        }