Пример #1
0
 public Object InvokeMember(String name, BindingFlags flags, Binder binder, Object target, 
                            Object[] args, ParameterModifier[] modifiers, CultureInfo locale, String[] namedParameters){
   if ((flags & BindingFlags.CreateInstance) == 0)
     //Try to create an instance of the array
     return LateBinding.CallValue(this.elementType, args, true, true, null, null, binder, locale, namedParameters);
   return Typeob.Array.InvokeMember(name, flags, binder, target, args, modifiers, locale, namedParameters);
 }
Пример #2
0
 internal WithTypeArgumentsBinder(ImmutableArray<TypeSymbol> typeArguments, Binder next)
     : base(next)
 {
     Debug.Assert(!typeArguments.IsDefaultOrEmpty);
     Debug.Assert(typeArguments.All(ta => ta.Kind == SymbolKind.TypeParameter));
     _typeArguments = typeArguments;
 }
        protected sealed override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
        {
            Debug.Assert(name != null);

            if (!OnlySearchRelatedBitsSet(bindingAttr))  // We don't yet have proper handling for BindingFlags not related to search so throw rather return a wrong result.
                throw new NotImplementedException();

            // GetPropertyImpl() is a funnel for two groups of api. We can distinguish by comparing "types" to null.
            if (types == null && returnType == null)
            {
                // Group #1: This group of api accept only a name and BindingFlags. The other parameters are hard-wired by the non-virtual api entrypoints. 
                Debug.Assert(binder == null);
                Debug.Assert(modifiers == null);
                return LowLevelTypeExtensions.GetProperty(this, name, bindingAttr);
            }
            else
            {
                if (!OnlySearchRelatedBitsSet(bindingAttr))  // We don't yet have proper handling for BindingFlags not related to search so throw rather return a wrong result.
                    throw new NotImplementedException();

                // Group #2: This group of api takes a set of parameter types, a return type (both cannot be null) and an optional binder. 
                if (binder == null)
                    binder = Type.DefaultBinder;
                PropertyInfo[] candidates = LowLevelTypeExtensions.GetProperties(this, name, bindingAttr);
                return binder.SelectProperty(bindingAttr, candidates, returnType, types, modifiers);
            }
        }
Пример #4
0
        internal PlaceholderLocalBinder(
            CSharpSyntaxNode syntax,
            ImmutableArray<Alias> aliases,
            MethodSymbol containingMethod,
            EETypeNameDecoder typeNameDecoder,
            Binder next) :
            base(next)
        {
            _syntax = syntax;
            _containingMethod = containingMethod;

            var compilation = next.Compilation;
            var sourceAssembly = compilation.SourceAssembly;

            var aliasesBuilder = ArrayBuilder<LocalSymbol>.GetInstance(aliases.Length);
            var lowercaseBuilder = ImmutableDictionary.CreateBuilder<string, LocalSymbol>();
            foreach (Alias alias in aliases)
            {
                var local = PlaceholderLocalSymbol.Create(
                    typeNameDecoder,
                    containingMethod,
                    sourceAssembly,
                    alias);
                aliasesBuilder.Add(local);

                if (alias.Kind == DkmClrAliasKind.ReturnValue)
                {
                    lowercaseBuilder.Add(local.Name.ToLower(), local);
                }
            }
            _lowercaseReturnValueAliases = lowercaseBuilder.ToImmutableDictionary();
            _aliases = aliasesBuilder.ToImmutableAndFree();
        }
 internal SourceStrictComplexParameterSymbol(
     DiagnosticBag diagnostics,
     Binder binder,
     Symbol owner,
     int ordinal,
     TypeSymbol parameterType,
     RefKind refKind,
     string name,
     ImmutableArray<Location> locations,
     SyntaxReference syntaxRef,
     ConstantValue defaultSyntaxValue,
     bool isParams,
     bool isExtensionMethodThis)
 : base(
     owner: owner,
     ordinal: ordinal,
     parameterType: parameterType,
     refKind: refKind,
     name: name,
     locations: locations,
     syntaxRef: syntaxRef,
     defaultSyntaxValue: defaultSyntaxValue,
     isParams: isParams,
     isExtensionMethodThis: isExtensionMethodThis)
 {
     _tempBinder = binder;
     var unused = GetAttributesBag(diagnostics);
     _lazyDefaultSyntaxValue = MakeDefaultExpression(diagnostics, binder);
     _tempBinder = null; // no need to keep it around anymore, just uses up a lot of memory
 }
 public override void SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo locale){
   if (obj is StackFrame){
     this.field.SetValue(((StackFrame)((StackFrame)obj).engine.ScriptObjectStackTop()).closureInstance, value, invokeAttr, binder, locale);
     return;
   }
   throw new JScriptException(JSError.InternalError); //should never happen
 }
Пример #7
0
        public void TestBindNotAssignableInstanceTypeToInstance()
        {
            var binder = new Binder();

            var instance = new MockClassToDepend();
            binder.Bind<MockClassToDepend>().To(typeof(MockClassVerySimple), instance);
        }
 public override object Invoke(object obj, BindingFlags options, Binder binder, object[] parameters, CultureInfo culture)
 {
     MethodInfo method = TypeReferences.ToExecutionContext(this.method);
     if (binder != null)
     {
         try
         {
             return method.Invoke(obj, options, binder, parameters, culture);
         }
         catch (TargetInvocationException exception)
         {
             throw exception.InnerException;
         }
     }
     MethodInvoker methodInvoker = this.methodInvoker;
     if ((methodInvoker == null) && ((this.methodInvoker = MethodInvoker.GetInvokerFor(method)) == null))
     {
         try
         {
             return method.Invoke(obj, options, binder, parameters, culture);
         }
         catch (TargetInvocationException exception2)
         {
             throw exception2.InnerException;
         }
     }
     return methodInvoker.Invoke(obj, parameters);
 }
        public void ShouldBindBetweenIndexedObjects()
        {
            var binder = new Binder<ObservableDictionary<UniversalStub>>();

            var dict= new ObservableDictionary<UniversalStub>();

            binder.BindIf(x => x.ContainsKey("first") && x.ContainsKey("second"), x => x["first"].String).To(x => x["second"].String);

            using (binder.Attach(dict))
            {
                var first = new UniversalStub();
                var second = new UniversalStub { String = "a" };
                dict.Add("second", second);
                second.String.ShouldBe("a");
                using (second.VerifyChangedOnce("String"))
                {
                    dict.Add("first", first);
                }
                second.String.ShouldBe(null);

                using (second.VerifyChangedOnce("String"))
                {
                    first.String = "b";
                }
                second.String.ShouldBe("b");
            }
        }
Пример #10
0
        public void TestBindNotAssignableKeyTypeToInstance()
        {
            var binder = new Binder();

            var instance = new MockClassToDepend();
            binder.Bind<IMockInterface>().To<MockClassToDepend>(instance);
        }
Пример #11
0
        public void TestBinding()
        {
            Binder binder = new Binder();
            var equivalent = new EventEquivalent();

            binder.Bind(new SampleEvent1(), new MethodHandler<SampleEvent1>(OnSampleEvent1));

            var e1 = new SampleEvent1();
            var e2 = new SampleEvent1 { Foo = 1 };
            var e3 = new SampleEvent1 { Foo = 1, Bar = "bar" };

            List<Handler> handlerChain = new List<Handler>();

            handlerChain.Clear();
            Assert.AreEqual(1, binder.BuildHandlerChain(e1, equivalent, handlerChain));
            Assert.AreEqual(new MethodHandler<SampleEvent1>(OnSampleEvent1), handlerChain[0]);
            handlerChain.Clear();
            Assert.AreEqual(1, binder.BuildHandlerChain(e2, equivalent, handlerChain));
            Assert.AreEqual(new MethodHandler<SampleEvent1>(OnSampleEvent1), handlerChain[0]);
            handlerChain.Clear();
            Assert.AreEqual(1, binder.BuildHandlerChain(e3, equivalent, handlerChain));
            Assert.AreEqual(new MethodHandler<SampleEvent1>(OnSampleEvent1), handlerChain[0]);

            binder.Unbind(new SampleEvent1(), new MethodHandler<SampleEvent1>(OnSampleEvent1));

            handlerChain.Clear();
            Assert.AreEqual(0, binder.BuildHandlerChain(e1, equivalent, handlerChain));
            handlerChain.Clear();
            Assert.AreEqual(0, binder.BuildHandlerChain(e2, equivalent, handlerChain));
            handlerChain.Clear();
            Assert.AreEqual(0, binder.BuildHandlerChain(e3, equivalent, handlerChain));
        }
 internal override object Call(object[] args, object thisob, Binder binder, CultureInfo culture)
 {
     if (this.func.isExpandoMethod)
     {
         ((Microsoft.JScript.StackFrame) this.enclosing_scope).thisObject = thisob;
     }
     else if ((this.declaringObject != null) && !(this.declaringObject is ClassScope))
     {
         thisob = this.declaringObject;
     }
     if (thisob == null)
     {
         thisob = ((IActivationObject) base.engine.ScriptObjectStackTop()).GetDefaultThisObject();
     }
     if ((this.enclosing_scope is ClassScope) && (this.declaringObject == null))
     {
         if (thisob is Microsoft.JScript.StackFrame)
         {
             thisob = ((Microsoft.JScript.StackFrame) thisob).closureInstance;
         }
         if (!this.func.isStatic && !((ClassScope) this.enclosing_scope).HasInstance(thisob))
         {
             throw new JScriptException(JSError.InvalidCall);
         }
     }
     return this.func.Call(args, thisob, this.enclosing_scope, this, binder, culture);
 }
