private void InitalDataField(object source, IFieldCollection collection) { foreach (DataFieldMapping field in collection.GetFieldMappings()) { if (field == null) { continue; } if (field is IFieldCollection) { IFieldCollection ifc = field as IFieldCollection; object obj = ifc.InitialData(); field.Handler.Set(source, obj); } else { if (field.DefaultValue != null) { if (field.SpecifiedHandler != null) { field.SpecifiedHandler.Set(source, true); } field.Handler.Set(source, field.ToProperty(field.DefaultValue)); } } } }
/// <summary> /// Returns a list with all fields that have different values for two given work items. /// </summary> /// <param name="wordFields">Fields of a Word work item.</param> /// <param name="tfsFields">Fields of a TFS work item.</param> /// <param name="ignoreFormatting">Sets whether formatting is ignored.</param> /// <returns>List of different fields.</returns> public static Collection <IField> GetFieldsWithDifferentValues2(IFieldCollection wordFields, IFieldCollection tfsFields, bool ignoreFormatting) { Guard.ThrowOnArgumentNull(wordFields, "wordFields"); Guard.ThrowOnArgumentNull(tfsFields, "tfsFields"); var changedFields = new Collection <IField>(); foreach (var field in wordFields) { try { if (tfsFields.Contains(field.ReferenceName)) { if (!tfsFields[field.ReferenceName].CompareValue(wordFields[field.ReferenceName].Value, ignoreFormatting)) { changedFields.Add(field); } } } catch (KeyNotFoundException) { SyncServiceTrace.W("Converter value not found. Please check your configuration"); } } return(changedFields); }
public static IReadOnlyLogbook Build <TModel>(IFieldCollection fields, IFieldValuePairs fieldValuePairs, IFieldPredicatePairs fieldPredicatePairs, out IEnumerable <QueryField> queryFields) where TModel : class, IModel, new() { queryFields = Enumerable.Empty <QueryField>(); ILogbook logs = Logger.NewLogbook(); if (!fields.IsSubsetOfModel <TModel>()) { logs.Failure("Qualifier fields must be subset of model fields"); return(logs); } ICollection <QueryField> queryFieldCollection = new Collection <QueryField>(); foreach (Field field in fields) { bool valueFound = fieldValuePairs.TryGetValue(field, out object value); bool predicateFound = fieldPredicatePairs.TryGetValue(field, out ReadOnlyLogbookPredicate <object> predicate); if (valueFound && predicateFound && predicate != null) { logs.AddRange(predicate.Invoke(value)); } if (!logs.Safely) { break; } } return(logs); }
public async Task InvokeAsync(IMiddlewareContext context) { IFieldCollection <IInputField> arguments = context.Selection.Field.Arguments; foreach (IInputField argument in arguments) { var value = context.ArgumentValue <object?>(argument.Name) !; Type actualType = value.GetType(); if (argument.RuntimeType != actualType) { context.ReportError($"RuntimeType ({argument.RuntimeType}) not equal to actual type ({actualType})"); } if (context.Selection.Field.Name.Value.StartsWith("array")) { if (!argument.RuntimeType.IsArray) { context.ReportError($"Field defined with array but ArgDeg saying it's a {argument.RuntimeType}"); } if (!actualType.IsArray) { context.ReportError($"Field defined with array but actual type is a {actualType}"); } } } await _next(context); }
public TypeMemberCollection() { _fields = new FieldCollection(); _methods = new MethodCollection(); _properties = new PropertyCollection(); _events = new EventCollection(); }
public static IReadOnlyLogbook Build(IFieldCollection fields, IFieldValuePairs fieldValuePairs, IFieldPredicatePairs fieldPredicatePairs, IFieldOperationPairs fieldOperationPairs, out IEnumerable <QueryField> queryFields) { queryFields = Enumerable.Empty <QueryField>(); ILogbook logs = Logger.NewLogbook(); ICollection <QueryField> queryFieldCollection = new Collection <QueryField>(); foreach (Field field in fields) { bool valueFound = fieldValuePairs.TryGetValue(field, out object value); bool predicateFound = fieldPredicatePairs.TryGetValue(field, out ReadOnlyLogbookPredicate <object> predicate); bool operationFound = fieldOperationPairs.TryGetValue(field, out Operation operation); if (valueFound && predicateFound && predicate != null) { logs.AddRange(predicate.Invoke(value)); } if (!logs.Safely) { break; } if (valueFound && operationFound) { queryFieldCollection.Add(new QueryField(field, operation, value)); } } return(logs); }
public static string GenerateTreeView(IFieldCollection fields) { Debug.Assert(fields != null); var viewFields = from f in fields where !AbstractSqlModel.SystemReadonlyFields.Contains(f.Key) && !f.Value.Name.StartsWith("_") && f.Value.Type != FieldType.Text && f.Value.Type != FieldType.ManyToMany && f.Value.Type != FieldType.OneToMany select f.Value; var vb = new ViewBuilder(); vb.WriteTreeStart(); foreach (var f in viewFields) { if (f.Name == "name") { vb.WriteColumn(f.Name, "basic"); } else { vb.WriteColumn(f.Name, "advanced"); } } vb.WriteTreeEnd(); return(vb.ToString()); }
public InterpretedClass(ClassDeclarationExpression expression, Scope scope) { _rootscope = scope.Root; _name = expression.Name; _parents = expression.Parents; _interfaces = expression.Interfaces; _methods = new MethodCollection(); _fields = new FieldCollection(); _classes = new ClassCollection(); _static_variables = new VariableCollection(); ScriptScope script_scope = null; scope.FindNearestScope <ScriptScope> (ss => script_scope = ss); foreach (ClassMethodDeclarationExpression m in expression.Methods) { _methods.Add(new InterpretedMethod(m, script_scope)); } foreach (ClassFieldDeclarationExpression f in expression.Fields) { IVariable var = _static_variables.EnsureExists(f.Name); if (f.Initializer is Expression initializer_expr) { var.Value = Interpreters.Execute(initializer_expr, script_scope).ResultValue; } } }
/// <summary> /// Initializes a new instance of <see cref="LayoutBase{TTarget, TFieldSettings, TBuilder, TLayout}"/>. /// </summary> /// <param name="fieldBuilderFactory">Creates field builders.</param> /// <param name="fieldCollection">Stores field mappings.</param> protected LayoutBase( IFieldSettingsBuilderFactory <TBuilder, TFieldSettings> fieldBuilderFactory, IFieldCollection <TFieldSettings> fieldCollection) : base(fieldCollection) { _fieldBuilderFactory = fieldBuilderFactory; InstanceFactory = ReflectionHelper.CreateConstructor(TargetType); }
public FixedLengthLayoutDescriptor( IFieldCollection <IFixedFieldSettingsContainer> fieldsContainer, Type targetType, FixedLengthFileAttribute fileAttribute) : base(fieldsContainer, targetType) { HasHeader = fileAttribute.HasHeader; }
public void ReadAllProperties_UnitTest() { IWorkItem workItem = GetTestWorkItem(); FieldCollection real = WorkItemWrapper.GetInstance(workItem).Fields; IFieldCollection instance = FieldCollectionWrapper.GetWrapper(real); ReadAllProperties(typeof(IFieldCollection), instance); }
/// <summary> /// Initializes a new <see cref="DelimitedLayout{TTarget}"/>. /// </summary> /// <param name="fieldSettingsFactory">Creates delimited field configurations.</param> /// <param name="fieldsContainer">Stores the field configurations in a layout.</param> public DelimitedLayout( IFieldSettingsBuilderFactory <IDelimitedFieldSettingsBuilder, IDelimitedFieldSettingsContainer> fieldSettingsFactory, IFieldCollection <IDelimitedFieldSettingsContainer> fieldsContainer) : base(fieldSettingsFactory, fieldsContainer) { Quotes = string.Empty; Delimiter = ","; }
public DelimitedLayoutDescriptor( IFieldCollection <IDelimitedFieldSettingsContainer> fieldsContainer, Type targetType, DelimitedFileAttribute fileAttribute) : base(fieldsContainer, targetType) { HasHeader = fileAttribute.HasHeader; Delimiter = fileAttribute.Delimiter ?? ","; Quotes = fileAttribute.Quotes ?? string.Empty; }
protected AbstractExtendedModel(string name) : base(name) { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } this.fields = new FieldCollection(this); }
protected AbstractModel(string name) : base(name) { this.Order = DefaultOrder; this.IsVersioned = true; this.AutoMigration = true; this.fields = new FieldCollection(this); this.Inheritances = new InheritanceCollection(); this.RegisterInternalServiceMethods(); this.AddInternalFields(); }
private void InitMembers() { if (_members != null) { return; } _fields = new FieldList(this); _properties = new PropertyList(this); _events = new EventList(this); _methods = new MethodList(this); _members = new TypeMemberCollection(_fields, _methods, _properties, _events); }
public static bool Build(this IFieldCollection fieldCollection, out IEnumerable <Field> fields) { fields = Enumerable.Empty <Field>(); if (fieldCollection.HasField) { fields = fieldCollection; return(true); } return(false); }
public static bool Build <TModel>(this IFieldCollection fieldCollection, out IEnumerable <Field> fields) where TModel : class, IModel, new() { fields = Enumerable.Empty <Field>(); if (fieldCollection.HasField && fieldCollection.IsSubsetOfModel <TModel>()) { fields = fieldCollection; return(true); } return(false); }
private void CheckArguments( IFieldCollection <IInputField> declaredArguments, IReadOnlyCollection <ArgumentNode> assignedArguments) { foreach (ArgumentNode argument in assignedArguments) { if (!declaredArguments.ContainsField(argument.Name.Value)) { Errors.Add(new ValidationError( $"The argument `{argument.Name.Value}` does not " + "exist.", argument)); } } }
private void ValidateArguments( IFieldCollection <IInputField> arguments, IEnumerable <ArgumentNode> argumentNodes) { foreach (ArgumentNode argument in argumentNodes) { if (argument.Value is VariableNode vn && arguments.TryGetField(argument.Name.Value, out IInputField f)) { _variablesUsages.Add( new VariableUsage(f, argument, vn)); } } }
public static bool TryGetField <T>( this IFieldCollection <T> collection, NameString fieldName, [NotNullWhen(true)] out T field) where T : IField { if (collection.ContainsField(fieldName)) { field = collection[fieldName]; return(true); } field = default; return(false); }
private void VisitArguments( IEnumerable <ArgumentNode> arguments, IFieldCollection <IInputField> argumentFields) { foreach (ArgumentNode argument in arguments) { if (argument.Value is ObjectValueNode ov && argumentFields.TryGetField(argument.Name.Value, out IInputField argumentField) && argumentField.Type.NamedType() is InputObjectType io) { VisitObjectValue(io, ov); } } }
private void LoadDataField(object source, IFieldCollection collection, DataRow datarow) { foreach (AggregateFieldMapping field in collection.GetFieldMappings()) { if (field == null) { continue; } object obj = datarow [field.Name]; bool isnull = Object.Equals(obj, DBNull.Value); if (!isnull) { field.Handler.Set(source, field.ToProperty(obj)); } } }
public static string GenerateFormView(IFieldCollection fields) { Debug.Assert(fields != null); Func <FieldType, bool> isBigFieldDlg = (FieldType ft) => ft == FieldType.OneToMany || ft == FieldType.ManyToMany || ft == FieldType.Text; var smallFields = from f in fields where !AbstractSqlModel.SystemReadonlyFields.Contains(f.Key) && !f.Value.Name.StartsWith("_") && !isBigFieldDlg(f.Value.Type) select f; //生成单行字段 var vb = new ViewBuilder(); vb.WriteFormStart(); foreach (var f in smallFields) { vb.WriteFieldLabel(f.Value.Name); vb.WriteField(f.Value.Name); } var bigFields = from f in fields where !AbstractSqlModel.SystemReadonlyFields.Contains(f.Key) && !f.Key.StartsWith("_") && isBigFieldDlg(f.Value.Type) select f; //生成比较占空间的字段 foreach (var f in bigFields) { vb.WriteNewLine(); vb.WriteHLine(f.Value.Label); vb.WriteNewLine(); vb.WriteField(f.Value.Name, 4, true); } vb.WriteFormEnd(); return(vb.ToString()); }
void LoadDataField(object source, IFieldCollection collection, DataContext context, DataRow datarow) { foreach (DataFieldMapping field in collection.GetFieldMappings()) { if (field == null) { continue; } if (field is IFieldCollection) { IFieldCollection ifc = field as IFieldCollection; object obj = ifc.LoadData(context, datarow); field.Handler.Set(source, obj); } else { object obj = field.DataOrder.HasValue ? datarow [field.DataOrder.Value] : datarow [field.Name]; bool isnull = Object.Equals(obj, DBNull.Value); if (field.SpecifiedHandler != null) { if (isnull && field.DefaultValue == null) { field.SpecifiedHandler.Set(source, false); } else { field.SpecifiedHandler.Set(source, true); } } if (!isnull) { field.Handler.Set(source, field.ToProperty(obj)); } else { if (field.DefaultValue != null) { field.Handler.Set(source, field.ToProperty(field.DefaultValue)); } } } } }
public TypeMemberCollection(IFieldCollection fields, IMethodCollection methods, IPropertyCollection properties, IEventCollection events) { if (fields == null) { throw new ArgumentNullException("fields"); } if (methods == null) { throw new ArgumentNullException("methods"); } if (properties == null) { throw new ArgumentNullException("properties"); } if (events == null) { throw new ArgumentNullException("events"); } _fields = fields; _methods = methods; _properties = properties; _events = events; }
private void ValidateRequiredArguments( ISyntaxNode parent, IEnumerable <ArgumentNode> providedArguments, IFieldCollection <IInputField> arguments) { ILookup <string, ArgumentNode> providedArgumentLookup = providedArguments.ToLookup(t => t.Name.Value); foreach (InputField requiredArgument in arguments .Where(t => IsRequiredArgument(t))) { ArgumentNode providedArgument = providedArgumentLookup[requiredArgument.Name] .FirstOrDefault(); if (providedArgument == null || providedArgument.Value is NullValueNode) { Errors.Add(new ValidationError( $"The argument `{requiredArgument.Name}` is required " + "and does not allow null values.", parent)); } } }
private static List <ListDataAsStreamProperty> TransformRowData(JsonElement row, IFieldCollection fields, Dictionary <string, IField> fieldLookupCache) { List <ListDataAsStreamProperty> properties = new List <ListDataAsStreamProperty>(); foreach (var property in row.EnumerateObject()) { // Doing the field lookup is expensive given it happens per field/row, caching drastically improves performance when reading large sets of items if (!fieldLookupCache.TryGetValue(property.Name, out IField field)) { field = fields.AsRequested().FirstOrDefault(p => p.InternalName == property.Name); fieldLookupCache.Add(property.Name, field); } if (field != null) { var streamProperty = new ListDataAsStreamProperty() { Field = field, Type = field.FieldTypeKind, Name = property.Name }; // Is this a field that needs to be wrapped into a special field type? var specialField = DetectSpecialFieldType(streamProperty.Name, field); if (specialField != null) { streamProperty.IsArray = specialField.Item2; if (property.Value.ValueKind == JsonValueKind.Array) { #region Sample json responses /* * "PersonSingle": [ * { * "id": "15", * "title": "Kevin Cook", * "email": "*****@*****.**", * "sip": "*****@*****.**", * "picture": "" * } * ], * * "PersonMultiple": [ * { * "id": "14", * "value": "Anna Lidman", * "title": "Anna Lidman", * "email": "*****@*****.**", * "sip": "*****@*****.**", * "picture": "" * }, * { * "id": "6", * "value": "Bert Jansen (Cloud)", * "title": "Bert Jansen (Cloud)", * "email": "*****@*****.**", * "sip": "*****@*****.**", * "picture": "" * } * ], * * "MMSingle": { * "__type": "TaxonomyFieldValue:#Microsoft.SharePoint.Taxonomy", * "Label": "LBI", * "TermID": "ed5449ec-4a4f-4102-8f07-5a207c438571" * }, * * "MMMultiple": [ * { * "Label": "LBI", * "TermID": "ed5449ec-4a4f-4102-8f07-5a207c438571" * }, * { * "Label": "MBI", * "TermID": "1824510b-00e1-40ac-8294-528b1c9421e0" * }, * { * "Label": "HBI", * "TermID": "0b709a34-a74e-4d07-b493-48041424a917" * } * ], * * "LookupSingle": [ * { * "lookupId": 71, * "lookupValue": "Sample Document 01", * "isSecretFieldValue": false * } * ], * * "LookupMultiple": [ * { * "lookupId": 1, * "lookupValue": "General", * "isSecretFieldValue": false * }, * { * "lookupId": 71, * "lookupValue": "Sample Document 01", * "isSecretFieldValue": false * } * ], * * "Location": { * "DisplayName": null, * "LocationUri": "https://www.bingapis.com/api/v6/addresses/QWRkcmVzcy83MDA5ODMwODI3MTUyMzc1ODA5JTdjMT9h%3d%3d?setLang=en", * "EntityType": null, * "Address": { * "Street": "Somewhere", * "City": "XYZ", * "State": "Vlaanderen", * "CountryOrRegion": "Belgium", * "PostalCode": "9999" * }, * "Coordinates": { * "Latitude": null, * "Longitude": null * } * }, */ #endregion // Add values that will become part of a FieldValueCollection later on foreach (var streamPropertyElement in property.Value.EnumerateArray()) { (var fieldValue, var isArray) = DetectSpecialFieldType(streamProperty.Name, field); var listDataAsStreamPropertyValue = new ListDataAsStreamPropertyValue() { FieldValue = fieldValue }; foreach (var streamPropertyElementValue in streamPropertyElement.EnumerateObject()) { listDataAsStreamPropertyValue.Properties.Add(streamPropertyElementValue.Name, GetJsonPropertyValueAsString(streamPropertyElementValue.Value)); } streamProperty.Values.Add(listDataAsStreamPropertyValue); } } else { /* * "Url": "https:\u002f\u002fpnp.com\u002f3", * "Url.desc": "something3", * * "LookupSingleField1": "", * "LookupSingleField1.": "", */ var listDataAsStreamPropertyValue = new ListDataAsStreamPropertyValue() { FieldValue = specialField.Item1 }; if (property.Value.ValueKind == JsonValueKind.Object) { foreach (var streamPropertyElementValue in property.Value.EnumerateObject()) { if (streamPropertyElementValue.Value.ValueKind == JsonValueKind.Object) { foreach (var streamPropertyElementValueLevel2 in streamPropertyElementValue.Value.EnumerateObject()) { listDataAsStreamPropertyValue.Properties.Add(streamPropertyElementValueLevel2.Name, GetJsonPropertyValueAsString(streamPropertyElementValueLevel2.Value)); } } else { listDataAsStreamPropertyValue.Properties.Add(streamPropertyElementValue.Name, GetJsonPropertyValueAsString(streamPropertyElementValue.Value)); } } } else { listDataAsStreamPropertyValue.Properties.Add(property.Name, GetJsonPropertyValueAsString(property.Value)); } streamProperty.Values.Add(listDataAsStreamPropertyValue); } } else { // Add as single property or simple choice collection /* * "Title": "Item1", * * "ChoiceMultiple": [ * "Choice 1", * "Choice 3", * "Choice 4" * ], */ streamProperty.Value = property.Value; } properties.Add(streamProperty); } else { /* * "Url.desc": "something3", * "DateTime1.": "2020-12-04T11:15:15Z", */ if (property.Name.Contains(".")) { string[] nameParts = property.Name.Split(new char[] { '.' }); var propertyToUpdate = properties.FirstOrDefault(p => p.Name == nameParts[0]); if (propertyToUpdate != null && propertyToUpdate.Values.Count == 1 && !string.IsNullOrEmpty(nameParts[1])) { var valueToUpdate = propertyToUpdate.Values.FirstOrDefault(); if (valueToUpdate == null) { valueToUpdate = new ListDataAsStreamPropertyValue(); propertyToUpdate.Values.Add(valueToUpdate); } if (!valueToUpdate.Properties.ContainsKey(nameParts[1])) { valueToUpdate.Properties.Add(nameParts[1], GetJsonPropertyValueAsString(property.Value)); } } else if (propertyToUpdate != null && !string.IsNullOrEmpty(nameParts[1])) { //"Bool1.value": "1", if (!fieldLookupCache.TryGetValue(nameParts[0], out IField field2)) { field2 = fields.AsRequested().FirstOrDefault(p => p.InternalName == nameParts[0]); fieldLookupCache.Add(nameParts[0], field2); } // Extra properties on "regular" fields if (field2 != null && field2.FieldTypeKind == FieldType.Boolean && nameParts[1] == "value") { propertyToUpdate.Value = property.Value; } } else if (propertyToUpdate != null && string.IsNullOrEmpty(nameParts[1])) { // override the set Value propertyToUpdate.Value = property.Value; } } } } return(properties); }
partial void Fields_SetCondition(ref IRevision instance, ref IFieldCollection setValue);
public MergedFieldCollection(IReadOnlyFieldCollection collection_parent, IFieldCollection collection_own) : base(collection_parent, collection_own) { }
public Request(string resource, IEnumerable<KeyValuePair<string, string>> cookies, IEnumerable<KeyValuePair<string, string>> allFields) { this.resource = resource; this.cookies = new FieldCollection(cookies); this.allFields = new FieldCollection(allFields); }
public ItemBuilder WithFieldCollection(IFieldCollection fieldCollection) { _fieldCollection = fieldCollection; return this; }