/// <summary> /// Handles members that are not being invoked. /// /// TLObjects.foo -- Not Invoked /// TLObjects.foo.bar -- Not Invoked /// TLObjects.foo() -- Invoked /// TLObjects.foo.bar() -- Invoked /// /// This function assigns a new instance of itself to <paramref name="result"/> while saving all previous members /// </summary> /// <param name="binder">Information about the member</param> /// <param name="result">The member itself</param> /// <returns>True if the member could be found. Otherwise, false.</returns> public override bool TryGetMember(GetMemberBinder binder, out object result) { if (binder.Name.ToLower() == "layer") { result = Layer(); return(true); } // If there's more to come, return a NEW instance so we can continue parsing while // retaining all previous information. and to keep the methods separate which allows // this instance to remain free of junk from previous calls. if (ReservedMethods.Contains(binder.Name.ToLower())) { // Create a new instance of this member while reserving the prior ones result = new TLSchema() { methodStack = new List <string>(methodStack) { binder.Name } }; // Since the method is reserved, we need to continue before creating the object return(true); } // Attempt to parse the item for return. // NOTE: We are returning an item here in case it's a constructor with no methods. result = TLObject.BuildTLObject($"{string.Join(".", methodStack)}.{binder.Name}".Trim('.')); // Return whether or not the TLObject was found return(result != null); }
/// <summary> /// Handles members that are being invoked. /// /// TLObjects.foo -- Not Invoked /// TLObjects.foo.bar -- Not Invoked /// TLObjects.foo() -- Invoked /// TLObjects.foo.bar() -- Invoked /// /// This function assigns the resulting TLObject to <paramref name="result"/> with all args saved. /// </summary> /// <param name="binder">Information about the member</param> /// <param name="args">Arguments to be passed to the member</param> /// <param name="result">The member itself</param> /// <returns>True if the member could be found. Otherwise, false.</returns> public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result) { // Ensure that there will something so that we can pass args[0] if (args == null) { args = new object[1]; } if (args[0] == null) { args[0] = new object(); } //var asdf = // // Attempt to parse the item for return. // NOTE: All args besides the first are ignored result = TLObject.BuildTLObject($"{string.Join(".", methodStack)}.{binder.Name}".Trim('.'), args[0]); // Return whether or not the TLObject was found return(result != null); }