Пример #13
0
        public void TestDuplicateUnbinding()
        {
            Binder binder = new Binder();
            var equivalent = new EventEquivalent();
            List<Handler> handlerChain = new List<Handler>();

            binder.Bind(new SampleEvent1 { Foo = 1 }, new MethodHandler<SampleEvent1>(OnSampleEvent1));
            binder.Bind(new SampleEvent1 { Foo = 2 }, new MethodHandler<SampleEvent1>(OnSpecificSampleEvent1));

            binder.Unbind(new SampleEvent1 { Foo = 1 }, new MethodHandler<SampleEvent1>(OnSampleEvent1));
            binder.Unbind(new SampleEvent1 { Foo = 1 }, new MethodHandler<SampleEvent1>(OnSampleEvent1));

            handlerChain.Clear();
            Assert.AreEqual(0, binder.BuildHandlerChain(new SampleEvent1 { Foo = 1 }, equivalent, handlerChain));
            Assert.AreEqual(1, binder.BuildHandlerChain(new SampleEvent1 { Foo = 2 }, equivalent, handlerChain));
            Assert.AreEqual(new MethodHandler<SampleEvent1>(OnSpecificSampleEvent1), handlerChain[0]);

            // with EventSink

            var sink = new SampleEventSink();
            sink.Bind(new SampleEvent1 { Foo = 1 }, sink.OnSampleEvent1);

            sink.Unbind(new SampleEvent1 { Foo = 1 }, sink.OnSampleEvent1);
            sink.Bind(new SampleEvent1 { Foo = 1 }, sink.OnSampleEvent1);

            handlerChain.Clear();
            Assert.AreEqual(0, binder.BuildHandlerChain(new SampleEvent1 { Foo = 1 }, equivalent, handlerChain));
            Assert.AreEqual(1, binder.BuildHandlerChain(new SampleEvent1 { Foo = 2 }, equivalent, handlerChain));
            Assert.AreEqual(new MethodHandler<SampleEvent1>(OnSpecificSampleEvent1), handlerChain[0]);
        }
        internal sealed override void LookupSymbolsInSingleBinder(
            LookupResult result,
            string name,
            int arity,
            ConsList<Symbol> basesBeingResolved,
            LookupOptions options,
            Binder originalBinder,
            bool diagnose,
            ref HashSet<DiagnosticInfo> useSiteDiagnostics)
        {
            if ((options & (LookupOptions.NamespaceAliasesOnly | LookupOptions.NamespacesOrTypesOnly | LookupOptions.LabelsOnly)) != 0)
            {
                return;
            }

            var local = this.LookupPlaceholder(name);
            if ((object)local == null)
            {
                base.LookupSymbolsInSingleBinder(result, name, arity, basesBeingResolved, options, originalBinder, diagnose, ref useSiteDiagnostics);
            }
            else
            {
                result.MergeEqual(this.CheckViability(local, arity, options, null, diagnose, ref useSiteDiagnostics, basesBeingResolved));
            }
        }
Пример #15
0
        public void TestAfterInject()
        {
            var eventCalled = false;

            IReflectionCache cache = new ReflectionCache();
            IBinder binder = new Binder();
            IInjector injector = new Injector(cache, binder);
            var instanceToInject = new MockClassVerySimple();

            injector.afterInject += delegate(IInjector source, ref object instance, ReflectedClass reflectedClass) {
                //The if below is just to avoid checking when injecting on MockIClass.
                if (reflectedClass.type != typeof(MockClassVerySimple)) return;

                Assert.AreEqual(injector, source);
                Assert.AreEqual(instanceToInject, instance);
                Assert.AreEqual(typeof(MockIClass), instanceToInject.field.GetType());

                eventCalled = true;
            };

            binder.Bind<IMockInterface>().To<MockIClass>();
            injector.Inject(instanceToInject);

            Assert.IsTrue(eventCalled);
        }
Пример #16
0
        public void TestAfterResolve()
        {
            var eventCalled = false;

            IReflectionCache cache = new ReflectionCache();
            IBinder binder = new Binder();
            IInjector injector = new Injector(cache, binder);
            IMockInterface resolvedInstance = null;

            injector.afterResolve += delegate(IInjector source,
                Type type,
                InjectionMember member,
                object parentInstance,
              	object identifier,
                ref object resolutionInstance) {
                Assert.AreEqual(injector, source);
                Assert.AreEqual(typeof(IMockInterface), type);
                Assert.AreEqual(InjectionMember.None, member);
                Assert.IsNull(parentInstance);
                Assert.IsNull(identifier);
                Assert.IsNotNull(resolutionInstance);

                resolvedInstance = (IMockInterface)resolutionInstance;
                eventCalled = true;

                return false;
            };

            binder.Bind<IMockInterface>().To<MockIClass>();
            var instance = injector.Resolve<IMockInterface>();

            Assert.IsTrue(eventCalled);
            Assert.AreEqual(typeof(MockIClass), instance.GetType());
            Assert.AreEqual(resolvedInstance, instance);
        }
        protected virtual async Task ProcessInputBindingsAsync(object input, string functionInstanceOutputPath, Binder binder,
            Collection<FunctionBinding> inputBindings, Collection<FunctionBinding> outputBindings,
            Dictionary<string, object> bindingData, Dictionary<string, string> environmentVariables)
        {
            // if there are any input or output bindings declared, set up the temporary
            // output directory
            if (outputBindings.Count > 0 || inputBindings.Any())
            {
                Directory.CreateDirectory(functionInstanceOutputPath);
            }

            // process input bindings
            foreach (var inputBinding in inputBindings)
            {
                string filePath = Path.Combine(functionInstanceOutputPath, inputBinding.Metadata.Name);
                using (FileStream stream = File.OpenWrite(filePath))
                {
                    // If this is the trigger input, write it directly to the stream.
                    // The trigger binding is a special case because it is early bound
                    // rather than late bound as is the case with all the other input
                    // bindings.
                    if (inputBinding.Metadata.IsTrigger)
                    {
                        if (input is string)
                        {
                            using (StreamWriter sw = new StreamWriter(stream))
                            {
                                await sw.WriteAsync((string)input);
                            }
                        }
                        else if (input is byte[])
                        {
                            byte[] bytes = input as byte[];
                            await stream.WriteAsync(bytes, 0, bytes.Length);
                        }
                        else if (input is Stream)
                        {
                            Stream inputStream = input as Stream;
                            await inputStream.CopyToAsync(stream);
                        }
                    }
                    else
                    {
                        // invoke the input binding
                        BindingContext bindingContext = new BindingContext
                        {
                            Binder = binder,
                            BindingData = bindingData,
                            DataType = DataType.Stream,
                            Value = stream
                        };
                        await inputBinding.BindAsync(bindingContext);
                    }
                }

                environmentVariables[inputBinding.Metadata.Name] = Path.Combine(functionInstanceOutputPath,
                    inputBinding.Metadata.Name);
            }
        }
