public UserBLL() { Type t = typeof(Cb.SQLServerDAL.Generic <PNK_User>); dal_2C = DataAccessGeneric <PNK_User> .CreateSession(t.FullName); switch (ConfigurationManager.AppSettings["Database"]) { case "SQLServer": prefixParam = "@"; break; case "MySQL": prefixParam = "v_"; break; } }
/// <summary> /// Returns a string containing the type parameter definitions. /// </summary> /// <param name="generic">An instance of <see cref="IGeneric"/> to take the generic parameters from.</param> /// <returns>A string containing the type parameter definitions.</returns> private static string GetGenericDefinition(IGeneric generic) { if (!generic.IsGeneric) { return(""); } IEnumerable <NRTypeParameter> nrTypeParameters = generic.GenericTypes; StringBuilder result = new StringBuilder("<"); foreach (NRTypeParameter nrTypeParameter in nrTypeParameters) { result.AppendFormat("{0}, ", nrTypeParameter.Name); } result.Length -= 2; result.Append(">"); return(result.ToString()); }
public static void AssertReadAndWrite <T>( IGeneric <T> value, T expected, int expectedLength, Action <ValuePair <T> > assertion = null) { var actualType = value .GetType(); if (typeof(T).IsArray) { expectedLength *= Marshal.SizeOf(typeof(T).GetMethod("Get").ReturnType); } var actual = (IGeneric <T>)Activator.CreateInstance(actualType); var memory = new MemoryStream(); var reader = new BinaryReader(memory); var writer = new BinaryWriter(memory); BinaryMapping.WriteObject(writer, value); Assert.Equal(expectedLength, memory.Length); memory.Position = 0; BinaryMapping.ReadObject(reader, actual); Assert.Equal(expectedLength, memory.Position); if (assertion != null) { assertion.Invoke(new ValuePair <T> { Expected = expected, Actual = actual.Value }); } else { Assert.Equal(expected, actual.Value); } }
/// <summary> /// Gets the C# generic from the source generic. /// </summary> /// <param name="sourceGeneric">The source generic.</param> public ICSharpGeneric GetGeneric(IGeneric sourceGeneric) { ICSharpGeneric Result = null; foreach (KeyValuePair <IClass, ICSharpClass> Entry in ClassTable) { foreach (ICSharpGeneric Generic in Entry.Value.GenericList) { if (Generic.Source == sourceGeneric) { Debug.Assert(Result == null); Result = Generic; } } } Debug.Assert(Result != null); return(Result); }
/// <summary> /// Returns a string containing the generic contraints if any. /// </summary> /// <param name="generic">An instance of <see cref="IGeneric" /> to take the generic constraints from.</param> /// <returns>A string containing the generic contraints.</returns> private static string GetGenericConstraint(IGeneric generic) { if (!generic.IsGeneric) { return(""); } IEnumerable <NRTypeParameter> nrTypeParameters = generic.GenericTypes; StringBuilder result = new StringBuilder( ); foreach (NRTypeParameter nrTypeParameter in nrTypeParameters) { if ((nrTypeParameter.BaseTypes.Count == 0) && !nrTypeParameter.IsClass && !nrTypeParameter.IsConstructor && !nrTypeParameter.IsStruct) { continue; } result.AppendFormat(" where {0} : ", nrTypeParameter.Name); if (nrTypeParameter.IsClass) { result.Append("class, "); } if (nrTypeParameter.IsStruct) { result.Append("struct, "); } foreach (NRTypeUsage baseType in nrTypeParameter.BaseTypes) { result.AppendFormat("{0}, ", baseType.Declaration( )); } if (nrTypeParameter.IsConstructor) { result.Append("new(), "); } result.Length -= 2; } return(result.ToString( )); }
/// <summary> /// Checks for errors before applying a rule. /// </summary> /// <param name="node">The node instance to check.</param> /// <param name="dataList">Optional data collected during inspection of sources.</param> /// <param name="data">Private data to give to Apply() upon return.</param> /// <returns>True if an error occured.</returns> public override bool CheckConsistency(IConstraint node, IDictionary <ISourceTemplate, object> dataList, out object data) { bool Success = true; data = null; IGeneric InnerGeneric = (IGeneric)node.ParentSource; Debug.Assert(node.ResolvedParentType.IsAssigned); ICompiledType ResolvedType = node.ResolvedParentType.Item; foreach (KeyValuePair <ITypeName, ICompiledType> Entry in InnerGeneric.ResolvedConformanceTable) { ICompiledType OtherConformingType = Entry.Value; if (ObjectType.TypesHaveIdenticalSignature(ResolvedType, OtherConformingType)) { AddSourceError(new ErrorTypeAlreadyUsedAsConstraint((IObjectType)node.ParentType)); Success = false; } } return(Success); }
public GenericWrapper( IGeneric <string> generic) { Generic = generic; }
public AppRoleManager(IGeneric <AppRole> generic) : base(generic) { _generic = generic; }
public EditorasController() { EditoraRepository = new EditoraRepository(); }
public ClassWithGeneric(IGeneric<int> generic) { this.Generic = generic; }
private void ParsePossibleTypeParameterConstraintNode(IGeneric node) { // if the current token is "where", the source code is starting // a type parameter constraint while (curtok.ID == TokenID.Ident && strings[curtok.Data] == "where") { Advance(); // advance over Where token ParseTypeParameterConstraintNode(node); } }
public CategoryService(IGeneric <Category> repository) { this.repository = repository; }
public GenericServiceWithGenericConstructor(IGeneric <T> arg) { }
public ProductManager(IGeneric <Product> generic, IProduct product) : base(generic) { _product = product; }
public LoanService(IGeneric <Loan> genericRepository, ILoan loan) : base(genericRepository) { _genericRepository = genericRepository; _loan = loan; }
public Size(IGeneric <uint> generic) => _generic = generic;
private void ParsePossibleTypeParameterConstraintNode(IGeneric node) { // if the current token is "where", the source code is starting // a type parameter constraint if (curtok.ID == TokenID.Where) { Advance(); // advance over Where token //parse it at least one time out of the next while loop // to be sure that at least one type parameter constraint is defined //( for example -> "where " is invalid ParseTypeParameterConstraintNode(node); while (curtok.ID == TokenID.Where && curtok.ID != TokenID.Eof) { Advance(); //over the TokenID.Where ParseTypeParameterConstraintNode(node); } } }
private void ParseTypeParameterConstraintNode(IGeneric genericType) { if (curmods != Modifier.Empty) ReportError("Type parameter constraint can not contain modifiers"); ParseTypeParameterNode(false, true, false); Constraint node = new Constraint(curTypeParameters[0]); curTypeParameters = new List<TypeParameterNode>(); AssertAndAdvance(TokenID.Colon); //parse the first constraint ParseConstraintNode(node); while( curtok.ID == TokenID.Comma && curtok.ID != TokenID.Eof ) { Advance(); ParseConstraintNode(node); } if (!node.TypeParameter.IsEmpty) { if (!genericType.Generic.TypeParameters.Contains(node.TypeParameter)) { ReportError("unknow type parameter : " + node.TypeParameter.UniqueIdentifier); } } string key = node.TypeParameter.Identifier.Identifier; if (curTypeParameterConstraints.ContainsKey(key)) { ReportError("duplicated constraint for the type parameter '" + key + "'."); } curTypeParameterConstraints.Add(key, node); }
public UseGenericExtended2(IGenericExtended<string> genericExtended, IGeneric<string> generic) { this.genericExtended = genericExtended; this.generic = generic; }
public DefaultValueTypeDefaults(IGeneric <ISource <object> > generic) => _generic = generic;
private void ApplyTypeParameterConstraints(IGeneric node) { if (curTypeParameterConstraints.Count > 0) { if (node.IsGeneric) { node.Generic.Constraints.AddRange( curTypeParameterConstraints.Values ); curTypeParameterConstraints = new Dictionary<string, Constraint>(); } else { ReportError("Type parameter constraint applies only on generic type or generic method"); } } }
public InvoiceService(IGeneric <Invoice> genericRepository) : base(genericRepository) { _genericRepository = genericRepository; }
public IGeneric <int>?TargetWithComplexGeneric(IGeneric <int> a) => null;
public UlogeController(IGeneric <Uloge, object> service) : base(service) { }
public ClassWithGeneric(IGeneric <int> generic) { this.Generic = generic; }
public GenericService(IMapper mapper, IGeneric repo, IErrorlogService errorlogService) { this._mapper = mapper; this._repo = repo; this._errorlogService = errorlogService; }
public UseGenericExtended1(IGeneric<string> generic, IGenericExtended<string> genericExtended) { this.generic = generic; this.genericExtended = genericExtended; }
public GenericManager(IGeneric <TEntity> generic) { _generic = generic; }
public XMLConfigBLL() { Type t = typeof(Cb.SQLServerDAL.Generic <sd_XML>); generic = DataAccessGeneric <sd_XML> .CreateSession(t.FullName); }
public Element(IIdentities identities, IGeneric <IIdentity, IWriter> adapter) { _identities = identities; _adapter = adapter; }
public EngEstService(IGeneric <TranslationEngEst> repository) { this.repository = repository; }
public Service1(IGeneric generic) { _generic = generic; }
public Task Handle(IGeneric <Parent> message) => Task.CompletedTask;
public GenerosController() { GeneroRepository = new GeneroRepository(); }
public GenericFactory(IGeneric<int> intG, IGeneric<string> stringG) { intGeneric = intG; stringG = stringG; }
public FacultyController(IGeneric <Faculty> genericRepository) { _faculty = genericRepository; }
public ProizvodController(ICRUD <Proizvod, ProizvodSearchRequest, ProizvodUpsertRequest, ProizvodUpsertRequest> service, IGeneric <Proizvod, ProizvodSearchRequest> _base) : base(service, _base) { }
private void ApplyTypeParameters(IGeneric node) { if (curTypeParameters.Count > 0) { if (node.Generic == null) { node.Generic = new GenericNode(curtok); genericList.Add(node); } node.Generic.TypeParameters.AddRange( curTypeParameters ); curTypeParameters = new List<TypeParameterNode>(); } }