///<summary> ///Appends the standard naming context for evaluating an OGNL expression ///into the context given so that cached maps can be used as a context. ///</summary> ///<param name="root"> the root of the object graph</param> ///<param name="context"> the context to which OGNL context will be added.</param> ///<returns> ///a new IDictionary with the keys <c>root</c> and <c>context</c> ///set appropriately ///</returns> public static IDictionary addDefaultContext(object root, ClassResolver classResolver, TypeConverter converter, MemberAccess memberAccess, IDictionary context) { OgnlContext result; if (!(context is OgnlContext)) { result = new OgnlContext(); result.setValues(context); } else { result = (OgnlContext)context; } if (classResolver != null) { result.setClassResolver(classResolver); } if (converter != null) { result.setTypeConverter(converter); } if (memberAccess != null) { result.setMemberAccess(memberAccess); } result.setRoot(root); return(result); }
public void ResolveMultipleWithType() { var result = ClassResolver.Resolve <OneOfMultipleClassResolverTargets>("OneOfMultiple"); Assert.AreEqual(result.Count(), 1); Assert.IsTrue(result.First().GetType().IsAssignableFrom(typeof(OneOfMultipleClassResolverTargets))); }
public void ResolvePrivateClass() { var result = ClassResolver.Resolve("PrivateClassToResolve"); Assert.AreEqual(result.Count(), 1); Assert.IsTrue(result.First().IsAssignableFrom(typeof(PrivateClassResolverTarget))); }
public void setClassResolver(ClassResolver value) { if (value == null) { throw new ArgumentException("cannot set ClassResolver to null"); } classResolver = value; }
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 void ResolveMultipleClasses() { var result = ClassResolver.Resolve("OneOfMultiple"); Assert.AreEqual(result.Count(), 2); Assert.IsTrue(result.Any(q => q.IsAssignableFrom(typeof(OneOfMultipleClassResolverTargets)))); Assert.IsTrue(result.Any(q => q.IsAssignableFrom(typeof(TwoOfMultipleClassResolverTargets)))); }
///<summary> /// Constructs a new OgnlContext with the given class resolver, type converter and /// member access. If any of these parameters is null the default will be used. /// </summary> /// public OgnlContext(ClassResolver classResolver, TypeConverter typeConverter, MemberAccess memberAccess) { if (classResolver != null) { this.classResolver = classResolver; } if (typeConverter != null) { this.typeConverter = typeConverter; } if (memberAccess != null) { this.memberAccess = memberAccess; } }
//Try to modify static void TestWriter() { using (new CS(new CodeWriter(File.CreateText("TestWriter.txt")))) { CS.Writer.Start("Test"); CS.Writer.WriteLine("1"); CS.Writer.WriteLine("3"); CS.Writer.WritePreviousLine("2"); CS.Writer.CreateLinePoint("//aa"); CS.Writer.WriteLine("4"); var writer2 = new CodeWriter(File.CreateText("TestWriter2.txt")); using (new CS(writer2)) { CS.Writer.WriteLine("write Test2 file.."); } CS.Writer.WriteLine("5"); using (new LP(CS.Writer.GetLinePoint("//aa"))) { CS.Writer.Start("LinePointTest"); CS.Writer.WriteLine("aa 1"); CS.Writer.WriteLine("aa 2"); var resolverRes = new ClassResolver(null).Box("testObj"); CS.Writer.WriteLine($"return {resolverRes}"); CS.Writer.End(); } CS.Writer.WriteLine("6"); var cResolverRes = new Generater.C.StringResolver(null, false).Box("testStr"); CS.Writer.WriteLine($"return {cResolverRes}"); CS.Writer.End(); using (new CS(writer2)) { CS.Writer.WriteLine("write Test2 file once more...", false); } } }
public Injector createInjector(GuiceModule module) { var hashMap = new BindingHashMap(); var binder = new Binder(hashMap); var loader = new SynchronousClassLoader(new XMLHttpRequest(), "generated/"); var classResolver = new ClassResolver(loader); if (module != null) { module.configure(binder); } var injector = new Injector(binder, classResolver); binder.bind(typeof(Injector)).toInstance(injector); binder.bind(typeof(ClassResolver)).toInstance(classResolver); binder.bind(typeof(SynchronousClassLoader)).toInstance(loader); return(injector); }
public HelpersClassResolver(ClassResolver underlyingResolver) { UnderlyingResolver = underlyingResolver; }
public void ResolveClassWhichDoesNotExist() { var result = ClassResolver.Resolve("de625b81-7659-4d69-89d0-2c1089b0be39"); Assert.IsTrue(!result.Any()); }
public Injector(Binder binder, ClassResolver classResolver) { this.binder = binder; this.classResolver = classResolver; }
///<summary> ///Creates and returns a new standard naming context for evaluating an OGNL ///expression. ///</summary> ///<param name="root">the root of the object graph</param> ///<returns> ///a new IDictionary with the keys <c>root</c> and <c>context</c> ///set appropriately ///</returns> /// public static IDictionary createDefaultContext(object root, ClassResolver classResolver, TypeConverter converter, MemberAccess memberAccess) { return(addDefaultContext(root, classResolver, converter, memberAccess, new OgnlContext())); }
/// <summary> /// Sets the class resolver, which the stream will use when attempting to unmarshal /// a value or exception. If the stream was initialized with a communicator, the communicator's /// resolver will be used by default. /// </summary> /// <param name="r">The class resolver.</param> public void setClassResolver(ClassResolver r) { _classResolver = r; }
/* * This was always a bad idea... i have simply finally talked myself out of it * [JsMethod(NativeParams=false)] * public object buildClass(JsString className, params object[] list) { * object instance; * TypeDefinition typeDefinition = classResolver.resolveClassName( className ); * * //this feels like it needs to be refactored * instance = typeDefinition.constructorApply(list); * injector.injectMembers(instance); * * return instance; * }*/ public InjectionClassBuilder(Injector injector, ClassResolver classResolver) { this.injector = injector; this.classResolver = classResolver; }
/// <summary> /// Swaps the contents of one stream with another. /// </summary> /// <param name="other">The other stream.</param> public void swap(InputStream other) { Debug.Assert(instance_ == other.instance_); IceInternal.Buffer tmpBuf = other._buf; other._buf = _buf; _buf = tmpBuf; EncodingVersion tmpEncoding = other._encoding; other._encoding = _encoding; _encoding = tmpEncoding; bool tmpTraceSlicing = other._traceSlicing; other._traceSlicing = _traceSlicing; _traceSlicing = tmpTraceSlicing; object tmpClosure = other._closure; other._closure = _closure; _closure = tmpClosure; bool tmpSliceValues = other._sliceValues; other._sliceValues = _sliceValues; _sliceValues = tmpSliceValues; // // Swap is never called for InputStreams that have encapsulations being read. However, // encapsulations might still be set in case un-marshalling failed. We just // reset the encapsulations if there are still some set. // resetEncapsulation(); other.resetEncapsulation(); int tmpStartSeq = other._startSeq; other._startSeq = _startSeq; _startSeq = tmpStartSeq; int tmpMinSeqSize = other._minSeqSize; other._minSeqSize = _minSeqSize; _minSeqSize = tmpMinSeqSize; ValueFactoryManager tmpVfm = other._valueFactoryManager; other._valueFactoryManager = _valueFactoryManager; _valueFactoryManager = tmpVfm; Logger tmpLogger = other._logger; other._logger = _logger; _logger = tmpLogger; CompactIdResolver tmpCompactIdResolver = other._compactIdResolver; other._compactIdResolver = _compactIdResolver; _compactIdResolver = tmpCompactIdResolver; ClassResolver tmpClassResolver = other._classResolver; other._classResolver = _classResolver; _classResolver = tmpClassResolver; }
public OgnlContext(ClassResolver classResolver, TypeConverter typeConverter, MemberAccess memberAccess, IDictionary values) : this(classResolver, typeConverter, memberAccess) { this.values = values; }
private void initialize(IceInternal.Instance instance, EncodingVersion encoding) { initialize(encoding); instance_ = instance; _traceSlicing = instance_.traceLevels().slicing > 0; _valueFactoryManager = instance_.initializationData().valueFactoryManager; _logger = instance_.initializationData().logger; _classResolver = instance_.resolveClass; }
///<summary> ///Creates and returns a new standard naming context for evaluating an OGNL ///expression. ///</summary> ///<param name="root">the root of the object graph</param> ///<returns> ///a new IDictionary with the keys <c>root</c> and <c>context</c> ///set appropriately ///</returns> /// public static IDictionary createDefaultContext(object root, ClassResolver classResolver, TypeConverter converter) { return(addDefaultContext(root, classResolver, converter, null, new OgnlContext())); }
internal EncapsDecoder(InputStream stream, Encaps encaps, bool sliceValues, ValueFactoryManager f, ClassResolver cr) { _stream = stream; _encaps = encaps; _sliceValues = sliceValues; _valueFactoryManager = f; _classResolver = cr; _typeIdIndex = 0; _unmarshaledMap = new Dictionary<int, Ice.Object>(); }
///<summary> ///Appends the standard naming context for evaluating an OGNL expression ///into the context given so that cached maps can be used as a context. ///</summary> ///<param name="root"> the root of the object graph</param> ///<param name="context"> the context to which OGNL context will be added.</param> ///<returns> ///a new IDictionary with the keys <c>root</c> and <c>context</c> ///set appropriately ///</returns> public static IDictionary addDefaultContext(object root, ClassResolver classResolver, TypeConverter converter, IDictionary context) { return(addDefaultContext(root, classResolver, converter, null, context)); }
internal EncapsDecoder10(InputStream stream, Encaps encaps, bool sliceValues, ValueFactoryManager f, ClassResolver cr) : base(stream, encaps, sliceValues, f, cr) { _sliceType = SliceType.NoSlice; }
public static void setClassResolver(IDictionary context, ClassResolver classResolver) { context [OgnlContext.CLASS_RESOLVER_CONTEXT_KEY] = classResolver; }
private int _valueIdIndex; // The ID of the next instance to unmarshal. #endregion Fields #region Constructors internal EncapsDecoder11(InputStream stream, Encaps encaps, bool sliceValues, ValueFactoryManager f, ClassResolver cr, CompactIdResolver r) : base(stream, encaps, sliceValues, f, cr) { _compactIdResolver = r; _current = null; _valueIdIndex = 1; }
public DomExtensionFactory(ContentLoader contentLoader, ClassResolver classResolver, ExternalBehaviorFactory externalBehaviorFactory) { this.contentLoader = contentLoader; this.classResolver = classResolver; this.externalBehaviorFactory = externalBehaviorFactory; }
public HelpersClassResolver(ClassResolver underlyingResolver) { UnderlyingResolver = underlyingResolver; }