Пример #18
0
        /// <summary>
        /// Create a context to compile expressions within a method scope.
        /// </summary>
        internal CompilationContext(
            CSharpCompilation compilation,
            MethodSymbol currentFrame,
            ImmutableArray<LocalSymbol> locals,
            InScopeHoistedLocals inScopeHoistedLocals,
            MethodDebugInfo<TypeSymbol, LocalSymbol> methodDebugInfo,
            CSharpSyntaxNode syntax)
        {
            Debug.Assert((syntax == null) || (syntax is ExpressionSyntax) || (syntax is LocalDeclarationStatementSyntax));

            // TODO: syntax.SyntaxTree should probably be added to the compilation,
            // but it isn't rooted by a CompilationUnitSyntax so it doesn't work (yet).
            _currentFrame = currentFrame;
            _syntax = syntax;
            _methodNotType = !locals.IsDefault;

            // NOTE: Since this is done within CompilationContext, it will not be cached.
            // CONSIDER: The values should be the same everywhere in the module, so they
            // could be cached.  
            // (Catch: what happens in a type context without a method def?)
            this.Compilation = GetCompilationWithExternAliases(compilation, methodDebugInfo.ExternAliasRecords);

            // Each expression compile should use a unique compilation
            // to ensure expression-specific synthesized members can be
            // added (anonymous types, for instance).
            Debug.Assert(this.Compilation != compilation);

            this.NamespaceBinder = CreateBinderChain(
                this.Compilation,
                (PEModuleSymbol)currentFrame.ContainingModule,
                currentFrame.ContainingNamespace,
                methodDebugInfo.ImportRecordGroups);

            if (_methodNotType)
            {
                _locals = locals;
                ImmutableArray<string> displayClassVariableNamesInOrder;
                GetDisplayClassVariables(
                    currentFrame,
                    _locals,
                    inScopeHoistedLocals,
                    out displayClassVariableNamesInOrder,
                    out _displayClassVariables,
                    out _hoistedParameterNames);
                Debug.Assert(displayClassVariableNamesInOrder.Length == _displayClassVariables.Count);
                _localsForBinding = GetLocalsForBinding(_locals, displayClassVariableNamesInOrder, _displayClassVariables);
            }
            else
            {
                _locals = ImmutableArray<LocalSymbol>.Empty;
                _displayClassVariables = ImmutableDictionary<string, DisplayClassVariable>.Empty;
                _localsForBinding = ImmutableArray<LocalSymbol>.Empty;
            }

            // Assert that the cheap check for "this" is equivalent to the expensive check for "this".
            Debug.Assert(
                _displayClassVariables.ContainsKey(GeneratedNames.ThisProxyFieldName()) ==
                _displayClassVariables.Values.Any(v => v.Kind == DisplayClassVariableKind.This));
        }
 internal override object Invoke(object obj, object thisob, BindingFlags options, Binder binder, object[] parameters, CultureInfo culture)
 {
     if (!(obj is StackFrame))
     {
         throw new JScriptException(JSError.InternalError);
     }
     return this.method.Invoke(((StackFrame) ((StackFrame) obj).engine.ScriptObjectStackTop()).closureInstance, options, binder, parameters, culture);
 }
        public override void configure(Binder binder)
        {
            binder.bind(typeof(AbstractTranslator)).to(typeof(StaticTranslator));

            //Everyone in this context gets this same DemoEventBus
            binder.bind(typeof(AbstractEventBus)).to(typeof(DemoEventBus));
            binder.bind(typeof(DemoEventBus)).inScope(Scope.Context).to(typeof(DemoEventBus));
        }
Пример #21
0
        public override void configure(Binder binder)
        {
            //make the StyleExtensionMap a Singleton
            binder.bind(typeof(StyleExtensionMap)).inScope(Scope.Singleton).to(typeof(StyleExtensionMap));

            //Setup a NoOp translator as the default
            binder.bind(typeof(AbstractTranslator)).to(typeof(NoOpTranslator));
        }
 public override object GetValue(object obj, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture)
 {
     if (this.getMeth == null)
     {
         throw new MissingMethodException();
     }
     return this.getMeth.Invoke(obj, invokeAttr, binder, index, culture);
 }
        public ChildInjector(Binder binder, ClassResolver classResolver, Injector parentInjector)
            : base(binder, classResolver)
        {
            this.parentInjector = parentInjector;

            //Child injectors set themselves up as the new default Injector for the tree below them
            binder.bind(typeof(Injector)).toInstance(this);
        }
 public override void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture)
 {
     FieldAccessor fieldAccessor = this.fieldAccessor;
     if (fieldAccessor == null)
     {
         this.fieldAccessor = fieldAccessor = FieldAccessor.GetAccessorFor(this.field);
     }
     fieldAccessor.SetValue(obj, value);
 }
        public static object AnotherResolver(Binder sender, Type t)
        {
            if (t == typeof(SomeClass8))
            {
                return new SomeClass8();
            }

            return null;
        }
Пример #26
0
 public static SourceLocalSymbol MakeLocal(
     Symbol containingSymbol,
     Binder binder,
     TypeSyntax typeSyntax,
     SyntaxToken identifierToken,
     LocalDeclarationKind declarationKind)
 {
     Debug.Assert(declarationKind != LocalDeclarationKind.ForEachIterationVariable);
     return new SourceLocalSymbol(containingSymbol, binder, typeSyntax, identifierToken, declarationKind);
 }
 public override void SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture) {
   if (this.setMeth == null)
     throw new MissingMethodException();
   int n = index == null ? 0 : index.Length;
   Object[] pars = new Object[n+1];
   pars[0] = value;
   if (n > 0)
     ArrayObject.Copy(index, 0, pars, 1, n);
   this.setMeth.Invoke(obj, invokeAttr, binder, pars, culture);
 }
 internal override Object Invoke(Object obj, Object thisob, BindingFlags options, Binder binder, Object[] parameters, CultureInfo culture){
   int n = this.formalParams.Length;
   int pn = (parameters != null ? parameters.Length : 0);
   if (!this.hasThis && !this.hasVarargs && n == pn)
     if (binder != null)
       return TypeReferences.ToExecutionContext(this.method).Invoke(this.obj, BindingFlags.SuppressChangeType, null, this.ConvertParams(0, parameters, binder, culture), null);
     else
       return TypeReferences.ToExecutionContext(this.method).Invoke(this.obj, options, binder, parameters, culture);
   int offset = (this.hasThis ? 1 : 0) + (this.hasEngine ? 1 : 0);
   Object[] arguments = new Object[n];
   if (this.hasThis){
     arguments[0] = thisob;
     if (this.hasEngine)
       arguments[1] = this.engine;
   }else if (this.hasEngine)
     arguments[0] = this.engine;
   if (this.hasVarargs){
     if (n == offset+1) //No params other than the vararg array
       arguments[offset] = parameters;
     else{
       //Some of the values in parameters must be passed separately from the vararg array
       int argsToCopy = n - 1 - offset; //The number of separate arguments
       if (pn > argsToCopy){
         ArrayObject.Copy(parameters, 0, arguments, offset, argsToCopy);
         int vn = pn-argsToCopy;
         Object[] varargs = new Object[vn];
         ArrayObject.Copy(parameters, argsToCopy, varargs, 0, vn); 
         arguments[n - 1] = varargs;
       }else{
         ArrayObject.Copy(parameters, 0, arguments, offset, pn);
         for (int i = pn; i < argsToCopy; i++)
           arguments[i+offset] = Missing.Value;
         arguments[n - 1] = new Object[0];
       }
     }
   }else{
     if(parameters != null){
       if (n-offset < pn)
         ArrayObject.Copy(parameters, 0, arguments, offset, n-offset);
       else
         ArrayObject.Copy(parameters, 0, arguments, offset, pn);
     }
     if(n-offset > pn){
       for (int i = pn+offset; i < n; i++)
         if (i == n-1 && this.formalParams[i].ParameterType.IsArray && CustomAttribute.IsDefined(this.formalParams[i], typeof(ParamArrayAttribute), true))
           arguments[i] = System.Array.CreateInstance(this.formalParams[i].ParameterType.GetElementType(), 0);
         else
           arguments[i] = Missing.Value;
     }
   }
   if (binder != null)
     return TypeReferences.ToExecutionContext(this.method).Invoke(this.obj, BindingFlags.SuppressChangeType, null, this.ConvertParams(offset, arguments, binder, culture), null);
   else
     return TypeReferences.ToExecutionContext(this.method).Invoke(this.obj, options, binder, arguments, culture);
 }
Пример #29
0
 public static SourceLocalSymbol MakeLocal(
     MethodSymbol containingMethod,
     Binder binder,
     TypeSyntax typeSyntax,
     SyntaxToken identifierToken,
     EqualsValueClauseSyntax initializer,
     LocalDeclarationKind declarationKind)
 {
     Debug.Assert(declarationKind != LocalDeclarationKind.ForEach);
     return new SourceLocalSymbol(containingMethod, binder, typeSyntax, identifierToken, initializer, null, declarationKind);
 }
        /// <summary>
        /// A custom resolver for <see cref="Binder.CustomResolver"/> event.
        /// This resolver contributes unconditionally with a new instance if the required type <paramref name="t"/>        
        /// is <see cref="SomeClass6"/> or <see cref="SomeClass7"/>. 
        /// </summary>
        /// <param name="sender">
        /// The <see cref="Binder"/> that generated the event. The resolver method might need some info 
        /// from the binder to help the instance creation. 
        /// </param>
        /// <param name="t">The <see cref="Type"/> of the instance to be created.</param>
        /// <returns>
        /// An reference to an object on type <paramref name="t"/>, if the method wants to contribute with an instance;
        /// <code>null</code> otherwise.
        /// </returns>
        public static object Resolve(Binder sender, Type t) {
            if (t == typeof(SomeClass6)) {
                return new SomeClass6();
            }

            if (t == typeof(SomeClass7)) {
                return new SomeClass7();
            }

            return null;
        }
Пример #31
0
 protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder,
                                             CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
 {
     throw new NotSupportedException(SR.NotSupported_NonReflectedType);
 }
Пример #32
0
 protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder,
                                                 Type returnType, Type[] types, ParameterModifier[] modifiers)
 {
     throw new NotSupportedException(SR.NotSupported_NonReflectedType);
 }
 public override object ActivatorCreateInstance(
     [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)]
     Type type, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes) => throw new NotSupportedException(SR.Reflection_Disabled);
