当前位置: 首页>>代码示例>>C#>>正文


C# GenerationContext类代码示例

本文整理汇总了C#中GenerationContext的典型用法代码示例。如果您正苦于以下问题:C# GenerationContext类的具体用法?C# GenerationContext怎么用?C# GenerationContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GenerationContext类属于命名空间,在下文中一共展示了GenerationContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Enact

 public void Enact(IGenerationContext context, object target)
 {
     var propertyContext = new GenerationContext(context.Builders, new TypePropertyGenerationContextNode(
                                                                       (TypeGenerationContextNode) context.Node,
                                                                       mMember));
     mMember.PropertyInfo.SetValue(target, mDatasource.Next(propertyContext), null);
 }
开发者ID:lamiomni,项目名称:questionyourfriends,代码行数:7,代码来源:ObjectPropertySetFromSourceAction.cs

示例2: Enact

 public void Enact(IGenerationContext context, object target)
 {
     var fieldContext = new GenerationContext(context.Builders, new TypeFieldGenerationContextNode(
                                                                    (TypeGenerationContextNode) context.Node,
                                                                    _member));
     _member.FieldInfo.SetValue(target, _datasource.Next(fieldContext));
 }
开发者ID:lamiomni,项目名称:questionyourfriends,代码行数:7,代码来源:ObjectFieldSetFromSourceAction.cs

示例3: WriteClassHeader

        public override void WriteClassHeader(CodeWriter writer, DbLinq.Schema.Dbml.Table table, GenerationContext context)
        {
            using (writer.WriteRegion(string.Format("{0} handling", typeof(INotifyPropertyChanging).Name)))
            {
                const string eventName = "PropertyChanging"; // do not change, part of INotifyPropertyChanging
                const string emptyArgs = "emptyChangingEventArgs";

                // event
                writer.WriteEvent(SpecificationDefinition.Public, eventName, typeof(PropertyChangingEventHandler).Name);
                writer.WriteLine();
                // empty event arg
                writer.WriteField(SpecificationDefinition.Private | SpecificationDefinition.Static,
                                  writer.GetAssignmentExpression(emptyArgs, writer.GetNewExpression(
                                                                                writer.GetMethodCallExpression(typeof(PropertyChangingEventArgs).Name, "\"\""))),
                                  typeof(PropertyChangingEventArgs).Name);
                // method
                using (writer.WriteMethod(SpecificationDefinition.Protected | SpecificationDefinition.Virtual,
                                          sendPropertyChangingMethod, null))
                {
                    using (writer.WriteIf(writer.GetDifferentExpression(eventName, writer.GetNullExpression())))
                    {
                        writer.WriteLine(writer.GetStatement(writer.GetMethodCallExpression(eventName,
                                                                                            writer.GetThisExpression(), emptyArgs)));
                    }
                }
            }
        }
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:27,代码来源:INotifyPropertyChangingImplementation.cs

示例4: WriteDataContextProcedure

        private void WriteDataContextProcedure(CodeWriter writer, Function procedure, GenerationContext context)
        {
            if (procedure == null || procedure.Name == null)
            {
                //Logger.Write(Level.Error, "CodeGenStoredProc: Error L33 Invalid storedProcedure object");
                writer.WriteCommentLine("error L33 Invalid storedProcedure object");
                return;
            }

            var functionAttribute = NewAttributeDefinition<FunctionAttribute>();
            functionAttribute["Name"] = procedure.Name;
            functionAttribute["IsComposable"] = procedure.IsComposable;

            SpecificationDefinition specifications;
            if (procedure.AccessModifierSpecified)
                specifications = GetSpecificationDefinition(procedure.AccessModifier);
            else
                specifications = SpecificationDefinition.Public;
            if (procedure.ModifierSpecified)
                specifications |= GetSpecificationDefinition(procedure.Modifier);

            using (writer.WriteAttribute(functionAttribute))
            using (writer.WriteMethod(specifications, GetProcedureName(procedure),
                                      GetProcedureType(procedure), GetProcedureParameters(procedure)))
            {
                string result = WriteProcedureBodyMethodCall(writer, procedure, context);
                WriteProcedureBodyOutParameters(writer, procedure, result, context);
                WriteProcedureBodyReturnValue(writer, procedure, result, context);
            }
            writer.WriteLine();
        }
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:31,代码来源:CodeGenerator.Procedure.cs

示例5: CreateCategory

 private List<UserCategorySettings<ObjectId>> CreateCategory(
     GenerationContext<UserDeliveryTypeSettings<ObjectId>> context)
 {
     ObjectId userID = context.ForeignEntity.UserID;
     var category = SignaloBotEntityCreator<ObjectId>.CreateUserCategorySettings(userID, 1);
     return new List<UserCategorySettings<ObjectId>>() { category };
 }
