Exemple #1
0
		/////////////////////////////////////////////////////////////////////////////
		
		//public static TypeHelperDictionary	TypeHelpers	{ get { return ThreadContext.TypeHelpers; } }


		/////////////////////////////////////////////////////////////////////////////

		public static Invoker GetMethodInvoker( object parent, string methodName, TypeHelperDictionary typeHelpers )
		{
			// ******
			var objInfo = new ObjectInfo( parent, methodName );
			if( objInfo.IsMethod ) {
				return new MethodInvoker( objInfo );
			}

			// ******
			INmpDynamic dyn = parent as INmpDynamic;
			if( null != dyn ) {
				if( dyn.HasMethod(methodName) ) {
					return new DynamicMethodInvoker( parent, methodName );
				}
			}

			// ******
			object standin = typeHelpers.GetHelper( parent );
			if( null != standin ) {
				objInfo = new ObjectInfo( standin, methodName );
				if( objInfo.IsMethod ) {
					return new MethodInvoker( objInfo );
				}
			}

			// ******
			return null;
		}
Exemple #2
0
		/////////////////////////////////////////////////////////////////////////////

		public static Invoker GetIndexerInvoker( object parent, string indexerName, TypeHelperDictionary typeHelpers )
		{
			// ******
			var objInfo = new ObjectInfo( parent, indexerName );
			if( objInfo.IsIndexer ) {
				return new IndexerInvoker( objInfo );
			}

			// ******
			INmpDynamic dyn = parent as INmpDynamic;
			if( null != dyn && dyn.HasIndexer(indexerName) ) {
				return new DynamicIndexerInvoker( parent, indexerName);
			}

			// ******
			object standin = typeHelpers.GetHelper( parent );
			if( null != standin ) {
				objInfo = new ObjectInfo( standin, indexerName );
				if( objInfo.IsIndexer ) {
					return new IndexerInvoker( objInfo );
				}
			}

			// ******
			return null;
		}
Exemple #3
0
		/////////////////////////////////////////////////////////////////////////////

		public static object EvalMemberHelper( object parent, string memberName, TypeHelperDictionary typeHelpers )
		{
			// ******
			object value;

			// ******
			var oo = new ObjectInfo( parent, memberName );
			if( null != (value = oo.GetValue()) ) {
				return value;
			}

			// ******
			INmpDynamic dyn = parent as INmpDynamic;
			if( null != dyn ) {
				NmpDynamicType dynType = dyn.HasMember( memberName );

				switch( dynType ) {
					case NmpDynamicType.None:
						break;

					case NmpDynamicType.Property:
						return DynamicPropertyInvoker.Invoke( parent, memberName );

					case NmpDynamicType.Indexer:
						return new DynamicIndexerInvoker( parent, memberName );

					case NmpDynamicType.Method:
						return new DynamicMethodInvoker( parent, memberName );
				}
			}

			// ******
			object standin = typeHelpers.GetHelper( parent );
			if( null != standin ) {
				oo = new ObjectInfo( standin, memberName );
				if( null != (value = oo.GetValue()) ) {
					return value;
				}
			}

			// ******
			return null;
		}