Пример #34
0
 public override ICompletable Load()
 {
     Binder.Bind(ViewModel.ImageUri, Image, true, 0.3f);
     Binder.Bind(ViewModel.Photographer.Name, PhotographerName);
     return(null);
 }
Пример #35
0
 public abstract object ActivatorCreateInstance(Type type, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes);
Пример #36
0
 public override void SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
 {
     throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
 }
Пример #37
0
 public override void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture)
 {
     throw new NotSupportedException();
 }
            internal override BoundBlock CreateBody(BindingDiagnosticBag diagnostics)
            {
                var syntax      = DummySyntax();
                var compilation = _containingType.DeclaringCompilation;

                // Creates a new top-level binder that just contains the global imports for the compilation.
                // The imports are required if a consumer of the scripting API is using a Task implementation
                // that uses extension methods.
                Binder binder = WithUsingNamespacesAndTypesBinder.Create(compilation.GlobalImports, next: new BuckStopsHereBinder(compilation), withImportChainEntry: true);

                binder = new InContainerBinder(compilation.GlobalNamespace, binder);

                var ctor = _containingType.GetScriptConstructor();

                Debug.Assert(ctor.ParameterCount == 0);

                var initializer = _containingType.GetScriptInitializer();

                Debug.Assert(initializer.ParameterCount == 0);

                var scriptLocal = new BoundLocal(
                    syntax,
                    new SynthesizedLocal(this, TypeWithAnnotations.Create(_containingType), SynthesizedLocalKind.LoweringTemp),
                    null,
                    _containingType)
                {
                    WasCompilerGenerated = true
                };

                Debug.Assert(!initializer.ReturnType.IsDynamic());
                var             initializeCall = CreateParameterlessCall(syntax, scriptLocal, initializer);
                BoundExpression getAwaiterGetResultCall;

                if (!binder.GetAwaitableExpressionInfo(initializeCall, out getAwaiterGetResultCall, syntax, diagnostics))
                {
                    return(new BoundBlock(
                               syntax: syntax,
                               locals: ImmutableArray <LocalSymbol> .Empty,
                               statements: ImmutableArray <BoundStatement> .Empty,
                               hasErrors: true));
                }

                return(new BoundBlock(syntax,
                                      ImmutableArray.Create <LocalSymbol>(scriptLocal.LocalSymbol),
                                      ImmutableArray.Create <BoundStatement>(
                                          // var script = new Script();
                                          new BoundExpressionStatement(
                                              syntax,
                                              new BoundAssignmentOperator(
                                                  syntax,
                                                  scriptLocal,
                                                  new BoundObjectCreationExpression(
                                                      syntax,
                                                      ctor)
                {
                    WasCompilerGenerated = true
                },
                                                  _containingType)
                {
                    WasCompilerGenerated = true
                })
                {
                    WasCompilerGenerated = true
                },
                                          // script.<Initialize>().GetAwaiter().GetResult();
                                          new BoundExpressionStatement(syntax, getAwaiterGetResultCall)
                {
                    WasCompilerGenerated = true
                },
                                          // return;
                                          new BoundReturnStatement(
                                              syntax,
                                              RefKind.None,
                                              null,
                                              @checked: false)
                {
                    WasCompilerGenerated = true
                }))
                {
                    WasCompilerGenerated = true
                });
            }
Пример #39
0
        public static ImmutableArray<ParameterSymbol> MakeParameters(
            Binder binder,
            Symbol owner,
            BaseParameterListSyntax syntax,
            out SyntaxToken arglistToken,
            DiagnosticBag diagnostics,
            bool allowRefOrOut,
            bool allowThis)
        {
            arglistToken = default(SyntaxToken);

            int parameterIndex = 0;
            int firstDefault = -1;

            var builder = ArrayBuilder<ParameterSymbol>.GetInstance();
            var mustBeLastParameter = (ParameterSyntax)null;

            foreach (var parameterSyntax in syntax.Parameters)
            {
                if (mustBeLastParameter == null)
                {
                    if (parameterSyntax.Modifiers.Any(SyntaxKind.ParamsKeyword) ||
                        parameterSyntax.Identifier.Kind() == SyntaxKind.ArgListKeyword)
                    {
                        mustBeLastParameter = parameterSyntax;
                    }
                }

                CheckParameterModifiers(parameterSyntax, diagnostics);

                var refKind = GetModifiers(parameterSyntax.Modifiers,
                    out SyntaxToken outKeyword, out SyntaxToken refKeyword,
                    out SyntaxToken paramsKeyword, out SyntaxToken thisKeyword);

                if (thisKeyword.Kind() != SyntaxKind.None && !allowThis)
                {
                    diagnostics.Add(ErrorCode.ERR_ThisInBadContext, thisKeyword.GetLocation());
                }

                if (parameterSyntax.IsArgList)
                {
                    arglistToken = parameterSyntax.Identifier;
                    // The native compiler produces "Expected type" here, in the parser. Roslyn produces
                    // the somewhat more informative "arglist not valid" error.
                    if (paramsKeyword.Kind() != SyntaxKind.None || outKeyword.Kind() != SyntaxKind.None ||
                        refKeyword.Kind() != SyntaxKind.None || thisKeyword.Kind() != SyntaxKind.None)
                    {
                        // CS1669: __arglist is not valid in this context
                        diagnostics.Add(ErrorCode.ERR_IllegalVarArgs, arglistToken.GetLocation());
                    }
                    continue;
                }

                if (parameterSyntax.Default != null && firstDefault == -1)
                {
                    firstDefault = parameterIndex;
                }

                Debug.Assert(parameterSyntax.Type != null);
                var parameterType = binder.BindType(parameterSyntax.Type, diagnostics);

                if (!allowRefOrOut && (refKind != RefKind.None))
                {
                    var outOrRefKeyword = (outKeyword.Kind() != SyntaxKind.None) ? outKeyword : refKeyword;
                    Debug.Assert(outOrRefKeyword.Kind() != SyntaxKind.None);

                    // error CS0631: ref and out are not valid in this context
                    diagnostics.Add(ErrorCode.ERR_IllegalRefParam, outOrRefKeyword.GetLocation());
                }

                var parameter = SourceParameterSymbol.Create(
                    binder,
                    owner,
                    parameterType,
                    parameterSyntax,
                    refKind,
                    parameterSyntax.Identifier,
                    parameterIndex,
                    (paramsKeyword.Kind() != SyntaxKind.None),
                    parameterIndex == 0 && thisKeyword.Kind() != SyntaxKind.None,
                    diagnostics);

                ReportParameterErrors(owner, parameterSyntax, parameter, firstDefault, diagnostics);

                builder.Add(parameter);
                ++parameterIndex;
            }

            if (mustBeLastParameter != null && mustBeLastParameter != syntax.Parameters.Last())
            {
                diagnostics.Add(
                    mustBeLastParameter.Identifier.Kind() == SyntaxKind.ArgListKeyword
                        ? ErrorCode.ERR_VarargsLast
                        : ErrorCode.ERR_ParamsLast,
                    mustBeLastParameter.GetLocation());
            }

            ImmutableArray<ParameterSymbol> parameters = builder.ToImmutableAndFree();

            var methodOwner = owner as MethodSymbol;
            var typeParameters = (object)methodOwner != null ?
                methodOwner.TypeParameters :
                default(ImmutableArray<TypeParameterSymbol>);

            binder.ValidateParameterNameConflicts(typeParameters, parameters, diagnostics);
            return parameters;
        }
