Ejemplo n.º 1
0
            public async Task SetValueAsync(object value, CancellationToken cancellationToken)
            {
                if (SerializedInputValue == null)
                {
                    return;
                }

                var entity = value as TEntity;

                if (entity == null)
                {
                    return;
                }

                var serializedOutputValue = JsonConvert.SerializeObject(entity);

                if (string.Equals(
                        SerializedInputValue,
                        serializedOutputValue,
                        StringComparison.Ordinal))
                {
                    return;
                }

                var table    = ResolvedAttribute.GetTableReference <TEntity>(ConfigContext);
                var entityId = ResolvedAttribute.GetEntityId(ConfigContext);

                await table.UpdateEntityAsync(entityId, entity, cancellationToken);
            }
            public object GetValue()
            {
                var table                 = ResolvedAttribute.GetTableReference <TEntity>(ConfigContext);
                var parameterType         = Parameter.ParameterType;
                var genericTypeDefinition = parameterType.GetGenericTypeDefinition();

                if (genericTypeDefinition == typeof(IAsyncCollector <>))
                {
                    return(new TableAsyncCollector <TEntity>(table));
                }

                return(table);
            }
Ejemplo n.º 3
0
            public object GetValue()
            {
                if (string.IsNullOrEmpty(ResolvedAttribute.EntityId))
                {
                    SerializedInputValue = null;
                    return(null);
                }

                var table    = ResolvedAttribute.GetTableReference <TEntity>(ConfigContext);
                var entityId = ResolvedAttribute.GetEntityId(ConfigContext);
                var entity   = table.GetEntityAsync(entityId).Result;

                if (entity == null)
                {
                    SerializedInputValue = null;
                    return(null);
                }

                SerializedInputValue = JsonConvert.SerializeObject(entity);
                return(entity);
            }