开发者ID:RodionKulin,项目名称:SignaloBot,代码行数:7,代码来源:MongoDbLoadTestDataModule.cs

示例6: WriteDataContextCtors

 protected virtual void WriteDataContextCtors(CodeWriter writer, Database schema, Type contextBaseType, GenerationContext context)
 {
     // ctor taking a connections tring
     WriteDataContextCtor(writer, schema, contextBaseType,
            new[] { new ParameterDefinition { Name = "connectionString", Type = typeof(string) } },
            new[] { "connectionString" },
            new[] { typeof(string) },
            context);
     // the two constructors below have the same prototype, so they are mutually exclusive
     // the base class requires a IVendor
     if (!WriteDataContextCtor(writer, schema, contextBaseType,
                          new[] { new ParameterDefinition { Name = "connection", Type = typeof(IDbConnection) } },
                          new[] { "connection", writer.GetNewExpression(writer.GetMethodCallExpression(writer.GetLiteralFullType(context.SchemaLoader.Vendor.GetType()))) },
                          new[] { typeof(IDbConnection), typeof(IVendor) },
                          context))
     {
         // OR the base class requires no IVendor
         WriteDataContextCtor(writer, schema, contextBaseType,
                              new[] { new ParameterDefinition { Name = "connection", Type = typeof(IDbConnection) } },
                              new[] { "connection" },
                              new[] { typeof(IDbConnection) },
                              context);
     }
     // ctor(string, MappingSource)
     WriteDataContextCtor(writer, schema, contextBaseType,
            new[] {
                new ParameterDefinition { Name = "connection", Type = typeof(string) },
                new ParameterDefinition { Name = "mappingSource", Type = typeof(MappingSource) },
            },
            new[] { "connection", "mappingSource" },
            new[] { typeof(string), typeof (MappingSource) },
            context);
     // ctor(IDbConnection, MappingSource)
     WriteDataContextCtor(writer, schema, contextBaseType,
             new[] {
                 new ParameterDefinition { Name = "connection", Type = typeof(IDbConnection) },
                 new ParameterDefinition { Name = "mappingSource", Type = typeof(MappingSource) },
             },
             new[] { "connection", "mappingSource" },
             new[] { typeof(IDbConnection), typeof(MappingSource) },
             context);
     // just in case you'd like to specify another vendor than the one who helped generating this file
     WriteDataContextCtor(writer, schema, contextBaseType,
             new[] {
                 new ParameterDefinition { Name = "connection", Type = typeof(IDbConnection) },
                 new ParameterDefinition { Name = "vendor", Type = typeof(IVendor) },
             },
             new[] { "connection", "vendor" },
             new[] { typeof(IDbConnection), typeof(IVendor) },
             context);
     WriteDataContextCtor(writer, schema, contextBaseType,
             new[] {
                 new ParameterDefinition { Name = "connection", Type = typeof(IDbConnection) },
                 new ParameterDefinition { Name = "mappingSource", Type = typeof(MappingSource) },
                 new ParameterDefinition { Name = "vendor", Type = typeof(IVendor) },
             },
             new[] { "connection", "mappingSource", "vendor" },
             new[] { typeof(IDbConnection), typeof(MappingSource), typeof(IVendor) },
             context);
 }
开发者ID:nlhepler,项目名称:mono,代码行数:60,代码来源:CodeGenerator.Context.Ctor.cs

示例7: WriteDataContextProcedures

 protected virtual void WriteDataContextProcedures(CodeWriter writer, DbLinq.Schema.Dbml.Database schema, GenerationContext context)
 {
     foreach (var procedure in schema.Functions)
     {
         WriteDataContextProcedure(writer, procedure, context);
     }
 }
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:7,代码来源:CodeGenerator.Procedure.cs

示例8: WriteClass

        protected virtual void WriteClass(CodeWriter writer, Table table, Database schema, GenerationContext context)
        {
            writer.WriteLine();

            string entityBase = context.Parameters.EntityBase;
            if (string.IsNullOrEmpty(entityBase))
                entityBase = schema.EntityBase;

            var specifications = SpecificationDefinition.Partial;
            if (table.Type.AccessModifierSpecified)
                specifications |= GetSpecificationDefinition(table.Type.AccessModifier);
            else
                specifications |= SpecificationDefinition.Public;
            if (table.Type.ModifierSpecified)
                specifications |= GetSpecificationDefinition(table.Type.Modifier);

            var tableAttribute = NewAttributeDefinition<TableAttribute>();
            tableAttribute["Name"] = table.Name;
            using (writer.WriteAttribute(tableAttribute))
            using (writer.WriteClass(specifications,
                                     table.Type.Name, entityBase, context.Parameters.EntityInterfaces))
            {
                WriteClassHeader(writer, table, context);
                WriteCustomTypes(writer, table, schema, context);
                WriteClassExtensibilityDeclarations(writer, table, context);
                WriteClassProperties(writer, table, context);
                if (context.Parameters.GenerateEqualsHash)
                    WriteClassEqualsAndHash(writer, table, context);
                WriteClassChildren(writer, table, schema, context);
                WriteClassParents(writer, table, schema, context);
                WriteClassChildrenAttachment(writer, table, schema, context);
                WriteClassCtor(writer, table, schema, context);
            }
        }