Пример #40
0
        internal static bool ReportDefaultParameterErrors(
            Binder binder,
            Symbol owner,
            ParameterSyntax parameterSyntax,
            SourceParameterSymbol parameter,
            BoundExpression defaultExpression,
            DiagnosticBag diagnostics)
        {
            bool hasErrors = false;

            // SPEC VIOLATION: The spec says that the conversion from the initializer to the 
            // parameter type is required to be either an identity or a nullable conversion, but
            // that is not right:
            //
            // void M(short myShort = 10) {}
            // * not an identity or nullable conversion but should be legal
            //
            // void M(object obj = (dynamic)null) {}
            // * an identity conversion, but should be illegal
            //
            // void M(MyStruct? myStruct = default(MyStruct)) {}
            // * a nullable conversion, but must be illegal because we cannot generate metadata for it
            // 
            // Even if the expression is thoroughly illegal, we still want to bind it and 
            // stick it in the parameter because we want to be able to analyze it for
            // IntelliSense purposes.

            TypeSymbol parameterType = parameter.Type;
            HashSet<DiagnosticInfo> useSiteDiagnostics = null;
            Conversion conversion = binder.Conversions.ClassifyImplicitConversionFromExpression(defaultExpression, parameterType, ref useSiteDiagnostics);
            diagnostics.Add(defaultExpression.Syntax, useSiteDiagnostics);

            SyntaxToken outKeyword;
            SyntaxToken refKeyword;
            SyntaxToken paramsKeyword;
            SyntaxToken thisKeyword;
            GetModifiers(parameterSyntax.Modifiers, out outKeyword, out refKeyword, out paramsKeyword, out thisKeyword);

            // CONSIDER: We are inconsistent here regarding where the error is reported; is it
            // CONSIDER: reported on the parameter name, or on the value of the initializer?
            // CONSIDER: Consider making this consistent.

            if (outKeyword.Kind() == SyntaxKind.OutKeyword)
            {
                // error CS1741: A ref or out parameter cannot have a default value
                diagnostics.Add(ErrorCode.ERR_RefOutDefaultValue, outKeyword.GetLocation());
                hasErrors = true;
            }
            else if (refKeyword.Kind() == SyntaxKind.RefKeyword)
            {
                // error CS1741: A ref or out parameter cannot have a default value
                diagnostics.Add(ErrorCode.ERR_RefOutDefaultValue, refKeyword.GetLocation());
                hasErrors = true;
            }
            else if (paramsKeyword.Kind() == SyntaxKind.ParamsKeyword)
            {
                // error CS1751: Cannot specify a default value for a parameter array
                diagnostics.Add(ErrorCode.ERR_DefaultValueForParamsParameter, paramsKeyword.GetLocation());
                hasErrors = true;
            }
            else if (thisKeyword.Kind() == SyntaxKind.ThisKeyword)
            {
                // Only need to report CS1743 for the first parameter. The caller will
                // have reported CS1100 if 'this' appeared on another parameter.
                if (parameter.Ordinal == 0)
                {
                    // error CS1743: Cannot specify a default value for the 'this' parameter
                    diagnostics.Add(ErrorCode.ERR_DefaultValueForExtensionParameter, thisKeyword.GetLocation());
                    hasErrors = true;
                }
            }
            else if (!defaultExpression.HasAnyErrors && !IsValidDefaultValue(defaultExpression))
            {
                // error CS1736: Default parameter value for '{0}' must be a compile-time constant
                diagnostics.Add(ErrorCode.ERR_DefaultValueMustBeConstant, parameterSyntax.Default.Value.Location, parameterSyntax.Identifier.ValueText);
                hasErrors = true;
            }
            else if (!conversion.Exists ||
                conversion.IsUserDefined ||
                conversion.IsIdentity && parameterType.SpecialType == SpecialType.System_Object && defaultExpression.Type.IsDynamic())
            {
                // If we had no implicit conversion, or a user-defined conversion, report an error.
                //
                // Even though "object x = (dynamic)null" is a legal identity conversion, we do not allow it. 
                // CONSIDER: We could. Doesn't hurt anything.

                // error CS1750: A value of type '{0}' cannot be used as a default parameter because there are no standard conversions to type '{1}'
                diagnostics.Add(ErrorCode.ERR_NoConversionForDefaultParam, parameterSyntax.Identifier.GetLocation(),
                    defaultExpression.Display, parameterType);

                hasErrors = true;
            }
            else if (conversion.IsReference &&
                (parameterType.SpecialType == SpecialType.System_Object || parameterType.Kind == SymbolKind.DynamicType) &&
                (object)defaultExpression.Type != null &&
                defaultExpression.Type.SpecialType == SpecialType.System_String ||
                conversion.IsBoxing)
            {
                // We don't allow object x = "hello", object x = 123, dynamic x = "hello", etc.
                // error CS1763: '{0}' is of type '{1}'. A default parameter value of a reference type other than string can only be initialized with null
                diagnostics.Add(ErrorCode.ERR_NotNullRefDefaultParameter, parameterSyntax.Identifier.GetLocation(),
                    parameterSyntax.Identifier.ValueText, parameterType);

                hasErrors = true;
            }
            else if (conversion.IsNullable && !defaultExpression.Type.IsNullableType() &&
                !(parameterType.GetNullableUnderlyingType().IsEnumType() || parameterType.GetNullableUnderlyingType().IsIntrinsicType()))
            {
                // We can do:
                // M(int? x = default(int)) 
                // M(int? x = default(int?)) 
                // M(MyEnum? e = default(enum))
                // M(MyEnum? e = default(enum?))
                // M(MyStruct? s = default(MyStruct?))
                //
                // but we cannot do:
                //
                // M(MyStruct? s = default(MyStruct))

                // error CS1770: 
                // A value of type '{0}' cannot be used as default parameter for nullable parameter '{1}' because '{0}' is not a simple type
                diagnostics.Add(ErrorCode.ERR_NoConversionForNubDefaultParam, parameterSyntax.Identifier.GetLocation(),
                    defaultExpression.Type, parameterSyntax.Identifier.ValueText);

                hasErrors = true;
            }

            // Certain contexts allow default parameter values syntactically but they are ignored during
            // semantic analysis. They are:

            // 1. Explicitly implemented interface methods; since the method will always be called
            //    via the interface, the defaults declared on the implementation will not 
            //    be seen at the call site.
            //
            // UNDONE: 2. The "actual" side of a partial method; the default values are taken from the
            // UNDONE:    "declaring" side of the method.
            //
            // UNDONE: 3. An indexer with only one formal parameter; it is illegal to omit every argument
            // UNDONE:    to an indexer.
            //
            // 4. A user-defined operator; it is syntactically impossible to omit the argument.

            if (owner.IsExplicitInterfaceImplementation() ||
                owner.IsPartialImplementation() ||
                owner.IsOperator())
            {
                // CS1066: The default value specified for parameter '{0}' will have no effect because it applies to a 
                //         member that is used in contexts that do not allow optional arguments
                diagnostics.Add(ErrorCode.WRN_DefaultValueForUnconsumedLocation,
                    parameterSyntax.Identifier.GetLocation(),
                    parameterSyntax.Identifier.ValueText);
            }

            return hasErrors;
        }
