// No argument CTOR. By deafult Parser's ctor requires scanner as param.
        public Parser(Scanner scn, StatementFactory codegen) : base(scn)
        {
            this.codegen = codegen; program = codegen.NewList(); currentStatement = new Stack <IStatement>();
        }
 internal CqlUpdate(Expression expression, ITable table, StatementFactory stmtFactory, PocoData pocoData, MapperFactory mapperFactory)
     : base(expression, table, stmtFactory, pocoData)
 {
     _mapperFactory = mapperFactory;
 }
Example #3
0
 internal CqlQueryBase(Expression expression, ITable table, MapperFactory mapperFactory, StatementFactory stmtFactory, PocoData pocoData)
 {
     InternalInitialize(expression, table, mapperFactory, stmtFactory, pocoData);
 }
Example #4
0
 public virtual Task <int?> InsertGetIdAsync(T obj) =>
 GeneratedNonQueryGetIdAsync(StatementFactory.Insert <T>().Build(obj));
Example #5
0
 internal CqlQuery(Expression expression, ITable table, MapperFactory mapperFactory, StatementFactory stmtFactory, PocoData pocoData)
     : base(expression, table, mapperFactory, stmtFactory, pocoData)
 {
 }
Example #6
0
 private protected override SelectStatementBuilder <RaceData> DefaultSelectQuery() =>
 StatementFactory.Select <RaceData>().Join <RaceData, EventType>((nameof(RaceData.EventTypeId), nameof(EventType.Id)));
Example #7
0
 private protected override SelectStatementBuilder <SkierEvent> DefaultSelectQuery() =>
 StatementFactory.Select <SkierEvent>()
 .Join <SkierEvent, RaceData>((nameof(SkierEvent.RaceDataId), nameof(RaceData.Id)))
Example #8
0
 public DriveParser(ResourceFactory resourceFactory, StatementFactory statementFactory)
 {
     itsResourceFactory  = resourceFactory;
     itsStatementFactory = statementFactory;
     itsDereferencer     = new SimpleDereferencer();
 }
Example #9
0
 /// <summary>
 /// Assign the factory the parser must use to create statements from resources
 /// </summary>
 public void SetStatementFactory(StatementFactory statementFactory)
 {
     itsStatementFactory = statementFactory;
 }
Example #10
0
 private protected virtual SelectStatementBuilder <T> DefaultSelectQuery() => StatementFactory.Select <T>();
Example #11
0
 public GenderDao( IConnectionFactory connectionFactory, StatementFactory statementFactory) : base(
     connectionFactory,"hurace.Gender", statementFactory)
 {
 }
Example #12
0
 protected ReadonlyDao(IConnectionFactory connectionFactory, string tableName,
                       StatementFactory statementFactory) : base(connectionFactory, tableName, statementFactory)
 {
 }
Example #13
0
 public bool WasMakeParserCalledWith(ResourceFactory resourceFactory, StatementFactory statementFactory)
 {
     return(itsMethodCalls.WasMethodCalledWith("MakeParser", resourceFactory, statementFactory));
 }
Example #14
0
 public Parser MakeParser(ResourceFactory resourceFactory, StatementFactory statementFactory)
 {
     itsMethodCalls.RecordMethodCall("MakeParser", resourceFactory, statementFactory);
     return(new ParserStub());
 }
Example #15
0
 internal CqlScalar(Expression expression, ITable table, StatementFactory stmtFactory, PocoData pocoData)
     : base(expression, table, null, stmtFactory, pocoData)
 {
 }
Example #16
0
 public SensorDao(IConnectionFactory connectionFactory, StatementFactory statementFactory) : base(
         connectionFactory, "hurace.sensor", statementFactory)
 {
 }
Example #17
0
 public RaceDataDao(IConnectionFactory connectionFactory, StatementFactory statementFactory) : base(
         connectionFactory, "hurace.RaceData", statementFactory)
 {
 }
Example #18
0
 public override async Task <bool> InsertAsync(TimeData obj) =>
 await GeneratedNonQueryAsync(StatementFactory.Insert <TimeData>().WithKey().Build(obj));
