public override int GetHashCode() { int hash = 1; if (ProfileId.Length != 0) { hash ^= ProfileId.GetHashCode(); } if (ProposalId.Length != 0) { hash ^= ProposalId.GetHashCode(); } if (ResultId.Length != 0) { hash ^= ResultId.GetHashCode(); } if (matchObject_ != null) { hash ^= MatchObject.GetHashCode(); } if (Timestamp.Length != 0) { hash ^= Timestamp.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
private ResultId VisitMemberAccess(MemberExpression expression) { if (expression.Expression is QuerySourceReferenceExpression) { var fieldInfo = (FieldInfo)expression.Member; return(this.GetInputId(fieldInfo)); } else { var targetType = expression.Expression.Type; if (this.vectorLibrary.IsVectorType(targetType)) { GetMemberData(expression, out string name, out var type); int fieldIndex; switch (name) { case "x": case "r": fieldIndex = 0; break; case "y": case "g": fieldIndex = 1; break; case "z": case "b": fieldIndex = 2; break; case "w": case "a": fieldIndex = 3; break; default: throw new Exception($"Unsupported field: {name}"); } ResultId targetId = this.Visit(expression.Expression); ResultId typeId = this.Visit(Expression.Constant(type)); ResultId accessId = this.file.GetNextResultId(); this.file.AddFunctionStatement(accessId, Op.OpCompositeExtract, typeId, targetId, fieldIndex); return(accessId); } else { throw new NotImplementedException("Member access is only implemented for vector types."); } } }
public async Task <IActionResult> Add(ScheduleDto schedule) { ResultId output = await _addScheduleUseCase.Execute(schedule); _schedulePresenter.Populate(output); return(_schedulePresenter.ContentResult); }
private ResultId GetInputId(FieldInfo fieldInfo) { ResultId typeId = this.Visit(Expression.Constant(fieldInfo.FieldType)); if (this.inputMappings.ContainsKey(fieldInfo)) { ResultId fieldId = this.inputMappings[fieldInfo]; ResultId resultId = this.file.GetNextResultId(); this.file.AddFunctionStatement(resultId, Op.OpLoad, typeId, fieldId); return(resultId); } else { ResultId pointerTypeId = this.Visit(Expression.Constant(typeof(UniformPointer <>).MakeGenericType(fieldInfo.FieldType))); var binding = this.bindingMappings[fieldInfo]; ResultId accessId = this.file.GetNextResultId(); this.file.AddFunctionStatement(accessId, Op.OpAccessChain, pointerTypeId, binding.Item1, this.Visit(Expression.Constant(binding.Item2))); ResultId resultId = this.file.GetNextResultId(); this.file.AddFunctionStatement(resultId, Op.OpLoad, typeId, accessId); return(resultId); } }
private IEnumerable <ResultId> ExpandNewArguments(IEnumerable <Expression> arguments) { foreach (var argument in arguments) { ResultId argumentId = this.Visit(argument); if (this.vectorLibrary.IsVectorType(argument.Type)) { ResultId typeId = this.Visit(Expression.Constant(this.vectorLibrary.GetVectorElementType(argument.Type))); for (int index = 0; index < this.vectorLibrary.GetVectorLength(argument.Type); index++) { ResultId fieldId = this.file.GetNextResultId(); this.file.AddFunctionStatement(fieldId, Op.OpCompositeExtract, typeId, argumentId, index); yield return(fieldId); } } else { yield return(argumentId); } } }
public CStatHubFixture(int slotMax) { for (int i = 0; i < slotMax; i++) { SerialNo.Add(""); ResultName.Add(""); ResultId.Add(0); Result.Add(0); } }
public async Task <ResultId> Execute(ScheduleDto schedule) { var message = string.Empty; //var result = new Result<ScheduleDto>(); var result = new ResultId(); try { if (schedule.Name == null || schedule.Telephone == null || schedule.Email == null || schedule.Birthday == null) { if (schedule.Name == null) { message = "Por favor preencha seu nome"; } else if (schedule.Telephone == null) { message = "Por favor preencha o seu telefone"; } else if (schedule.Email == null) { message = "Por favor preencha o seu Email"; } else if (schedule.Birthday == null) { message = "Por favor preencha a data do seu aniversário"; } return(result = new ResultId { Message = "Erro", Sucess = false }); } int id = await _scheduleRepository.AddSchedule(schedule); result = new ResultId { Message = id == 0 ? "Não foi possível cadastrar, por favor verifique!" : "Cadastrado com sucesso!", Sucess = id == 0 ? false : true, //Data = sch.Id == 0 ? null : schedule }; } catch (Exception ex) { return(result = new ResultId { Message = "Erro!", Sucess = false }); } return(result); }
private ResultId VisitUnary(UnaryExpression expression, Op unaryOp) { ResultId resultTypeId = this.Visit(Expression.Constant(expression.Type)); ResultId operand = this.Visit(expression.Operand); ResultId result = this.file.GetNextResultId(); this.file.AddFunctionStatement(result, unaryOp, resultTypeId, operand); return(result); }
private ResultId VisitBinary(BinaryExpression expression, Op binaryOp) { ResultId resultTypeId = this.Visit(Expression.Constant(expression.Type)); ResultId left = this.Visit(expression.Left); ResultId right = this.Visit(expression.Right); ResultId result = this.file.GetNextResultId(); this.file.AddFunctionStatement(result, binaryOp, resultTypeId, left, right); return(result); }
public void Populate(ResultId dto) { if (dto == null) { ContentResult.StatusCode = (int)(HttpStatusCode.BadRequest); ContentResult.Content = JsonSerializer.SerializeObject(dto); return; } ContentResult.StatusCode = (int)(HttpStatusCode.OK); ContentResult.Content = JsonSerializer.SerializeObject(dto); }
public override void ToStream(Stream output) { output.Write(TLUtils.SignatureToBytes(Signature)); Id.ToStream(output); ResultId.ToStream(output); Type.ToStream(output); ThumbUrl.ToStream(output); ContentType.ToStream(output); ContentUrl.ToStream(output); Url.ToStream(output); Attributes.ToStream(output); }
public override int GetHashCode() { var prime1 = 108301; var prime2 = 150151; unchecked { var hash = prime1; // random big prime number hash = (hash * prime2) ^ UserId.GetHashCode(); hash = (hash * prime2) ^ ResultId.GetHashCode(); return(hash); } }
public CStatTestFixture(int slotMax) { for (int i = 0; i < slotMax; i++) { SerialNo.Add(""); ResultName.Add(""); ResultId.Add(0); Result.Add(0); Value.Add(""); Volt.Add(0); Cur.Add(0); DD.Add(""); } }
public CStatHub(int idNo, string name, int flowId, string flowName, int slotMax) { this._idNo = idNo; this._name = name; this._slotMax = slotMax; this.FlowId = flowId; this.FlowName = flowName; for (int i = 0; i < slotMax; i++) { SnEnable.Add(true); SerialNo.Add(""); ResultName.Add(""); ResultId.Add(0); Result.Add(0); TranOK.Add(false); } }
protected void Report() { try { string InsQuery = "insert into tblResult values ('" + ResultId.ToString() + "','" + UserName + "','" + subject_name + "','" + DateTime.Today + "','" + TotQus + "','" + marks + "','" + Result + "')"; con.Open(); SqlCommand cmd2 = new SqlCommand(InsQuery, con); cmd2.ExecuteNonQuery(); //lblDB.Text = "Success"; //lblDB.Visible = true; } catch (Exception ex) { Response.Write("Try Again"); } finally { con.Close(); } }
private ResultId VisitNew(NewExpression expression) { SpirvStatement statement; if (this.vectorLibrary.IsVectorType(expression.Type)) { var operands = new[] { this.Visit(Expression.Constant(expression.Type)) } .Concat(this.ExpandNewArguments(expression.Arguments)); statement = new SpirvStatement(Op.OpCompositeConstruct, operands.Cast <object>().ToArray()); } else { throw new NotImplementedException("New expressions are only implemented for vector types."); } ResultId resultId = this.file.GetNextResultId(); this.file.AddFunctionStatement(resultId, statement); return(resultId); }
/// <summary> /// 授权登录处理 /// </summary> /// <param name="filterContext"></param> public void OnAuthorization(AuthorizationContext filterContext) { if (filterContext.IsChildAction) { return; } //如果有该属性就不需授权 if (filterContext.ActionDescriptor.GetCustomAttributes(typeof(UnAuthorize), false).Length > 0) { return; } //调用提供者验证是否授权 ResultId vret = AuthorizeVerifyProvider(); //判断访问是否授权 if (vret.Success) { filterContext.RouteData.Values.Add("USERID", vret.Id); return; } filterContext.Result = AuthorizeVerifyFailProvider((Result)vret); }
public override Task OnAuthorizationAsync(HttpActionContext actionContext, CancellationToken cancellationToken) { var request = actionContext.Request; //判断必须使用https访问接口 if (request.RequestUri.Scheme != Uri.UriSchemeHttps && IsUriSchemeHttps) { return(HandleUnauthorizedRequest(actionContext, new Result("Https is required", false, ResultTypes.NoRight))); } //判断是否需要授权判断 if (actionContext.ActionDescriptor.GetCustomAttributes <UnAuthorize>().Count > 0) { return(base.OnAuthorizationAsync(actionContext, cancellationToken)); } //获取token 判断用户是否授权 NameValueCollection list = request.RequestUri.ParseQueryString(); string token = list["token"]; if (string.IsNullOrEmpty(token)) { return(HandleUnauthorizedRequest(actionContext, new Result("Token is required", false, ResultTypes.ParaError))); } //调用提供者验证是否授权 ResultId vret = AuthorizeVerifyProvider(token); if (!vret.Success) { return(HandleUnauthorizedRequest(actionContext, vret)); } //把访问用户存储 actionContext.RequestContext.RouteData.Values.Add("USERID", vret.Id); actionContext.RequestContext.RouteData.Values.Add("TOKEN", token); return(base.OnAuthorizationAsync(actionContext, cancellationToken)); }
public IEnumerable <T> ExecuteCollection <T>(QueryModel queryModel) { var file = new SpirvFile(); file.AddHeaderStatement(Op.OpCapability, Capability.Shader); file.AddHeaderStatement(file.GetNextResultId(), Op.OpExtInstImport, "GLSL.std.450"); file.AddHeaderStatement(Op.OpMemoryModel, AddressingModel.Logical, MemoryModel.GLSL450); var expressionVisitor = new ShanqExpressionVisitor(file); ResultId voidId = expressionVisitor.Visit(Expression.Constant(typeof(void))); ResultId actionId = expressionVisitor.Visit(Expression.Constant(typeof(Action))); ResultId entryPointerFunctionId = file.GetNextResultId(); ResultId entryPointerLabelId = file.GetNextResultId(); file.AddFunctionStatement(entryPointerFunctionId, Op.OpFunction, voidId, FunctionControl.None, actionId); file.AddFunctionStatement(entryPointerLabelId, Op.OpLabel); var fieldMapping = new Dictionary <FieldInfo, ResultId>(); var bindingMapping = new Dictionary <FieldInfo, Tuple <ResultId, int> >(); var builtinList = new Dictionary <FieldInfo, Tuple <ResultId, ResultId, int> >(); bool hasBuiltInOutput = false; var resultType = typeof(T); foreach (var field in resultType.GetFields()) { if (field.GetCustomAttribute <LocationAttribute>() != null) { var pointerType = typeof(OutputPointer <>).MakeGenericType(field.FieldType); ResultId outputPointerId = expressionVisitor.Visit(Expression.Constant(pointerType)); ResultId outputVariableId = file.GetNextResultId(); file.AddGlobalStatement(outputVariableId, Op.OpVariable, outputPointerId, StorageClass.Output); fieldMapping.Add(field, outputVariableId); } hasBuiltInOutput |= field.GetCustomAttribute <BuiltInAttribute>() != null; } var fromClauses = new FromClauseBase[] { queryModel.MainFromClause } .Concat(queryModel.BodyClauses.OfType <AdditionalFromClause>()); var inputTypes = new List <Type>(); var bindingTypes = new List <Type>(); foreach (var clause in fromClauses) { var queryable = (IShanqQueryable)((ConstantExpression)clause.FromExpression).Value; switch (queryable.Origin) { case QueryableOrigin.Input: inputTypes.Add(clause.ItemType); break; case QueryableOrigin.Binding: bindingTypes.Add(clause.ItemType); break; } } foreach (var field in inputTypes.SelectMany(type => type.GetFields())) { if (field.GetCustomAttribute <LocationAttribute>() != null) { var pointerType = typeof(InputPointer <>).MakeGenericType(field.FieldType); ResultId inputPointerId = expressionVisitor.Visit(Expression.Constant(pointerType)); ResultId inputVariableId = file.GetNextResultId(); file.AddGlobalStatement(inputVariableId, Op.OpVariable, inputPointerId, StorageClass.Input); fieldMapping.Add(field, inputVariableId); expressionVisitor.AddInputMapping(field, inputVariableId); } } foreach (var type in bindingTypes) { ResultId structureTypeId = expressionVisitor.Visit(Expression.Constant(type)); var pointerType = typeof(InputPointer <>).MakeGenericType(type); ResultId uniformPointerId = expressionVisitor.Visit(Expression.Constant(pointerType)); ResultId uniformVariableId = file.GetNextResultId(); file.AddGlobalStatement(uniformVariableId, Op.OpVariable, uniformPointerId, StorageClass.Uniform); file.AddAnnotationStatement(Op.OpDecorate, structureTypeId, Decoration.Block); file.AddAnnotationStatement(Op.OpDecorate, uniformVariableId, Decoration.DescriptorSet, 0); file.AddAnnotationStatement(Op.OpDecorate, uniformVariableId, Decoration.Binding, 0); int fieldIndex = 0; foreach (var field in type.GetFields()) { expressionVisitor.AddBinding(field, Tuple.Create(uniformVariableId, fieldIndex)); if (ShanqExpressionVisitor.IsMatrixType(field.FieldType)) { //HACK Should adapt to different matrix formats file.AddAnnotationStatement(Op.OpMemberDecorate, structureTypeId, fieldIndex, Decoration.ColMajor); file.AddAnnotationStatement(Op.OpMemberDecorate, structureTypeId, fieldIndex, Decoration.Offset, Marshal.OffsetOf(type, field.Name).ToInt32()); file.AddAnnotationStatement(Op.OpMemberDecorate, structureTypeId, fieldIndex, Decoration.MatrixStride, 16); } fieldIndex++; } } var entryPointParameters = fieldMapping.Select(x => x.Value).Distinct().ToList(); if (hasBuiltInOutput) { var builtInFields = resultType.GetFields().Select(x => new { Field = x, BuiltIn = x.GetCustomAttribute <BuiltInAttribute>()?.BuiltIn }) .Where(x => x.BuiltIn != null); var structureType = GetTupleType(builtInFields.Count()).MakeGenericType(builtInFields.Select(x => x.Field.FieldType).ToArray()); ResultId structureTypeId = expressionVisitor.Visit(Expression.Constant(structureType));; var structurePointerType = typeof(OutputPointer <>).MakeGenericType(structureType); ResultId structurePointerId = expressionVisitor.Visit(Expression.Constant(structurePointerType)); ResultId outputVariableId = file.GetNextResultId(); file.AddGlobalStatement(outputVariableId, Op.OpVariable, structurePointerId, StorageClass.Output); file.AddAnnotationStatement(Op.OpDecorate, structureTypeId, Decoration.Block); foreach (var field in builtInFields.Select((x, y) => new { Index = y, Field = x.Field, Value = x.BuiltIn.Value })) { file.AddAnnotationStatement(Op.OpMemberDecorate, structureTypeId, field.Index, Decoration.BuiltIn, field.Value); builtinList.Add(field.Field, Tuple.Create(structurePointerId, outputVariableId, field.Index)); } entryPointParameters.Add(outputVariableId); } file.AddHeaderStatement(Op.OpEntryPoint, new object[] { this.model, entryPointerFunctionId, "main" }.Concat(entryPointParameters.Cast <object>()).ToArray()); if (this.model == ExecutionModel.Fragment) { file.AddHeaderStatement(Op.OpExecutionMode, entryPointerFunctionId, ExecutionMode.OriginUpperLeft); } foreach (var mapping in fieldMapping) { if (mapping.Key.GetCustomAttribute <LocationAttribute>() != null) { var attribute = mapping.Key.GetCustomAttribute <LocationAttribute>(); file.AddAnnotationStatement(Op.OpDecorate, mapping.Value, Decoration.Location, attribute.LocationIndex); } } var selector = queryModel.SelectClause.Selector; switch (selector.NodeType) { case ExpressionType.Constant: foreach (var field in resultType.GetFields()) { var fieldValue = field.GetValue(((ConstantExpression)queryModel.SelectClause.Selector).Value); ResultId valueId = expressionVisitor.Visit(Expression.Constant(fieldValue, field.FieldType)); file.AddFunctionStatement(Op.OpStore, fieldMapping[field], valueId); } break; case ExpressionType.MemberInit: var initExpression = (MemberInitExpression)selector; foreach (var binding in initExpression.Bindings) { var fieldValue = ((MemberAssignment)binding).Expression; ResultId valueId = expressionVisitor.Visit(fieldValue); var field = (FieldInfo)binding.Member; if (fieldMapping.ContainsKey(field)) { file.AddFunctionStatement(Op.OpStore, fieldMapping[field], valueId); } else if (builtinList.ContainsKey(field)) { ResultId constantIndex = expressionVisitor.Visit(Expression.Constant(builtinList[field].Item3)); ResultId fieldId = file.GetNextResultId(); var fieldPointerType = typeof(OutputPointer <>).MakeGenericType(field.FieldType); ResultId fieldPointerTypeId = expressionVisitor.Visit(Expression.Constant(fieldPointerType)); file.AddFunctionStatement(fieldId, Op.OpAccessChain, fieldPointerTypeId, builtinList[field].Item2, constantIndex); file.AddFunctionStatement(Op.OpStore, fieldId, valueId); } } break; default: throw new NotImplementedException(); } file.AddFunctionStatement(Op.OpReturn); file.AddFunctionStatement(Op.OpFunctionEnd); int bound = file.Entries.Select(x => x.ResultId) .Where(x => x.HasValue) .Max(x => x.Value.Id) + 1; var sink = new BinarySink(this.outputStream, bound); foreach (var entry in file.Entries) { sink.AddStatement(entry.ResultId, entry.Statement); } return(Enumerable.Empty <T>()); }
public void AddSampler(IFromClause clause, ResultId resultId) { this.samplerMappings.Add(clause, resultId); }
private ResultId VisitConstant(ConstantExpression expression) { SpirvStatement statement; if (this.vectorLibrary.IsVectorType(expression.Type)) { var operands = new object[] { expression.Type } .Concat(((IEnumerable)expression.Value).OfType <object>()) .Select(x => (object)this.Visit(Expression.Constant(x))); statement = new SpirvStatement(Op.OpConstantComposite, operands.ToArray()); } else if (typeof(Type).IsAssignableFrom(expression.Type)) { Type value = (Type)expression.Value; if (this.vectorLibrary.IsMatrixType(value)) { Type rowType = this.vectorLibrary.GetMatrixRowType(value); int[] dimensions = this.vectorLibrary.GetMatrixDimensions(value); ResultId rowTypeId = this.Visit(Expression.Constant(rowType)); statement = new SpirvStatement(Op.OpTypeMatrix, rowTypeId, dimensions[0]); } else if (this.vectorLibrary.IsVectorType(value)) { Type elementType = this.vectorLibrary.GetVectorElementType(value); int length = this.vectorLibrary.GetVectorLength(value); ResultId elementTypeId = this.Visit(Expression.Constant(elementType)); statement = new SpirvStatement(Op.OpTypeVector, elementTypeId, length); } else if (typeof(Delegate).IsAssignableFrom(value)) { var returnType = value.GetMethod("Invoke").ReturnType; ResultId returnTypeId = this.Visit(Expression.Constant(returnType)); if (value.GetMethod("Invoke").GetParameters().Length > 0) { throw new NotImplementedException(); } statement = new SpirvStatement(Op.OpTypeFunction, returnTypeId); } else if (value.BaseType.IsGenericType && value.BaseType.GetGenericTypeDefinition() == typeof(Pointer <>)) { StorageClass storage = (StorageClass)value.GetProperty("Storage").GetValue(null); ResultId typeId = this.Visit(Expression.Constant(value.GetGenericArguments()[0])); statement = new SpirvStatement(Op.OpTypePointer, storage, typeId); } else if (IsTupleType(value)) { var fieldTypes = value.GetGenericArguments(); var fieldTypeIds = fieldTypes.Select(x => (object)this.Visit(Expression.Constant(x))).ToArray(); statement = new SpirvStatement(Op.OpTypeStruct, fieldTypeIds); } else if (value == typeof(float)) { statement = new SpirvStatement(Op.OpTypeFloat, 32); } else if (value == typeof(int)) { statement = new SpirvStatement(Op.OpTypeInt, 32, 1); } else if (value == typeof(void)) { statement = new SpirvStatement(Op.OpTypeVoid); } else if (value.IsValueType) { var fieldTypeIds = value.GetFields().Select(x => (object)this.Visit(Expression.Constant(x.FieldType))).ToArray(); statement = new SpirvStatement(Op.OpTypeStruct, fieldTypeIds); } else { throw new NotImplementedException($"Constants of type {value} are not implemented."); } } else { ResultId typeOperand = this.Visit(Expression.Constant(expression.Type)); statement = new SpirvStatement(Op.OpConstant, typeOperand, expression.Value); } ResultId resultId; if (!this.expressionResults.TryGetValue(statement, out resultId)) { resultId = this.file.GetNextResultId(); this.expressionResults.Add(statement, resultId); this.file.AddGlobalStatement(resultId, statement); } return(resultId); }
/// <summary> /// Output an SPIR-V statement with the specified opcode, ResultID and operands /// arguments. /// </summary> /// <param name="sink"> /// The sink to which to output the statement. /// </param> /// <param name="resultId"> /// A ResultId representing the result of this statement. /// </param> /// <param name="op"> /// The opcode of the statement to output. /// </param> /// <param name="operands"> /// A list of operand arguments to include in the output statement. /// </param> public static void AddStatement(this ISpirvSink sink, ResultId resultId, Op op, params object[] operands) { sink.AddStatement(resultId, new SpirvStatement(op, operands)); }
public void AddInputMapping(FieldInfo field, ResultId resultId) { this.inputMappings.Add(field, resultId); }