Пример #41
0
    // Token: 0x06000571 RID: 1393 RVA: 0x0002EF94 File Offset: 0x0002D194
    public static void smethod_0(object object_0, JSExtInvokeArgs jsextInvokeArgs_0)
    {
        try
        {
            foreach (KeyValuePair <string, JToken> keyValuePair in JObject.Parse(jsextInvokeArgs_0.Arguments.First <object>().ToString()))
            {
                Class111.Class112 @class = new Class111.Class112();
                @class.jtoken_0 = keyValuePair.Value;
                if (MainWindow.dictionary_0.ContainsKey((int)@class.jtoken_0["id"]))
                {
                    if (Class111.Class114.callSite_0 == null)
                    {
                        Class111.Class114.callSite_0 = CallSite <Func <CallSite, object, Thread> > .Create(Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof(Thread), typeof(Class111)));
                    }
                    if (Class111.Class114.callSite_0.Target(Class111.Class114.callSite_0, MainWindow.dictionary_0[(int)@class.jtoken_0["id"]]["thread"]).IsAlive)
                    {
                        continue;
                    }
                }
                string text = @class.jtoken_0["store"].ToString();
                uint   num  = Class93.smethod_0(text);
                Thread thread;
                if (num <= 1213666813u)
                {
                    if (num <= 834122706u)
                    {
                        if (num <= 156382626u)
                        {
                            if (num <= 72053246u)
                            {
                                if (num != 7379352u)
                                {
                                    if (num != 72053246u)
                                    {
                                        goto IL_780;
                                    }
                                    if (!(text == "Lacoste CA"))
                                    {
                                        goto IL_780;
                                    }
                                    thread = new Thread(new ThreadStart(@class.method_14));
                                }
                                else
                                {
                                    if (!(text == "EastBay "))
                                    {
                                        goto IL_780;
                                    }
                                    thread = new Thread(new ThreadStart(@class.method_20));
                                }
                            }
                            else if (num != 94696313u)
                            {
                                if (num != 156382626u)
                                {
                                    goto IL_780;
                                }
                                if (!(text == "Lacoste FR"))
                                {
                                    goto IL_780;
                                }
                                thread = new Thread(new ThreadStart(@class.method_4));
                            }
                            else
                            {
                                if (!(text == "Size?"))
                                {
                                    goto IL_780;
                                }
                                thread = new Thread(new ThreadStart(@class.method_30));
                            }
                        }
                        else if (num <= 537959913u)
                        {
                            if (num != 356287031u)
                            {
                                if (num != 537959913u)
                                {
                                    goto IL_780;
                                }
                                if (!(text == "Footlocker US "))
                                {
                                    goto IL_780;
                                }
                                thread = new Thread(new ThreadStart(@class.method_17));
                            }
                            else
                            {
                                if (!(text == "Lacoste IT"))
                                {
                                    goto IL_780;
                                }
                                thread = new Thread(new ThreadStart(@class.method_7));
                            }
                        }
                        else if (num != 607951316u)
                        {
                            if (num != 834122706u)
                            {
                                goto IL_780;
                            }
                            if (!(text == "MrPorter"))
                            {
                                goto IL_780;
                            }
                            thread = new Thread(new ThreadStart(@class.method_1));
                        }
                        else
                        {
                            if (!(text == "Lacoste IE"))
                            {
                                goto IL_780;
                            }
                            thread = new Thread(new ThreadStart(@class.method_6));
                        }
                    }
                    else if (num <= 1073939897u)
                    {
                        if (num <= 993983648u)
                        {
                            if (num != 978780147u)
                            {
                                if (num != 993983648u)
                                {
                                    goto IL_780;
                                }
                                if (!(text == "Lacoste NL"))
                                {
                                    goto IL_780;
                                }
                                thread = new Thread(new ThreadStart(@class.method_5));
                            }
                            else
                            {
                                if (!(text == "Lacoste DK"))
                                {
                                    goto IL_780;
                                }
                                thread = new Thread(new ThreadStart(@class.method_8));
                            }
                        }
                        else if (num != 1033461544u)
                        {
                            if (num != 1073939897u)
                            {
                                goto IL_780;
                            }
                            if (!(text == "Footlocker CA "))
                            {
                                goto IL_780;
                            }
                            thread = new Thread(new ThreadStart(@class.method_18));
                        }
                        else
                        {
                            if (!(text == "EastBay"))
                            {
                                goto IL_780;
                            }
                            thread = new Thread(new ThreadStart(@class.method_24));
                        }
                    }
                    else if (num <= 1127660147u)
                    {
                        if (num != 1115811218u)
                        {
                            if (num != 1127660147u)
                            {
                                goto IL_780;
                            }
                            if (!(text == "Lacoste KR"))
                            {
                                goto IL_780;
                            }
                            thread = new Thread(new ThreadStart(@class.method_12));
                        }
                        else
                        {
                            if (!(text == "Lacoste UK"))
                            {
                                goto IL_780;
                            }
                            thread = new Thread(new ThreadStart(@class.method_3));
                        }
                    }
                    else if (num != 1162892671u)
                    {
                        if (num != 1213666813u)
                        {
                            goto IL_780;
                        }
                        if (!(text == "Lacoste DE"))
                        {
                            goto IL_780;
                        }
                        thread = new Thread(new ThreadStart(@class.method_11));
                    }
                    else
                    {
                        if (!(text == "Lacoste AT"))
                        {
                            goto IL_780;
                        }
                        thread = new Thread(new ThreadStart(@class.method_9));
                    }
                }
                else if (num <= 3276705478u)
                {
                    if (num <= 2445159016u)
                    {
                        if (num <= 1494588195u)
                        {
                            if (num != 1258127411u)
                            {
                                if (num != 1494588195u)
                                {
                                    goto IL_780;
                                }
                                if (!(text == "Footlocker CA"))
                                {
                                    goto IL_780;
                                }
                                thread = new Thread(new ThreadStart(@class.method_23));
                            }
                            else
                            {
                                if (!(text == "Footlocker US"))
                                {
                                    goto IL_780;
                                }
                                thread = new Thread(new ThreadStart(@class.method_22));
                            }
                        }
                        else if (num != 1518474074u)
                        {
                            if (num != 2445159016u)
                            {
                                goto IL_780;
                            }
                            if (!(text == "The Hip Store"))
                            {
                                goto IL_780;
                            }
                            thread = new Thread(new ThreadStart(@class.method_28));
                        }
                        else
                        {
                            if (!(text == "Lacoste US"))
                            {
                                goto IL_780;
                            }
                            thread = new Thread(new ThreadStart(@class.method_15));
                        }
                    }
                    else if (num <= 2692391852u)
                    {
                        if (num != 2508713984u)
                        {
                            if (num != 2692391852u)
                            {
                                goto IL_780;
                            }
                            if (!(text == "Supreme"))
                            {
                                goto IL_780;
                            }
                            thread = new Thread(new ThreadStart(@class.method_31));
                        }
                        else
                        {
                            if (!(text == "Champs Sports "))
                            {
                                goto IL_780;
                            }
                            thread = new Thread(new ThreadStart(@class.method_21));
                        }
                    }
                    else if (num != 3138249339u)
                    {
                        if (num != 3276705478u)
                        {
                            goto IL_780;
                        }
                        if (!(text == "Off-White"))
                        {
                            goto IL_780;
                        }
                        thread = new Thread(new ThreadStart(@class.method_0));
                    }
                    else
                    {
                        if (!(text == "Footaction"))
                        {
                            goto IL_780;
                        }
                        thread = new Thread(new ThreadStart(@class.method_26));
                    }
                }
                else if (num <= 3925924200u)
                {
                    if (num <= 3544959638u)
                    {
                        if (num != 3520812353u)
                        {
                            if (num != 3544959638u)
                            {
                                goto IL_780;
                            }
                            if (!(text == "JD Sports"))
                            {
                                goto IL_780;
                            }
                            thread = new Thread(new ThreadStart(@class.method_29));
                        }
                        else
                        {
                            if (!(text == "Footaction "))
                            {
                                goto IL_780;
                            }
                            thread = new Thread(new ThreadStart(@class.method_19));
                        }
                    }
                    else if (num != 3842920480u)
                    {
                        if (num != 3925924200u)
                        {
                            goto IL_780;
                        }
                        if (!(text == "Antonioli"))
                        {
                            goto IL_780;
                        }
                        thread = new Thread(new ThreadStart(@class.method_2));
                    }
                    else
                    {
                        if (!(text == "Champs Sports"))
                        {
                            goto IL_780;
                        }
                        thread = new Thread(new ThreadStart(@class.method_25));
                    }
                }
                else if (num <= 4053610095u)
                {
                    if (num != 4009715463u)
                    {
                        if (num != 4053610095u)
                        {
                            goto IL_780;
                        }
                        if (!(text == "Footlocker EU "))
                        {
                            goto IL_780;
                        }
                        thread = new Thread(new ThreadStart(@class.method_16));
                    }
                    else
                    {
                        if (!(text == "Footpatrol"))
                        {
                            goto IL_780;
                        }
                        thread = new Thread(new ThreadStart(@class.method_27));
                    }
                }
                else if (num != 4249577209u)
                {
                    if (num != 4285839398u)
                    {
                        goto IL_780;
                    }
                    if (!(text == "Lacoste PL"))
                    {
                        goto IL_780;
                    }
                    thread = new Thread(new ThreadStart(@class.method_13));
                }
                else
                {
                    if (!(text == "Lacoste CH"))
                    {
                        goto IL_780;
                    }
                    thread = new Thread(new ThreadStart(@class.method_10));
                }
IL_7A6:
                thread.IsBackground = true;
                Dictionary <int, Dictionary <string, object> > dictionary_ = MainWindow.dictionary_0;
                int key = (int)@class.jtoken_0["id"];
                Dictionary <string, object> dictionary = new Dictionary <string, object>();
                dictionary["thread"] = thread;
                dictionary["stop"]   = false;
                dictionary_[key]     = dictionary;
                thread.Start();
                MainWindow.webView_0.QueueScriptCall(string.Format("updateButton({0},true)", @class.jtoken_0["id"]));
                continue;
IL_780:
                thread = new Thread(new ThreadStart(@class.method_32));
                goto IL_7A6;
            }
        }
        catch
        {
        }
    }
Пример #42
0
        // Token: 0x06000596 RID: 1430 RVA: 0x0002F858 File Offset: 0x0002DA58
        internal void method_0()
        {
            JObject jobject = JObject.Parse(this.jsextInvokeArgs_0.Arguments.First <object>().ToString());

            foreach (KeyValuePair <string, JToken> keyValuePair in jobject)
            {
                JToken value = keyValuePair.Value;
                if (MainWindow.dictionary_0.ContainsKey((int)value["id"]))
                {
                    object arg = MainWindow.dictionary_0[(int)value["id"]]["thread"];
                    if (Class111.Class115.callSite_0 == null)
                    {
                        Class111.Class115.callSite_0 = CallSite <Func <CallSite, object, Thread> > .Create(Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof(Thread), typeof(Class111)));
                    }
                    if (Class111.Class115.callSite_0.Target(Class111.Class115.callSite_0, arg).IsAlive)
                    {
                        MainWindow.dictionary_0[(int)value["id"]]["stop"] = true;
                        MainWindow.webView_0.QueueScriptCall(string.Format("updateTable('Stopping...','DARKORANGE',{0},7)", value["id"]));
                    }
                }
            }
            foreach (KeyValuePair <string, JToken> keyValuePair2 in jobject)
            {
                JToken value2 = keyValuePair2.Value;
                if (MainWindow.dictionary_0.ContainsKey((int)value2["id"]))
                {
                    object arg2 = MainWindow.dictionary_0[(int)value2["id"]]["thread"];
                    if (Class111.Class115.callSite_1 == null)
                    {
                        Class111.Class115.callSite_1 = CallSite <Func <CallSite, object, Thread> > .Create(Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof(Thread), typeof(Class111)));
                    }
                    if (Class111.Class115.callSite_1.Target(Class111.Class115.callSite_1, arg2).IsAlive)
                    {
                        Class30.smethod_1((int)value2["id"], null);
                        if (Class111.Class115.callSite_2 == null)
                        {
                            Class111.Class115.callSite_2 = CallSite <Action <CallSite, object> > .Create(Binder.InvokeMember(CSharpBinderFlags.ResultDiscarded, "Abort", null, typeof(Class111), new CSharpArgumentInfo[]
                            {
                                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
                            }));
                        }
                        Class111.Class115.callSite_2.Target(Class111.Class115.callSite_2, arg2);
                    }
                }
            }
            foreach (KeyValuePair <string, JToken> keyValuePair3 in jobject)
            {
                JToken value3 = keyValuePair3.Value;
                if (MainWindow.dictionary_0.ContainsKey((int)value3["id"]))
                {
                    object arg3 = MainWindow.dictionary_0[(int)value3["id"]]["thread"];
                    if (Class111.Class115.callSite_3 == null)
                    {
                        Class111.Class115.callSite_3 = CallSite <Func <CallSite, object, Thread> > .Create(Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof(Thread), typeof(Class111)));
                    }
                    if (Class111.Class115.callSite_3.Target(Class111.Class115.callSite_3, arg3).IsAlive)
                    {
                        if (Class111.Class115.callSite_4 == null)
                        {
                            Class111.Class115.callSite_4 = CallSite <Action <CallSite, object> > .Create(Binder.InvokeMember(CSharpBinderFlags.ResultDiscarded, "Join", null, typeof(Class111), new CSharpArgumentInfo[]
                            {
                                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
                            }));
                        }
                        Class111.Class115.callSite_4.Target(Class111.Class115.callSite_4, arg3);
                        MainWindow.webView_0.QueueScriptCall(string.Format("updateTable('Stopped','red',{0},7)", value3["id"].ToString()));
                        MainWindow.webView_0.QueueScriptCall(string.Format("updateButton({0},false)", value3["id"].ToString()));
                    }
                    MainWindow.dictionary_0.Remove((int)value3["id"]);
                }
            }
        }