Example #19
0
 public SkierEventDao(IConnectionFactory connectionFactory, StatementFactory statementFactory) : base(
         connectionFactory, "hurace.SkierEvent", statementFactory)
 {
 }
Example #20
0
 /// <summary>
 /// Clears all the mapping defined for this instance
 /// </summary>
 internal void Clear()
 {
     _typeDefinitions = new LookupKeyedCollection<Type, ITypeDefinition>(td => td.PocoType);
     MapperFactory = new MapperFactory(_typeConverter, new PocoDataFactory(_typeDefinitions));
     StatementFactory = new StatementFactory();
 }
Example #21
0
 protected DefaultCrudDao(IConnectionFactory connectionFactory, string tableName,
                          StatementFactory statementFactory)
     : base(connectionFactory, tableName, statementFactory)
 {
 }
Example #22
0
 public Parser MakeParser(ResourceFactory resourceFactory, StatementFactory statementFactory)
 {
     return(new ParserStub());
 }
Example #23
0
 internal CqlDelete(Expression expression, ITable table, StatementFactory stmtFactory, PocoData pocoData)
     : base(expression, table, stmtFactory, pocoData)
 {
 }
Example #24
0
 protected BaseDao(IConnectionFactory connectionFactory, string tableName, StatementFactory statementFactory)
 {
     StatementFactory  = statementFactory;
     TableName         = tableName;
     ConnectionFactory = connectionFactory;
 }