开发者ID:Bewolf2,项目名称:GenesisMono,代码行数:34,代码来源:CodeGenerator.Class.cs

示例9: TestSetup

 public void TestSetup()
 {
     IEngineConfiguration configuration = new EngineConfiguration();
     IEngineConventionProvider conventionProvider = new Mock<IEngineConventionProvider>().Object;
     GenerationConfiguration repository = new GenerationConfiguration(configuration, conventionProvider, 10);
     configuration.RegisterType(typeof(SimpleUser));
     mGenerationSession = new GenerationContext(repository);
 }
开发者ID:KCL5South,项目名称:KCLAutoPoco,代码行数:8,代码来源:GenerationContextTests.cs

示例10: SetupObjects

 public void SetupObjects()
 {
     mSourceMock = new Mock<IDatasource>();
     mParentNode = new TypeGenerationContextNode(null, null);
     mContext = new GenerationContext(null, mParentNode);
     mAction = new ObjectPropertySetFromSourceAction((EngineTypePropertyMember)
        ReflectionHelper.GetMember<SimplePropertyClass>(x => x.SomeProperty), mSourceMock.Object);
 }
开发者ID:hvitorino,项目名称:AutoPoco,代码行数:8,代码来源:ObjectPropertySetFromSourceActionTests.cs

示例11: Generate

        public object Generate(GenerationContext context)
        {
            var user = context.RootAs<User>();
            var timeDiference = DateTime.Now - user.Dob;
            var age = timeDiference.Days / 365;

            return user.Sex == Sex.Male
                       ? GetMinAgeForMaleAged(age)
                       : GetMinAgeForFemaleAged(age);
        }
开发者ID:chrisjowen,项目名称:FillMe,代码行数:10,代码来源:MaxAgeGenerator.cs

示例12: GetNeeds

 public IEnumerable<INeed> GetNeeds(IGenerationContext context)
 {
     if (_myNeed.Key==null)
     {
         var buildContext = context.BuildContext;
         var genCtx = new GenerationContext(context.Container, _nestedRegistration, buildContext, _type.GetMethod("Invoke").GetParameters());
         _myNeed.Key = genCtx.GenerateFunc(_type);
     }
     yield return _myNeed;
 }
开发者ID:Xamarui,项目名称:BTDB,代码行数:10,代码来源:DelegateImpl.cs

示例13: SetupObjects

        public void SetupObjects()
        {
            mSourceMock = new Mock<IDatasource>();
            mParentNode = new TypeGenerationContextNode(null, null);
            mContext = new GenerationContext(null, mParentNode);

            mDoubleArgMethod = (EngineTypeMethodMember)ReflectionHelper.GetMember(typeof(SimpleMethodClass).GetMethod("SetSomething", new Type[] { typeof(string), typeof(string) }));

            mDoubleArgAction = new ObjectMethodInvokeFromSourceAction(mDoubleArgMethod, new IDatasource[] { mSourceMock.Object, mSourceMock.Object });
        }
开发者ID:hvitorino,项目名称:AutoPoco,代码行数:10,代码来源:ObjectMethodInvokeFromSourceActionTests.cs

示例14: Single_Passes_Context_Through_To_Session

        public void Single_Passes_Context_Through_To_Session()
        {
            Mock<IObjectBuilder> builder = new Mock<IObjectBuilder>();
            Mock<IGenerationConfiguration> builderRepository = new Mock<IGenerationConfiguration>();
            builderRepository.Setup(x => x.GetBuilderForType(typeof (Object))).Returns(builder.Object);
            IGenerationContext context = new GenerationContext(builderRepository.Object);

            context.Single<Object>().Get();

            builder.Verify(x => x.CreateObject(context), Times.Once());
        }
开发者ID:KCL5South,项目名称:KCLAutoPoco,代码行数:11,代码来源:GenerationContextTests.cs

示例15: WriteClasses

        protected virtual void WriteClasses(CodeWriter writer, Database schema, GenerationContext context)
        {
            IEnumerable<Table> tables = schema.Tables;

            var types = context.Parameters.GenerateTypes;
            if (types.Count > 0)
                tables = tables.Where(t => types.Contains(t.Type.Name));

            foreach (var table in tables)
                WriteClass(writer, table, schema, context);
        }
开发者ID:Bewolf2,项目名称:GenesisMono,代码行数:11,代码来源:CodeGenerator.Class.cs


注:本文中的GenerationContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。