Пример #43
0
        protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
        {
            PropertyInfo property = base.GetPropertyImpl(name, bindingAttr, binder, returnType, types, modifiers);

            bool getIgnoreCase   = (bindingAttr & BindingFlags.IgnoreCase) == BindingFlags.IgnoreCase;
            bool getDeclaredOnly = (bindingAttr & BindingFlags.DeclaredOnly) == BindingFlags.DeclaredOnly;
            bool getInstance     = (bindingAttr & BindingFlags.Instance) == BindingFlags.Instance;
            bool getPublic       = (bindingAttr & BindingFlags.Public) == BindingFlags.Public;

            // If the ReflectionContext adds a property with identical name and type to an existing property,
            // the behavior is unspecified.
            // In this implementation, we return the existing property.
            if (!getPublic || !getInstance)
            {
                return(property);
            }

            // Adding indexer properties is currently not supported.
            if (types != null && types.Length > 0)
            {
                return(property);
            }

            List <PropertyInfo> matchingProperties = new List <PropertyInfo>();

            if (property != null)
            {
                matchingProperties.Add(property);
            }

            // If the ReflectionContext adds two or more properties with the same name and type,
            // the behavior is unspecified.
            // In this implementation, we throw AmbiguousMatchException even if the two properties are
            // defined on different types (base and sub classes).

            StringComparison comparison = getIgnoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;

            CustomType type = this;

            foreach (PropertyInfo newDeclaredProperty in type.NewProperties)
            {
                if (string.Compare(newDeclaredProperty.Name, name, comparison) == 0)
                {
                    matchingProperties.Add(newDeclaredProperty);
                }
            }

            if (!getDeclaredOnly)
            {
                while ((type = type.BaseType as CustomType) != null)
                {
                    foreach (PropertyInfo newBaseProperty in type.NewProperties)
                    {
                        if (string.Compare(newBaseProperty.Name, name, comparison) == 0)
                        {
                            matchingProperties.Add(new InheritedPropertyInfo(newBaseProperty, this));
                        }
                    }
                }
            }

            if (matchingProperties.Count == 0)
            {
                return(null);
            }

            if (binder == null)
            {
                binder = Type.DefaultBinder;
            }

            return(binder.SelectProperty(bindingAttr, matchingProperties.ToArray(), returnType, types, modifiers));
        }
Пример #44
0
 public override object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target,
                                     object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters)
 {
     throw new NotSupportedException(SR.NotSupported_NonReflectedType);
 }
Пример #45
0
 internal GamesystemNamespaceBinder(Binder next, SourceGlobalNamespaceSymbol namespaceSymbol)
     : base(next)
 {
     NamespaceSymbol = namespaceSymbol;
 }
 public static FunctionPointerTypeSymbol CreateFromSource(FunctionPointerTypeSyntax syntax, Binder typeBinder, BindingDiagnosticBag diagnostics, ConsList <TypeSymbol> basesBeingResolved, bool suppressUseSiteDiagnostics)
 => new FunctionPointerTypeSymbol(
     FunctionPointerMethodSymbol.CreateFromSource(
         syntax,
         typeBinder,
         diagnostics,
         basesBeingResolved,
         suppressUseSiteDiagnostics));
Пример #47
0
 internal override void LookupSymbolsInSingleBinder(LookupResult result, string symbolId, LookupOptions options, Binder originalBinder, bool diagnose)
 {
     if (options.CanConsiderCatalogues())
     {
         originalBinder.CheckViability(result, NamespaceSymbol.Catalogues, symbolId, options, diagnose);
     }
 }
        public static async void Run([BlobTrigger("xmlfiles/{name}.xml", Connection = "BLOB_STORAGE")] CloudBlockBlob xmlData, string name, Binder binder, TraceWriter log)
        {
            string node = "ParseNode";

            log.Info($"C# Blob trigger function Processed blob\n Name:{name}\n Node:{node}");

            string path = $"{name}";
            string json = "";

            MemoryStream ms = new MemoryStream();

            await xmlData.DownloadToStreamAsync(ms);

            ms.Seek(0, 0);
            XmlDocument doc = new XmlDocument();

            doc.Load(ms);


            XmlNodeList nodes = doc.SelectNodes("node");

            for (int i = 0; i < nodes.Count; i++)
            {
                json += JsonConvert.SerializeXmlNode(nodes[i], Newtonsoft.Json.Formatting.Indented, true);
            }

            byte[] b = Encoding.UTF8.GetBytes(json);


            /////// Save JSON  ///////////
            var attributes = new System.Attribute[]
            {
                new BlobAttribute($"jsonfiles/{path}.json", FileAccess.Write),
                new StorageAccountAttribute("BLOB_STORAGE")
            };

            using (var stream = await binder.BindAsync <Stream>(attributes))
            {
                stream.Write(b, 0, b.Length);
                stream.Flush();
            }

            await xmlData.DeleteIfExistsAsync();
        }
Пример #49
0
 public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
 {
     // This will not be supported.
     throw new NotSupportedException(Environment.GetResourceString("NotSupported_SymbolMethod"));
 }
 PropertyInfo IReflect.GetProperty(string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
 {
     return(this.typeIReflectImplementation.GetProperty(name, bindingAttr, binder, returnType, types, modifiers));
 }
Пример #51
0
 public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
 {
     throw NotSupported();
 }
 MethodInfo IReflect.GetMethod(string name, BindingFlags bindingAttr, Binder binder, Type[] types, ParameterModifier[] modifiers)
 {
     return(this.typeIReflectImplementation.GetMethod(name, bindingAttr, binder, types, modifiers));
 }
Пример #53
0
 /// <summary>
 /// When overridden in a derived class, sets the value of the field supported by the given object.
 /// </summary>
 /// <param name="obj">The object whose field value will be set.</param>
 /// <param name="value">The value to assign to the field.</param>
 /// <param name="invokeAttr">A field of Binder that specifies the type of binding that is desired (for example, Binder.CreateInstance or Binder.ExactBinding).</param>
 /// <param name="binder">A set of properties that enables the binding, coercion of argument types, and invocation of members through reflection. If <paramref name="binder" /> is null, then Binder.DefaultBinding is used.</param>
 /// <param name="culture">The software preferences of a particular culture.</param>
 public override void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture)
 {
     this.aliasedField.SetValue(obj, value, invokeAttr, binder, culture);
 }
