public TypeReference(string name, TypeReference baseType) { this.Fields = new TypeVariableCollection(); this.Methods = new MethodCollection(); base.Name = name; this.BaseType = baseType; }
public void ReflectionMethodsCheckWeSupportAsync() { MethodCollection methodNames = Instance.ReflectionGetMethods(); Assert.IsNotNull(methodNames, "Should not be null"); Assert.AreNotEqual(0, methodNames.Count, "Should return some method names."); Assert.IsNotNull(methodNames[0], "First item should not be null"); Type type = typeof(Flickr); MethodInfo[] methods = type.GetMethods(); int failCount = 0; foreach (string methodName in methodNames.Where(m => !ExcludedMethods.Contains(m))) { bool found = false; string trueName = methodName.Replace("flickr.", "").Replace(".", "").ToLower() + "async"; foreach (MethodInfo info in methods) { if (trueName == info.Name.ToLower()) { found = true; break; } } if (!found) { failCount++; Console.WriteLine("Async Method '" + methodName + "' not found in FlickrNet.Flickr."); } } Assert.AreEqual(0, failCount, "FailCount should be zero. Currently " + failCount + " unsupported methods found."); }
private GeneratedMethod buildDetermineOperationMethod() { var method = _inlineType.MethodFor(nameof(AggregationRuntime <string, string> .DetermineOperation)); // This gets you the EventSlice aggregate Id method.DerivedVariables.Add(new Variable(_aggregateMapping.IdType, $"slice.{nameof(EventSlice<string, string>.Id)}")); method.DerivedVariables.Add(Variable.For <ITenant>($"slice.{nameof(EventSlice<string, string>.Tenant)}")); method.DerivedVariables.Add(Variable.For <ITenant>($"slice.{nameof(EventSlice<string, string>.Tenant)}")); method.DerivedVariables.Add(Variable.For <IEvent>("@event")); method.DerivedVariables.Add(Variable.For <IMartenSession>($"({typeof(IMartenSession).FullNameInCode()})session")); method.DerivedVariables.Add(Variable.For <IQuerySession>("session")); method.DerivedVariables.Add( Variable.For <IAggregateProjection>(nameof(AggregationRuntime <string, string> .Projection))); var createFrame = new CallCreateAggregateFrame(_createMethods); method.Frames.Add(new InitializeLiveAggregateFrame(typeof(T), _aggregateMapping.IdType, createFrame)); method.Frames.Add(new MethodCall(_storageType, "SetIdentity")); var handlers = MethodCollection.AddEventHandling(typeof(T), _aggregateMapping, _applyMethods, _shouldDeleteMethods); var iterate = new ForEachEventFrame((IReadOnlyList <Frame>)handlers); method.Frames.Add(iterate); return(method); }
internal ClassDefinition(JavaClassImage classImage) : base(classImage, (ClassInfo)classImage.ClassFile.ConstantPool.ResolveConstant(classImage.ClassFile.ThisClass)) { Image = classImage; // Super class _superClass = new LazyValue <ClassReference>(() => classImage.ClassFile.SuperClass != 0 ? new ClassReference(classImage, (ClassInfo)classImage.ClassFile.ConstantPool.ResolveConstant(classImage.ClassFile.SuperClass)) : null); // Flags AccessFlags = classImage.ClassFile.AccessFlags; // Fields Fields = new FieldCollection(this); foreach (var field in classImage.ClassFile.Fields) { Fields.Add(new FieldDefinition(classImage, field)); } // Methods Methods = new MethodCollection(this); foreach (var method in classImage.ClassFile.Methods) { Methods.Add(new MethodDefinition(classImage, method)); } }
public ClassDefinition(string name, ClassReference superClass) : base(name) { _superClass = new LazyValue <ClassReference>(superClass); Fields = new FieldCollection(this); Methods = new MethodCollection(this); }
public ScriptingExtension() { languages = new List<IScriptEngine>(); publishedMethods = new MethodCollection(); publishedObjects = new ObjectCollection(); PublishedMethods.Added += new TalkingCollectionEventHandler<string, Delegate>(HandleNewMethod); PublishedMethods.Removed += new TalkingCollectionEventHandler<string, Delegate>(HandleRemoveMethod); }
public void ReflectionMethodsBasic() { MethodCollection methodNames = Instance.ReflectionGetMethods(); Assert.IsNotNull(methodNames, "Should not be null"); Assert.AreNotEqual(0, methodNames.Count, "Should return some method names."); Assert.IsNotNull(methodNames[0], "First item should not be null"); }
public ResourceRouter(IHandler parent, object instance, SerializationRegistry formats) { Parent = parent; Instance = instance; Serialization = formats; Methods = new MethodCollection(this, AnalyzeMethods(instance.GetType())); }
private void buildInlineAggregationType() { var inlineBaseType = typeof(InlineAggregationBase <,>).MakeGenericType(typeof(T), _aggregateMapping.IdType); _inlineType = _assembly.AddType(GetType().NameInCode().Sanitize() + "InlineHandler", inlineBaseType); _createMethods.BuildCreateMethod(_inlineType, _aggregateMapping); _inlineType.AllInjectedFields.Add(new InjectedField(_storageType)); _inlineType.AllInjectedFields.Add(new InjectedField(GetType())); var method = _inlineType.MethodFor(nameof(InlineAggregationBase <string, string> .DetermineOperation)); // This gets you the EventSlice aggregate Id method.DerivedVariables.Add(Variable.For <Guid>($"slice.{nameof(EventSlice<string, string>.Id)}")); method.DerivedVariables.Add(Variable.For <string>($"slice.{nameof(EventSlice<string, string>.Id)}")); // TODO -- this is hokey. Just pass in ITenant? method.DerivedVariables.Add(Variable.For <ITenant>($"(({typeof(IMartenSession).FullNameInCode()})session).{nameof(IMartenSession.Tenant)}")); method.DerivedVariables.Add(Variable.For <IEvent>("@event")); method.DerivedVariables.Add(Variable.For <IMartenSession>($"({typeof(IMartenSession).FullNameInCode()})session")); method.DerivedVariables.Add(Variable.For <IQuerySession>("session")); method.DerivedVariables.Add(Variable.For <IAggregateProjection>(nameof(InlineAggregationBase <string, string> .Projection))); var sliceType = typeof(EventSlice <,>).MakeGenericType(_aggregateMapping.DocumentType, _aggregateMapping.IdType); if (DeleteEvents.Any()) { method.Frames.Code($"if (Projection.{nameof(MatchesAnyDeleteType)}({{0}})) return {{1}}.{nameof(IDocumentStorage<string, string>.DeleteForId)}({{2}});", new Use(sliceType), new Use(_storageType), new Use(_aggregateMapping.IdType)); } var createFrame = new CallCreateAggregateFrame(_createMethods); method.Frames.Add(new InitializeLiveAggregateFrame(typeof(T), _aggregateMapping.IdType, createFrame)); method.Frames.Add(new MethodCall(_storageType, "SetIdentity")); var handlers = MethodCollection.AddEventHandling(typeof(T), _aggregateMapping, _applyMethods, _shouldDeleteMethods); var iterate = new ForEachEventFrame((IReadOnlyList <Frame>)handlers); method.Frames.Add(iterate); var upsertMethod = typeof(IDocumentStorage <>).MakeGenericType(typeof(T)).GetMethod("Upsert"); var upsert = new MethodCall(_storageType, upsertMethod) { ReturnAction = ReturnAction.Return }; method.Frames.Add(upsert); _inlineType.Setters.AddRange(_applyMethods.Setters()); _inlineType.Setters.AddRange(_createMethods.Setters()); _inlineType.Setters.AddRange(_shouldDeleteMethods.Setters()); }
public void TestIsPrimeNumber(int number, bool fact) { // Arrange // Act bool isPrimeNumber = MethodCollection.IsPrimeNumber(number); // Assert Assert.Equal(fact, isPrimeNumber); }
public void TestIsOdd(int number, bool boolean) { // Arrange // Act bool odd = MethodCollection.IsOdd(number); //Assert Assert.Equal(boolean, odd); }
public void TestWordCount(string sentence, int fact) { // Arrange // Act int count = MethodCollection.WordCount(sentence); //Assert Assert.Equal(fact, count); }
public void should_detect_affected_method() { var methods = new MethodCollection { Methods = new List <Method> { new Method { Name = "foo", Span = new Span { OldFrom = 10, OldTo = 20 } }, new Method { Name = "bar", Span = new Span { OldFrom = 21, OldTo = 30 } }, new Method { Name = "baz", Span = new Span { OldFrom = 31, OldTo = 40 } }, new Method { Name = "barbaz", Span = new Span { OldFrom = 50, OldTo = 100 } } } }; var change = new Change { Spans = new List <Span> { new Span { OldFrom = 8, OldTo = 11 }, new Span { OldFrom = 29, OldTo = 30 }, new Span { OldFrom = 200, OldTo = 300 } } }; var result = methods.GetAffectedBy(change).ToList(); result.Should().Contain("foo"); result.Should().Contain("bar"); result.Should().NotContain("baz"); }
/// <summary> /// Creates an object that commits or rejects several batched operations as a unit. /// </summary> public Transaction(TransactionCollection transactionCollection) { // Initialize the object this.Index = transactionCollection.Count; this.Exceptions = new List <Exception>(); this.Methods = new MethodCollection(); this.transactionCollection = transactionCollection; // This transaction is the current transaction. this.previousTransaction = this.transactionCollection.Current; this.transactionCollection.current = this; }
/// <summary> /// Initializes a new instance of the MslScriptEngine class. /// </summary> public MslScriptEngine() { language = new LanguageDefinition("MSL", new string[] { "mrc", "ini" }, LanguageFeatures.Procedural | LanguageFeatures.TypeSave); publishedMethods = new MethodCollection(); Type scriptTextMethods = typeof(MslStringMethods); MethodInfo info = scriptTextMethods.GetMethod("Left"); publishedMethods.Add("+", new MultiParamIdentifierDelegate(MslStringMethods.Concat)); publishedMethods.Add("left", new MslStringMethods.LeftDelegate(MslStringMethods.Left)); publishedMethods.Add("me", new SimpleStringIdentifier(MslDummyMethods.Me)); publishedMethods.Add("true", new SimpleStringIdentifier(MslDummyMethods.True)); publishedMethods.Add("false", new SimpleStringIdentifier(MslDummyMethods.False)); }
public MethodWriter(TypeBuilder Parent, CodeMemberMethod Member, MethodCollection Lookup, ILMirror Mirror) { Loops = new Stack<LoopMetadata>(); this.Member = Member; this.Lookup = Lookup; this.Mirror = Mirror; if(Member is CodeEntryPointMethod) { Method = Parent.DefineMethod("Main", MethodAttributes.Private | MethodAttributes.Static, typeof(void), null); IsEntryPoint = true; } else Method = Parent.DefineMethod(Member.Name, MethodAttributes.Public | MethodAttributes.Static, typeof(object), new[] { typeof(object[]) }); Generator = Method.GetILGenerator(); ForceString = typeof(Script).GetMethod("ForceString"); ForceDecimal = typeof(Script).GetMethod("ForceDecimal"); ForceLong = typeof(Script).GetMethod("ForceLong"); ForceInt = typeof(Script).GetMethod("ForceInt"); ForceBool = typeof(Script).GetMethod("ForceBool"); Locals = new Dictionary<string, LocalBuilder>(); Labels = new Dictionary<string, LabelMetadata>(); Type Variables = typeof(Script.Variables); if(IsEntryPoint) GenerateEntryPointHeader(Generator); SetVariable = typeof(Script.Variables).GetMethod("SetVariable"); GetVariable = typeof(Script.Variables).GetMethod("GetVariable"); MethodInfo GetVars = typeof(Script).GetMethod("get_Vars"); if(Mirror != null) { ForceString = Mirror.GrabMethod(ForceString); ForceDecimal = Mirror.GrabMethod(ForceDecimal); ForceLong = Mirror.GrabMethod(ForceLong); ForceInt = Mirror.GrabMethod(ForceInt); ForceBool = Mirror.GrabMethod(ForceBool); SetVariable = Mirror.GrabMethod(SetVariable); GetVariable = Mirror.GrabMethod(GetVariable); Variables = Mirror.GrabType(Variables); GetVars = Mirror.GrabMethod(GetVars); } VarsProperty = Generator.DeclareLocal(Variables); Generator.Emit(OpCodes.Call, GetVars); Generator.Emit(OpCodes.Stloc, VarsProperty); }
internal override IReadOnlyList <AsyncProjectionShard> AsyncProjectionShards(DocumentStore store) { var baseFilters = new ISqlFragment[0]; var eventTypes = MethodCollection.AllEventTypes(_createMethods, _projectMethods); if (!eventTypes.Any(x => x.IsAbstract || x.IsInterface)) { baseFilters = new ISqlFragment[] { new Marten.Events.Daemon.EventTypeFilter(store.Events, eventTypes) }; } return(new List <AsyncProjectionShard> { new(this, baseFilters) });
internal ClassDefinition(JavaClassImage classImage) : base(classImage, (ClassInfo)classImage.ClassFile.ConstantPool.ResolveConstant(classImage.ClassFile.ThisClass)) { Image = classImage; // Super class _superClass = new LazyValue <ClassReference>(() => classImage.ClassFile.SuperClass != 0 ? new ClassReference(classImage, (ClassInfo)classImage.ClassFile.ConstantPool.ResolveConstant(classImage.ClassFile.SuperClass)) : null); // Flags AccessFlags = classImage.ClassFile.AccessFlags; // Fields Fields = new FieldCollection(this); foreach (var field in classImage.ClassFile.Fields) { Fields.Add(new FieldDefinition(classImage, field)); } // Methods Methods = new MethodCollection(this); foreach (var method in classImage.ClassFile.Methods) { Methods.Add(new MethodDefinition(classImage, method)); } // Attributes foreach (var attr in classImage.ClassFile.Attributes) { string name = classImage.ClassFile.ConstantPool.ResolveString(attr.NameIndex); switch (name) { // Source file case SingleIndexAttribute.SourceFileAttribute: _sourceFile = new LazyValue <string>(() => { var sourceFile = SingleIndexAttribute.FromReader(name, new MemoryBigEndianReader(attr.Contents)); return(classImage.ClassFile.ConstantPool.ResolveString(sourceFile.ConstantPoolIndex)); }); break; default: ExtraAttributes.Add(name, attr.Clone()); break; } } }
public Compiler() { Methods = new MethodCollection(); }
public Entity() { Properties = new PropertyCollection(); Relationships = new RelationshipCollection(); Methods = new MethodCollection(); }