public static void AddRandomCategories(this ITypeContext typeContext, Authentication authentication, int tryCount) { for (var i = 0; i < tryCount; i++) { typeContext.AddRandomCategory(authentication); } }
public System.Type Compile(AssemblyGen assembly, ITypeContext context) { System.Type baseType; if (BaseType != null) { baseType = BaseType.ResolveType(context); } else { baseType = typeof(FSObject); } var generator = assembly.DefineType(Name, baseType, System.Reflection.TypeAttributes.Public, context); System.Type[] types = null; if (Implements != null) { types = Implements.Map(impl => impl.ResolveType(context)).AddLast(typeof(IFSObject)); } else { types = new System.Type[1] { typeof(IFSObject) }; } generator.SetInterfaces(types); generator.Source = Source; generator.SetCustomAttribute(typeof(Runtime.RegisterAttribute), Utils.ReflectionHelpers.Register_Attr_Ctor, new object[] { Name }); foreach (var member in Members) { member.CreateMember(generator); } return(generator.CreateType()); }
/// <summary> /// Initializes new instance of <see cref="MethodBodyGenerator"/> /// </summary> public MethodBodyGenerator(IMethodBase method, System.Reflection.Emit.ILGenerator generator, bool emitInfo = false) : base(generator, emitInfo) { Method = method; ReturnType = method.ReturnType; Context = method.Context; SyntaxTree = method.SyntaxBody; }
public NewTypeViewModel(Authentication authentication, ITypeCategory category, ITypeTemplate template) : base(authentication, template, true) { this.category = category; this.typeContext = category.GetService(typeof(ITypeContext)) as ITypeContext; this.DisplayName = Resources.Title_NewType; }
public static void Generate(this ITypeContext context, Authentication authentication, int tryCount) { for (var i = 0; i < tryCount; i++) { context.Generate(authentication); } }
public static async Task GenerateStandardAsync(this ITypeContext typeContext, Authentication authentication) { if (typeContext.GetService(typeof(ITypeCategoryCollection)) is ITypeCategoryCollection typeCategoryCollection) { var root = typeCategoryCollection.Root; { await root.GenerateStandardTypeAsync(authentication); await root.GenerateStandardFlagsAsync(authentication); } var category = await root.AddNewCategoryAsync(authentication); { await category.GenerateStandardTypeAsync(authentication); await category.GenerateStandardFlagsAsync(authentication); } var subCategory = await category.AddNewCategoryAsync(authentication); { await subCategory.GenerateStandardTypeAsync(authentication); await subCategory.GenerateStandardFlagsAsync(authentication); } } else { throw new NotImplementedException(); } }
public void ExitContext(ITypeContext context) { ThrowHelper.Check(ReferenceEquals(_current, context), "Cannot exit non-current type context"); ThrowHelper.Check(!ReferenceEquals(_root, context), "Cannot exit root type context"); _current = ((TypeContext)context).Parent; }
public ITypeContext EnterContext() { var ctx = new TypeContext(this, _current); _current = ctx; return(ctx); }
public static void AddRandomTypes(this ITypeContext typeContext, Authentication authentication, int tryCount) { for (var i = 0; i < tryCount; i++) { AddRandomType(typeContext, authentication); } }
public ParameterInfo GetParameterInfo(ITypeContext provider) { if (Type == null) { return(new ParameterInfo(Name, Index, TypeProvider.AnyType, IsVarArgs)); } return(new ParameterInfo(Name, Index, Type.ResolveType(provider), IsVarArgs)); }
public static Task <IType> GetTypeAsync(this ITypeContext typeContext, string typeName) { if (typeContext.GetService(typeof(ITypeCollection)) is ITypeCollection typeCollection) { return(typeCollection.GetTypeAsync(typeName)); } throw new NotImplementedException(); }
public static Task <ITypeCategory> GetTypeCategoryAsync(this ITypeContext typeContext, string categoryPath) { if (typeContext.GetService(typeof(ITypeCategoryCollection)) is ITypeCategoryCollection typeCategoryCollection) { return(typeCategoryCollection.GetCategoryAsync(categoryPath)); } throw new NotImplementedException(); }
public static Task <ITypeCategory[]> GetTypeCategoriesAsync(this ITypeContext typeContext) { if (typeContext.GetService(typeof(ITypeCategoryCollection)) is ITypeCategoryCollection typeCategoryCollection) { return(typeCategoryCollection.GetCategoriesAsync()); } throw new NotImplementedException(); }
public TypeGenerator(TypeBuilder builder, AssemblyGen assemblyGen, ITypeContext context) { this.assemblyGen = assemblyGen; Name = builder.Name; _builder = builder; BaseType = _builder.BaseType; Context = context; }
public static async Task <IType> AddRandomTypeAsync(this ITypeContext typeContext, Authentication authentication) { if (typeContext.GetService(typeof(ITypeCategoryCollection)) is ITypeCategoryCollection typeCategoryCollection) { var category = await typeCategoryCollection.GetRandomTypeCategoryAsync(); return(await AddRandomTypeAsync(category, authentication)); } throw new NotImplementedException(); }
public CommonConversions(Document document, SemanticModel semanticModel, TypeConversionAnalyzer typeConversionAnalyzer, SyntaxGenerator csSyntaxGenerator, CSharpCompilation csCompilation, ITypeContext typeContext) { TypeConversionAnalyzer = typeConversionAnalyzer; Document = document; _semanticModel = semanticModel; CsSyntaxGenerator = csSyntaxGenerator; _csCompilation = csCompilation; _typeContext = typeContext; }
public static void Generate(this ITypeContext context, Authentication authentication) { if (RandomUtility.Within(25) == true) { context.AddRandomCategory(authentication); } else { context.AddRandomType(authentication); } }
public static void SetProperties <T>(this ITypeContext context, T typeToSetProperties) where T : class { foreach (var property in typeToSetProperties.GetType().GetProperties()) { var instance = context.GetInstance(property.PropertyType); if (instance != null) { typeToSetProperties.GetType().GetProperty(property.Name).SetValue(typeToSetProperties, instance); } } }
public static async Task AddRandomTypesAsync(this ITypeContext typeContext, Authentication authentication, DataBaseSettings settings) { var minCount = settings.TypeContext.MinTypeCount; var maxCount = settings.TypeContext.MaxTypeCount; var count = RandomUtility.Next(minCount, maxCount); var typeCollection = typeContext.GetService(typeof(ITypeCollection)) as ITypeCollection; while (typeCollection.Count < count) { await AddRandomTypeAsync(typeContext, authentication); } }
public ObjectAssembler(WiringContext wiringContext, ObjectAssemblerSettings settings = null) { this.wiringContext = wiringContext; typeConverterProvider = wiringContext.ConverterProvider; xamlTypeRepository = wiringContext.TypeContext; typeRepository = wiringContext.TypeContext; typeOperations = new TypeOperations(typeRepository.TypeFactory); startMemberWriter = new StartMemberWriter(this); getObjectWriter = new GetObjectWriter(this); startObjectWriter = new StartObjectWriter(this, settings?.RootInstance); valueWriter = new ValueWriter(this); }
public CommonConversions(Document document, SemanticModel semanticModel, TypeConversionAnalyzer typeConversionAnalyzer, SyntaxGenerator csSyntaxGenerator, CSharpCompilation csCompilation, ITypeContext typeContext, VisualBasicEqualityComparison visualBasicEqualityComparison) { TypeConversionAnalyzer = typeConversionAnalyzer; Document = document; _semanticModel = semanticModel; CsSyntaxGenerator = csSyntaxGenerator; _csCompilation = csCompilation; _typeContext = typeContext; VisualBasicEqualityComparison = visualBasicEqualityComparison; WinformsConversions = new WinformsConversions(typeContext); }
public async Task TestInitializeAsync() { var dataBaseFilter = new DataBaseFilter(DataBaseFlags.Loaded | DataBaseFlags.Public | DataBaseFlags.NotLocked) { Settings = DataBaseSettings.Default }; await this.TestContext.InitializeAsync(app); dataBase = await dataBaseFilter.GetDataBaseAsync(app); typeContext = dataBase.GetService(typeof(ITypeContext)) as ITypeContext; }
public CSharpToJScriptConverter(ITypeContext context) { _context = context; // extract assembly references from the container ... var assemblies = _context as IAssemblyContainer; if(null != assemblies) { foreach(var assembly in assemblies.Assemblies) { AddAssembly(assembly); } } }
public static async Task <ITypeCategory> AddRandomCategoryAsync(this ITypeContext typeContext, Authentication authentication) { if (typeContext.GetService(typeof(ITypeCategoryCollection)) is ITypeCategoryCollection typeCategoryCollection) { var category = RandomUtility.Within(33) == true ? typeCategoryCollection.Root : await typeCategoryCollection.GetRandomTypeCategoryAsync(); if (GetLevel(category, (i) => i.Parent) > 4) { return(null); } return(await category.AddRandomCategoryAsync(authentication)); } throw new NotImplementedException(); }
public static void ClassInit(TestContext context) { app = new CremaBootstrapper(); app.Initialize(context, nameof(ITypeContext_DispatcherTest)); cremaHost = app.GetService(typeof(ICremaHost)) as ICremaHost; cremaHost.Dispatcher.Invoke(() => { authentication = cremaHost.Start(); dataBase = cremaHost.DataBases.Random(); dataBase.Load(authentication); dataBase.Enter(authentication); dataBase.TypeContext.AddRandomItems(authentication); typeContext = dataBase.TypeContext; }); }
public static ITypeCategory AddRandomCategory(this ITypeContext typeContext, Authentication authentication) { if (RandomUtility.Within(33) == true) { return(typeContext.Root.AddRandomCategory(authentication)); } else { var category = typeContext.Categories.Random(); if (GetLevel(category, (i) => i.Parent) > 4) { return(null); } return(category.AddRandomCategory(authentication)); } }
public static async Task <ITypeItem> GenerateAsync(this ITypeContext typeContext, Authentication authentication) { if (RandomUtility.Within(25) == true) { if (typeContext.GetService(typeof(ITypeCategoryCollection)) is ITypeCategoryCollection typeCategoryCollection) { return((await typeCategoryCollection.GenerateCategoryAsync(authentication)) as ITypeItem); } } else { if (typeContext.GetService(typeof(ITypeCollection)) is ITypeCollection typeCollection) { return((await typeCollection.GenerateTypeAsync(authentication)) as ITypeItem); } } throw new NotImplementedException(); }
public static void GenerateStandard(this ITypeContext context, Authentication authentication) { var root = context.Root; { root.GenerateStandardType(authentication); root.GenerateStandardFlags(authentication); } var category = root.AddNewCategory(authentication); { category.GenerateStandardType(authentication); category.GenerateStandardFlags(authentication); } var subCategory = category.AddNewCategory(authentication); { subCategory.GenerateStandardType(authentication); subCategory.GenerateStandardFlags(authentication); } }
public override System.Type ResolveType(ITypeContext provider) { if (Type == null) { if (GenericPrameters == null) { Type = provider.GetType(Name); } else { Type = provider.GetType(string.Concat(Name, '`', GenericPrameters.Count)); if (Type == null) { Type = TypeProvider.AnyType; } Type = Type.MakeGenericType(GenericPrameters.Map(p => p.ResolveType(provider))); } } return(Type); }
internal static void Register(ITypeContext context, string lib, INodeList <TypeImport> imports) { #if NETCOREAPP // todo not supported getTypes for netcoreapp var assemblyImport = Assembly.Load(lib); #else var assemblyImport = Assembly.ReflectionOnlyLoad(lib); #endif foreach (var import in imports) { TypeName typeName = import.TypeName; Type type; if (typeName.Namespace == null) { Type[] types = assemblyImport.GetExportedTypes(); type = types.FirstOrDefault(t => t.Name == typeName.Name); } else { type = assemblyImport.GetType(typeName.FullName); } context.Register(import.Name, type); } }
public EndMemberCommand(ObjectAssembler assembler, ITopDownValueContext topDownValueContext) : base(assembler) { this.topDownValueContext = topDownValueContext; typeContext = Assembler.WiringContext.TypeContext; }
public override System.Type ResolveType(ITypeContext provider) { return(ElementType.ResolveType(provider).MakeArrayType(Rank)); }
public static Task AddItemsCreatedEventHandlerAsync(this ITypeContext typeContext, ItemsCreatedEventHandler <ITypeItem> handler) { return(typeContext.Dispatcher.InvokeAsync(() => typeContext.ItemsCreated += handler)); }
public XamlTypeConverterContext(ITypeContext typeContext) { TypeContext = typeContext; }
public override void Compile(ITypeContext context) { foreach(var cc in context) this.Compile(cc); }
public WiringContext(ITypeContext typeContext, ITypeFeatureProvider typeFeatureProvider) { FeatureProvider = typeFeatureProvider; TypeContext = typeContext; }
public WiringContext(ITypeContext typeContext, IContentPropertyProvider contentPropertyProvider, ITypeConverterProvider converterProvider) { TypeContext = typeContext; ContentPropertyProvider = contentPropertyProvider; ConverterProvider = converterProvider; }
public ProtoParser(ITypeContext typingCore) { this.typingCore = typingCore; stack = new Context(); }