Пример #54
0
 public override object Invoke(BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
 {
     throw not_supported();
 }
Пример #55
0
 internal ExternalDataExchangeBinder()
 {
     defltBinder = Type.DefaultBinder;
 }
Пример #56
0
 internal static void UnsafeSetValue(this FieldInfo fieldInfo, object target, object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture)
 {
     if (value != null && !fieldInfo.FieldType.IsAssignableFrom(value.GetType()))
     {
         if (fieldInfo.DeclaringType.Name == @"Font")
         {
             return;
             //if (value is int intValue)
             //{
             //    ((Font)target).Size = intValue;
             //    return;
             //}
         }
         //if (fieldInfo.FieldType == typeof(System.Collections.Hashtable))
         //{
         //    var newValue = new System.Collections.Hashtable();
         //    foreach (DictionaryEntry kv in ((Ssz.Collections.Hashtable)value))
         //        newValue.Add(kv.Key, kv.Value);
         //    value = newValue;
         //}
     }
     if (fieldInfo.FieldType == typeof(Font))
     {
         value = new Font("Arial", 12);
         //var oldValue = (Font)value;
         //value = new Font(oldValue.FontFamily, oldValue.Size, oldValue.Style);
     }
     try
     {
         fieldInfo.SetValue(target, value, invokeAttr, binder, culture);
     }
     catch (Exception ex)
     {
     }
 }
Пример #57
0
 protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
 {
     return(_typeInfo.GetConstructor(bindingAttr, binder, callConvention, types, modifiers));
 }
Пример #58
0
        internal static void AddDelegateMembers(
            SourceMemberContainerTypeSymbol delegateType,
            ArrayBuilder <Symbol> symbols,
            DelegateDeclarationSyntax syntax,
            DiagnosticBag diagnostics)
        {
            var        compilation = delegateType.DeclaringCompilation;
            Binder     binder      = delegateType.GetBinder(syntax.ParameterList);
            RefKind    refKind;
            TypeSyntax returnTypeSyntax = syntax.ReturnType.SkipRef(out refKind);
            var        returnType       = binder.BindType(returnTypeSyntax, diagnostics);

            // reuse types to avoid reporting duplicate errors if missing:
            var voidType = TypeWithAnnotations.Create(binder.GetSpecialType(SpecialType.System_Void, diagnostics, syntax));
            // https://github.com/dotnet/roslyn/issues/30079: Should the 'object', IAsyncResult and AsyncCallback parameters be considered nullable or not nullable?
            var objectType = TypeWithAnnotations.Create(binder.GetSpecialType(SpecialType.System_Object, diagnostics, syntax));
            var intPtrType = TypeWithAnnotations.Create(binder.GetSpecialType(SpecialType.System_IntPtr, diagnostics, syntax));

            if (returnType.IsRestrictedType(ignoreSpanLikeTypes: true))
            {
                // Method or delegate cannot return type '{0}'
                diagnostics.Add(ErrorCode.ERR_MethodReturnCantBeRefAny, returnTypeSyntax.Location, returnType.Type);
            }

            // A delegate has the following members: (see CLI spec 13.6)
            // (1) a method named Invoke with the specified signature
            var invoke = new InvokeMethod(delegateType, refKind, returnType, syntax, binder, diagnostics);

            invoke.CheckDelegateVarianceSafety(diagnostics);
            symbols.Add(invoke);

            // (2) a constructor with argument types (object, System.IntPtr)
            symbols.Add(new Constructor(delegateType, voidType, objectType, intPtrType, syntax));

            if (binder.Compilation.GetSpecialType(SpecialType.System_IAsyncResult).TypeKind != TypeKind.Error &&
                binder.Compilation.GetSpecialType(SpecialType.System_AsyncCallback).TypeKind != TypeKind.Error &&
                // WinRT delegates don't have Begin/EndInvoke methods
                !delegateType.IsCompilationOutputWinMdObj())
            {
                var iAsyncResultType  = TypeWithAnnotations.Create(binder.GetSpecialType(SpecialType.System_IAsyncResult, diagnostics, syntax));
                var asyncCallbackType = TypeWithAnnotations.Create(binder.GetSpecialType(SpecialType.System_AsyncCallback, diagnostics, syntax));

                // (3) BeginInvoke
                symbols.Add(new BeginInvokeMethod(invoke, iAsyncResultType, objectType, asyncCallbackType, syntax));

                // and (4) EndInvoke methods
                symbols.Add(new EndInvokeMethod(invoke, iAsyncResultType, syntax));
            }

            if (delegateType.DeclaredAccessibility <= Accessibility.Private)
            {
                return;
            }

            HashSet <DiagnosticInfo> useSiteDiagnostics = null;

            if (!delegateType.IsNoMoreVisibleThan(invoke.ReturnTypeWithAnnotations, ref useSiteDiagnostics))
            {
                // Inconsistent accessibility: return type '{1}' is less accessible than delegate '{0}'
                diagnostics.Add(ErrorCode.ERR_BadVisDelegateReturn, delegateType.Locations[0], delegateType, invoke.ReturnType);
            }

            foreach (var parameter in invoke.Parameters)
            {
                if (!parameter.TypeWithAnnotations.IsAtLeastAsVisibleAs(delegateType, ref useSiteDiagnostics))
                {
                    // Inconsistent accessibility: parameter type '{1}' is less accessible than delegate '{0}'
                    diagnostics.Add(ErrorCode.ERR_BadVisDelegateParam, delegateType.Locations[0], delegateType, parameter.Type);
                }
            }

            diagnostics.Add(delegateType.Locations[0], useSiteDiagnostics);
        }
Пример #59
0
        public override void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture)
        {
            var indexCnt = index != null ? index.Length : 0;

            if (setter.ParameterCount <= indexCnt + 1)
            {
                using (var ctx = appdomain.BeginInvoke(setter))
                {
                    if (!IsStatic)
                    {
                        ctx.PushObject(obj);
                    }
                    for (int i = 0; i < setter.ParameterCount - 1; i++)
                    {
                        ctx.PushObject(index[i], !setter.Parameters[i].IsValueType);
                    }
                    ctx.PushObject(value, !setter.Parameters[setter.ParameterCount - 1].IsValueType);
                    ctx.Invoke();
                }
            }
            else
            {
                throw new ArgumentException("Index count mismatch");
            }
        }
Пример #60
0
        protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
        {
            MethodInfo method = base.GetMethodImpl(name, bindingAttr, binder, callConvention, types, modifiers);

            bool getIgnoreCase   = (bindingAttr & BindingFlags.IgnoreCase) == BindingFlags.IgnoreCase;
            bool getDeclaredOnly = (bindingAttr & BindingFlags.DeclaredOnly) == BindingFlags.DeclaredOnly;
            bool getInstance     = (bindingAttr & BindingFlags.Instance) == BindingFlags.Instance;
            bool getPublic       = (bindingAttr & BindingFlags.Public) == BindingFlags.Public;

            // If the ReflectionContext adds a property with identical name and type to an existing property,
            // the behavior is unspecified.
            // In this implementation, we return the existing method.
            if (!getPublic || !getInstance)
            {
                return(method);
            }

            bool getPropertyGetter = false;
            bool getPropertySetter = false;

            StringComparison comparison = getIgnoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;

            if (name.Length > 4)
            {
                // Right now we don't support adding fabricated indexers on types
                string prefix = name.Substring(0, 4);
                getPropertyGetter = (types == null || types.Length == 0) && name.StartsWith("get_", comparison);

                if (!getPropertyGetter)
                {
                    getPropertySetter = (types == null || types.Length == 1) && name.StartsWith("set_", comparison);
                }
            }

            // not a property getter or setter
            if (!getPropertyGetter && !getPropertySetter)
            {
                return(method);
            }

            // get the target property name by removing "get_" or "set_"
            string targetPropertyName = name.Substring(4);

            List <MethodInfo> matchingMethods = new List <MethodInfo>();

            if (method != null)
            {
                matchingMethods.Add(method);
            }

            // in runtime reflection hidden methods are always returned in GetMethods
            foreach (PropertyInfo newDeclaredProperty in NewProperties)
            {
                if (string.Compare(newDeclaredProperty.Name, targetPropertyName, comparison) == 0)
                {
                    MethodInfo accessor = getPropertyGetter ? newDeclaredProperty.GetGetMethod() : newDeclaredProperty.GetSetMethod();
                    if (accessor != null)
                    {
                        matchingMethods.Add(accessor);
                    }
                }
            }

            // adding new methods declared on base types
            if (!getDeclaredOnly)
            {
                CustomType baseType = BaseType as CustomType;

                while (baseType != null)
                {
                    // We shouldn't add a base type method directly on a subtype.
                    // A new method with a different ReflectedType should be used.
                    foreach (PropertyInfo newBaseProperty in baseType.NewProperties)
                    {
                        if (string.Compare(newBaseProperty.Name, targetPropertyName, comparison) == 0)
                        {
                            PropertyInfo inheritedProperty = new InheritedPropertyInfo(newBaseProperty, this);

                            MethodInfo accessor = getPropertyGetter ? inheritedProperty.GetGetMethod() : inheritedProperty.GetSetMethod();
                            if (accessor != null)
                            {
                                matchingMethods.Add(accessor);
                            }
                        }
                    }

                    baseType = baseType.BaseType as CustomType;
                }
            }


            if (matchingMethods.Count == 0)
            {
                return(null);
            }

            if (types == null || getPropertyGetter)
            {
                Debug.Assert(types == null || types.Length == 0);

                // matches any signature
                if (matchingMethods.Count == 1)
                {
                    return(matchingMethods[0]);
                }
                else
                {
                    throw new AmbiguousMatchException();
                }
            }
            else
            {
                Debug.Assert(getPropertySetter && types != null && types.Length == 1);

                if (binder == null)
                {
                    binder = Type.DefaultBinder;
                }

                return((MethodInfo)binder.SelectMethod(bindingAttr, matchingMethods.ToArray(), types, modifiers));
            }
        }