Example #25
0
        private static async Task GenerateEditableWrappers()
        {
            string baseDirectory = Path.GetFullPath(
                Path.Combine(Path.GetDirectoryName(typeof(Program).Assembly.Location), @"..\..\..\.."));
            ProjectWithCodeAnalysis project = await ProjectWithCodeAnalysis.OpenAsync(
                Path.Combine(baseDirectory, @"CSharpDom\CSharpDom.csproj"));

            project.Lock();
            foreach (DocumentWithCodeAnalysis document in project.Documents.OrderBy(document => document.FullFilePath))
            {
                document.IsLocked = true;
                string filePath = document.FullFilePath;
                if (!filePath.Contains(@"CSharpDom\BaseClasses\Wrappers"))
                {
                    continue;
                }

                string newDirectory = Path.GetDirectoryName(filePath)
                                      .Replace(@"CSharpDom\BaseClasses\Wrappers", @"CSharpDom\BaseClasses\Editable\Wrappers");
                string destinationPath = Path.Combine(newDirectory, GetNewName(Path.GetFileName(filePath)));
                if (File.Exists(destinationPath))
                {
                    continue;
                }

                LoadedDocumentWithCodeAnalysis loadedDocument = await document.LoadAsync();

                NamespaceWithCodeAnalysis @namespace = loadedDocument.Namespaces.First();
                Console.WriteLine($"Writing: {Path.GetFileName(destinationPath)}");
                string namespaceName = @namespace.Name;
                using (CodeAnalysisSettings.AllowEdits(loadedDocument))
                {
                    foreach (UsingDirectiveWithCodeAnalysis directive in loadedDocument.UsingDirectives)
                    {
                        directive.Name = directive.Name.Replace("CSharpDom.Common", "CSharpDom.Common.Editable");
                    }

                    loadedDocument.UsingDirectives.Add(new UsingDirectiveWithCodeAnalysis("CSharpDom.Common"));
                    loadedDocument.UsingDirectives = loadedDocument.UsingDirectives
                                                     .OrderBy(directive => directive.Name)
                                                     .ToArray();
                    @namespace.Name = "CSharpDom.BaseClasses.Editable.Wrappers";
                    SealedClassWithCodeAnalysis @class = @namespace.Classes.SealedClasses.First();
                    @class.Name           = "Editable" + @class.Name;
                    @class.BaseClass.Name = Regex.Replace(@class.BaseClass.Name, "^Abstract", "Editable");
                    ITypeReferenceWithCodeAnalysis interfaceReference =
                        @class.ImplementedInterfaces.First().GenericParameters[0];
                    interfaceReference.Name = Regex.Replace(interfaceReference.Name, "^I", "IEditable");
                    foreach (GenericParameterDeclarationWithCodeAnalysis genericParameter in @class.GenericParameters)
                    {
                        InterfaceReferenceWithCodeAnalysis constraint = genericParameter.InterfaceConstraints.First();
                        constraint.Name = Regex.Replace(constraint.Name, "^I", "IEditable");
                    }

                    ITypeReferenceWithCodeAnalysis constructorParameterType =
                        @class.Constructors.First().Parameters[0].ParameterType;
                    constructorParameterType.Name = Regex.Replace(constructorParameterType.Name, "^I", "IEditable");
                    foreach (SealedClassAutoPropertyWithCodeAnalysis property in @class.Properties.AutoProperties)
                    {
                        if (property.Name == "WrappedObject")
                        {
                            //CodeAnalysisLogger.StartLoggingDebugMessages();
                            property.PropertyType.Name = Regex.Replace(property.PropertyType.Name, "^I", "IEditable");
                            //string[] logMessages = CodeAnalysisLogger.GetDebugLogMessages();
                            //CodeAnalysisLogger.StopLoggingDebugMessages();
                            break;
                        }
                    }

                    foreach (SealedClassPropertyWithCodeAnalysis property in @class.Properties)
                    {
                        string propertyName = property.Name;
                        if (propertyName == "WrappedObject")
                        {
                            continue;
                        }

                        string propertyTypeName = property.PropertyType.Name;
                        if (propertyTypeName.Contains("ReadOnly"))
                        {
                            property.PropertyType.Name = propertyTypeName.Replace("ReadOnly", string.Empty);
                        }

                        IExpressionWithCodeAnalysis expression = ExpressionFactory.Binary(
                            ExpressionFactory.Member(ExpressionFactory.Identifier("WrappedObject"), propertyName),
                            BinaryOperatorExpressionType.Assign,
                            ExpressionFactory.Identifier("value"));
                        property.SetAccessor = new ClassAccessorWithCodeAnalysis(
                            AccessorType.Set,
                            new MethodBodyWithCodeAnalysis(StatementFactory.Expression(expression)));
                    }

                    Directory.CreateDirectory(Path.GetDirectoryName(destinationPath));
                    const int maximumLineLength = 120;
                    string    sourceCode        = loadedDocument.ToSourceCode(
                        new IndentBaseTypeListIfTooLongRule(maximumLineLength),
                        new IndentGenericParamterDefinitionsIfTooLongRule(maximumLineLength),
                        new IndentMethodParametersIfTooLongRule(maximumLineLength));
                    File.WriteAllText(destinationPath, sourceCode);
                }
            }
        }
Example #26
0
 public SeasonDao(IConnectionFactory connectionFactory, StatementFactory statementFactory) : base(
         connectionFactory, "hurace.season", statementFactory)
 {
 }
Example #27
0
 public DisciplineDao(IConnectionFactory connectionFactory, StatementFactory statementFactory) : base(
         connectionFactory, "hurace.discipline", statementFactory)
 {
 }
Example #28
0
 /// <summary>
 /// 获取实体集合
 /// </summary>
 /// <returns></returns>
 public override List <TEntity> GetAllList()
 {
     return(_dbContext.connection.Query <TEntity>(StatementFactory.Select <TEntity>(Dialect.MSSQL)).ToList());
 }
Example #29
0
 internal void InternalInitialize(Expression expression, ITable table, MapperFactory mapperFactory, StatementFactory stmtFactory, PocoData pocoData)
 {
     Expression       = expression;
     Table            = table;
     MapperFactory    = mapperFactory;
     StatementFactory = stmtFactory;
     PocoData         = pocoData;
 }
Example #30
0
 public LocationDao(IConnectionFactory connectionFactory, StatementFactory statementFactory) :
     base(connectionFactory, "hurace.location", statementFactory)
 {
 }