Пример #1
0
        public void runRules(String[] rules, java.lang.Object[] facts)
        {
            KnowledgeBase    kbase    = KnowledgeBaseFactory.newKnowledgeBase();
            KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

            for (int i = 0; i < rules.Length; i++)
            {
                String ruleFile = rules[i];
                Console.WriteLine("Loading file: " + ruleFile);
                ruleFile = Path.GetFullPath(Path.Combine("rules", ruleFile));
                kbuilder.add(ResourceFactory.newFileResource(ruleFile), ResourceType.DRL);
            }

            java.util.Collection pkgs = kbuilder.getKnowledgePackages();
            kbase.addKnowledgePackages(pkgs);
            StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

            for (int i = 0; i < facts.Length; i++)
            {
                java.lang.Object fact = facts[i];
                //Console.WriteLine("Inserting fact: " + fact);
                ksession.insert(fact);
            }



            ksession.fireAllRules();
        }
Пример #2
0
        public java.lang.Object lookup(java.lang.Object par0)
        {
            if (par0 is java.lang.String)
            {
                if (null != contextVal)
                {
                    foreach (Variable v in contextVal.getMembers(session))
                    {
                        if (v.getName().Equals(par0))
                        {
                            return((java.lang.Object)v);
                        }
                    }
                    throw new NoSuchVariableException(par0);
                }

                if ((java.lang.String)par0 == "this")
                {
                    return((java.lang.Object)frame.getThis(session));
                }
                foreach (Variable v in frame.getArguments(session))
                {
                    if (v.getName().Equals(par0))
                    {
                        return((java.lang.Object)v);
                    }
                }
                foreach (Variable v in frame.getLocals(session))
                {
                    if (v.getName().Equals(par0))
                    {
                        return((java.lang.Object)v);
                    }
                }
                foreach (Variable v in frame.getThis(session).getValue().getMembers(session))
                {
                    if (v.getName().Equals(par0))
                    {
                        return((java.lang.Object)v);
                    }
                }
                foreach (Variable scope in frame.getScopeChain(session))
                {
                    foreach (Variable v in scope.getValue().getMembers(session))
                    {
                        if (v.getName().Equals(par0))
                        {
                            return((java.lang.Object)v);
                        }
                    }
                }
                var fullClassName = findClassName((java.lang.String)par0);
                if (null != fullClassName)
                {
                    return((java.lang.Object)session.getGlobal(new java.lang.String(fullClassName)));
                }
            }
            throw new NoSuchVariableException(par0);
            //Value_.UNDEFINED;
        }
Пример #3
0
        public Object lookup(Object par0)
        {
            if (par0 is String)
            {
                if (null != contextVal)
                {
                    foreach (Variable v in contextVal.getMembers(session))
                    {
                        if (v.getName().Equals(par0))
                        {
                            return((Object)v);
                        }
                    }
                    throw new NoSuchVariableException(System.String.Format(TextHelper.GetString("Error.NoSuchVariable"), par0));
                }

                if ((String)par0 == "this")
                {
                    return((Object)frame.getThis(session));
                }
                foreach (Variable v in frame.getArguments(session))
                {
                    if (v.getName().Equals(par0))
                    {
                        return((Object)v);
                    }
                }
                foreach (Variable v in frame.getLocals(session))
                {
                    if (v.getName().Equals(par0))
                    {
                        return((Object)v);
                    }
                }
                foreach (Variable v in frame.getThis(session).getValue().getMembers(session))
                {
                    if (v.getName().Equals(par0))
                    {
                        return((Object)v);
                    }
                }
                foreach (Variable scope in frame.getScopeChain(session))
                {
                    foreach (Variable v in scope.getValue().getMembers(session))
                    {
                        if (v.getName().Equals(par0))
                        {
                            return((Object)v);
                        }
                    }
                }
                var fullClassName = findClassName((String)par0);
                if (null != fullClassName)
                {
                    return((Object)session.getGlobal(new String(fullClassName)));
                }
            }
            throw new NoSuchVariableException(System.String.Format(TextHelper.GetString("Error.NoSuchVariable"), par0));
            //Value_.UNDEFINED;
        }
 public IHostingRobotProxy createRobotProxy(IHostManager hostManager, Object robotSpecification, IRobotStatics statics, IRobotPeer peer)
 {
     Object s = HiddenAccess.getFileSpecification(robotSpecification);
     var itemSpecification = Bridge.Cast<IRobotItem>(s);
     string file = DllRootHelper.GetDllFileName(itemSpecification);
     HostingShell hostingShell = new HostingShell(itemSpecification, hostManager, peer, statics, file);
     return hostingShell;
 }
Пример #5
0
		public sealed override bool equals(java.lang.Object arg0) 
		{
			global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv;
			if (!IsClrObject)
				return @__env.CallBooleanMethod(this.JvmHandle, global::java.net.NetworkInterface._equals13703, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0));
			else
				return @__env.CallNonVirtualBooleanMethod(this.JvmHandle, global::java.net.NetworkInterface.staticClass, global::java.net.NetworkInterface._equals13703, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0));
		}
Пример #6
0
			public virtual global::android.database.MatrixCursor.RowBuilder add(java.lang.Object arg0) 
			{
				global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv;
				if (!IsClrObject)
					return global::MonoJavaBridge.JavaBridge.WrapJavaObject(@__env.CallObjectMethod(this.JvmHandle, global::android.database.MatrixCursor.RowBuilder._add2746, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0))) as android.database.MatrixCursor.RowBuilder;
				else
					return global::MonoJavaBridge.JavaBridge.WrapJavaObject(@__env.CallNonVirtualObjectMethod(this.JvmHandle, global::android.database.MatrixCursor.RowBuilder.staticClass, global::android.database.MatrixCursor.RowBuilder._add2746, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0))) as android.database.MatrixCursor.RowBuilder;
			}
Пример #7
0
 public static System.Type GetType(java.lang.Object obj)
 {
     if (obj is IGenericObject genericObject)
     {
         return(genericObject.GetType());
     }
     return(system.RuntimeType.GetType(obj.getClass()));
 }
Пример #8
0
 public IHostingRobotProxy createRobotProxy(IHostManager hostManager, Object robotSpecification, IRobotStatics statics, IRobotPeer peer)
 {
     Object s = HiddenAccess.getFileSpecification(robotSpecification);
     var itemSpecification = Bridge.Cast<IRobotRepositoryItem>(s);
     string file = DllRootHelper.GetDllFileName(itemSpecification);
     HostingShell hostingShell = new HostingShell(itemSpecification, hostManager, peer, statics, file);
     return hostingShell;
 }
 /// <summary>Handle a JMX notification</summary>
 /// <param name="notification">the notification object received from the Java side</param>
 public virtual void HandleNotification(java.lang.Object notification)
 {
     if (verbose)
     {
         WriteEvent(notification as Notification, handback);
     }
     listener.HandleNotification(notification as Notification, handback);
 }
Пример #10
0
 /// <summary>
 /// Attempts to establish connection to a phoenix server.
 /// Setups .NET-Java bridge before connect to a server.
 /// </summary>
 public void Connect()
 {
     PlatformBridge.Setup();
     _connection = DriverReflection.GetConnection().invoke(null, new Object[]
     {
         JNIEnv.ThreadEnv.NewString(_url)
     });
 }
Пример #11
0
 public Context createContext(Object par0)
 {
     Value val;
     if (par0 is Variable) val = ((Variable)par0).getValue();
     else if (par0 is Value) val = (Value)par0;
     else if (par0 is String) val = DValue.forPrimitive(par0, getIsolateId());
     else throw new NotImplementedException();
     return new ExpressionContext(session, frame, val);
 }
        /// <summary>Job updated notification</summary>
        /// <param name="jobEvent">encapsulates information about the event and related job components</param>
        public virtual void JobUpdated(java.lang.Object jobEvent)
        {
            JobMonitoringEvent e = jobEvent as JobMonitoringEvent;

            if (verbose)
            {
                WriteEvent(e, "job updated");
            }
            listener.JobUpdated(e);
        }
        /// <summary>Driver added notification</summary>
        /// <param name="jobEvent">encapsulates information about the event and related job components</param>
        public virtual void DriverAdded(java.lang.Object jobEvent)
        {
            JobMonitoringEvent e = jobEvent as JobMonitoringEvent;

            if (verbose)
            {
                WriteEvent(e, "driver added");
            }
            listener.DriverAdded(e);
        }
        /// <summary>Job dispatch removed notification</summary>
        /// <param name="jobEvent">encapsulates information about the event and related job components</param>
        public virtual void JobDispatchRemoved(java.lang.Object jobEvent)
        {
            JobMonitoringEvent e = jobEvent as JobMonitoringEvent;

            if (verbose)
            {
                WriteEvent(e, "job dispatch removed");
            }
            listener.JobDispatchRemoved(e);
        }
Пример #15
0
        /// <summary>Job dispatched notification</summary>
        /// <param name="jobEvent">encapsulates the job and the tasks that were disptached of whose results have been received</param>
        public virtual void JobDispatched(java.lang.Object jobEvent)
        {
            JobEvent e = jobEvent as JobEvent;

            if (verbose)
            {
                WriteEvent(e, "dispatched");
            }
            listener.JobDispatched(e as JobEvent);
        }
Пример #16
0
        /// <summary>Job started notification</summary>
        /// <param name="jobEvent">encapsulates the job and the tasks that were disptached of whose results have been received</param>
        public virtual void JobEnded(java.lang.Object jobEvent)
        {
            JobEvent e = jobEvent as JobEvent;

            if (verbose)
            {
                WriteEvent(e, "ended");
            }
            listener.JobEnded(e);
        }
Пример #17
0
        /// <summary>Node updated notification</summary>
        /// <param name="jobEvent">encapsulates information about the event and related topology components</param>
        public virtual void NodeUpdated(java.lang.Object topologyEvent)
        {
            TopologyEvent e = topologyEvent as TopologyEvent;

            if (verbose)
            {
                WriteEvent(e, "node updated");
            }
            listener.NodeUpdated(e);
        }
Пример #18
0
        /// <summary>Driver added notification</summary>
        /// <param name="jobEvent">encapsulates information about the event and related topology components</param>
        public virtual void DriverAdded(java.lang.Object topologyEvent)
        {
            TopologyEvent e = topologyEvent as TopologyEvent;

            if (verbose)
            {
                WriteEvent(e, "driver added");
            }
            listener.DriverAdded(e);
        }
Пример #19
0
        public void DelegateCallback()
        {
            tested.TestDelegate td = TestDelegateImpl;
            Object del             = Bridge.WrapCLR(td);

            Assert.IsNotNull(del);

            object res = del.Invoke <object>("Invoke", "(ILjava/lang/String;)Lsystem/Object;", 1, "ahoj");

            Assert.AreEqual("ahoj1", res);
        }
Пример #20
0
 // full assertion with CDuration
 public void assertCDuration(java.lang.Object obj, String value, org.openehr.rm.support.basic.Interval interval,
                             String assumed, String pattern)
 {
     org.openehr.am.archetype.constraintmodel.primitive.CDuration c = (org.openehr.am.archetype.constraintmodel.primitive.CDuration)((org.openehr.am.archetype.constraintmodel.CPrimitiveObject)obj).getItem();
     Assert.AreEqual(value == null ? null : org.openehr.rm.datatypes.quantity.datetime.DvDuration.getInstance(value),
                     c.getValue(), "list");
     Assert.AreEqual(interval, c.getInterval(), "interval");
     Assert.AreEqual(assumed == null? null
                                     : org.openehr.rm.datatypes.quantity.datetime.DvDuration.getInstance(assumed), c.assumedValue(), "assumed value");
     Assert.AreEqual(pattern, c.getPattern(), "pattern wrong");
 }
Пример #21
0
 public void assign(java.lang.Object par0, Value par1)
 {
     java.lang.Object obj = lookup(par0);
     if (obj is Variable)
     {
         Variable var = (Variable)obj;
         var.setValue(session, par1.getType(), par1.getValueAsString());
         return;
     }
     throw new NotImplementedException();
 }
Пример #22
0
 public virtual int compareTo(java.lang.Object arg0)
 {
     global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv;
     if (!IsClrObject)
     {
         return(@__env.CallIntMethod(this.JvmHandle, global::java.nio.CharBuffer._compareTo14119, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)));
     }
     else
     {
         return(@__env.CallNonVirtualIntMethod(this.JvmHandle, global::java.nio.CharBuffer.staticClass, global::java.nio.CharBuffer._compareTo14119, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)));
     }
 }
Пример #23
0
 public override void setOption(int arg0, java.lang.Object arg1)
 {
     global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv;
     if (!IsClrObject)
     {
         @__env.CallVoidMethod(this.JvmHandle, global::java.net.DatagramSocketImpl_._setOption13661, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1));
     }
     else
     {
         @__env.CallNonVirtualVoidMethod(this.JvmHandle, global::java.net.DatagramSocketImpl_.staticClass, global::java.net.DatagramSocketImpl_._setOption13661, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1));
     }
 }
Пример #24
0
 public override bool equals(java.lang.Object arg0)
 {
     global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv;
     if (!IsClrObject)
     {
         return(@__env.CallBooleanMethod(this.JvmHandle, global::android.content.IntentSender._equals1719, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)));
     }
     else
     {
         return(@__env.CallNonVirtualBooleanMethod(this.JvmHandle, global::android.content.IntentSender.staticClass, global::android.content.IntentSender._equals1719, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)));
     }
 }
Пример #25
0
 bool java.lang.annotation.Annotation.equals(java.lang.Object arg0)
 {
     global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv;
     if (!IsClrObject)
     {
         return(@__env.CallBooleanMethod(this.JvmHandle, global::java.lang.annotation.Annotation_._equals13420, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)));
     }
     else
     {
         return(@__env.CallNonVirtualBooleanMethod(this.JvmHandle, global::java.lang.annotation.Annotation_.staticClass, global::java.lang.annotation.Annotation_._equals13420, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)));
     }
 }
Пример #26
0
 public virtual bool containsKey(java.lang.Object arg0)
 {
     global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv;
     if (!IsClrObject)
     {
         return(@__env.CallBooleanMethod(this.JvmHandle, global::java.util.AbstractMap._containsKey15221, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)));
     }
     else
     {
         return(@__env.CallNonVirtualBooleanMethod(this.JvmHandle, global::java.util.AbstractMap.staticClass, global::java.util.AbstractMap._containsKey15221, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)));
     }
 }
Пример #27
0
 public override bool equals(java.lang.Object arg0)
 {
     global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv;
     if (!IsClrObject)
     {
         return(@__env.CallBooleanMethod(this.JvmHandle, global::android.accounts.AuthenticatorDescription._equals110, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)));
     }
     else
     {
         return(@__env.CallNonVirtualBooleanMethod(this.JvmHandle, global::android.accounts.AuthenticatorDescription.staticClass, global::android.accounts.AuthenticatorDescription._equals110, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)));
     }
 }
Пример #28
0
 public virtual global::java.lang.Object put(java.lang.Object arg0, java.lang.Object arg1)
 {
     global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv;
     if (!IsClrObject)
     {
         return(global::MonoJavaBridge.JavaBridge.WrapJavaObject(@__env.CallObjectMethod(this.JvmHandle, global::java.util.AbstractMap._put15207, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1))) as java.lang.Object);
     }
     else
     {
         return(global::MonoJavaBridge.JavaBridge.WrapJavaObject(@__env.CallNonVirtualObjectMethod(this.JvmHandle, global::java.util.AbstractMap.staticClass, global::java.util.AbstractMap._put15207, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1))) as java.lang.Object);
     }
 }
Пример #29
0
 public global::java.lang.Object invoke(java.lang.Object arg0, java.lang.Object[] arg1)
 {
     global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv;
     if (!IsClrObject)
     {
         return(global::MonoJavaBridge.JavaBridge.WrapJavaObject(@__env.CallObjectMethod(this.JvmHandle, global::java.lang.reflect.Method._invoke13490, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1))) as java.lang.Object);
     }
     else
     {
         return(global::MonoJavaBridge.JavaBridge.WrapJavaObject(@__env.CallNonVirtualObjectMethod(this.JvmHandle, global::java.lang.reflect.Method.staticClass, global::java.lang.reflect.Method._invoke13490, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1))) as java.lang.Object);
     }
 }
Пример #30
0
 public sealed override bool equals(java.lang.Object arg0)
 {
     global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv;
     if (!IsClrObject)
     {
         return(@__env.CallBooleanMethod(this.JvmHandle, global::java.lang.reflect.Method._equals13491, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)));
     }
     else
     {
         return(@__env.CallNonVirtualBooleanMethod(this.JvmHandle, global::java.lang.reflect.Method.staticClass, global::java.lang.reflect.Method._equals13491, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)));
     }
 }
Пример #31
0
 public override bool equals(java.lang.Object arg0)
 {
     global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv;
     if (!IsClrObject)
     {
         return(@__env.CallBooleanMethod(this.JvmHandle, global::java.nio.CharBuffer._equals14113, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)));
     }
     else
     {
         return(@__env.CallNonVirtualBooleanMethod(this.JvmHandle, global::java.nio.CharBuffer.staticClass, global::java.nio.CharBuffer._equals14113, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)));
     }
 }
Пример #32
0
 public virtual void removeSpan(java.lang.Object arg0)
 {
     global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv;
     if (!IsClrObject)
     {
         @__env.CallVoidMethod(this.JvmHandle, global::android.text.SpannableString._removeSpan7820, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0));
     }
     else
     {
         @__env.CallNonVirtualVoidMethod(this.JvmHandle, global::android.text.SpannableString.staticClass, global::android.text.SpannableString._removeSpan7820, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0));
     }
 }
Пример #33
0
 public void assign(Object par0, Value par1)
 {
     Variable var = lookup(par0) as Variable;
     if (var != null)
     {
         int type = var.getValue().getType();
         if (type == VariableType_.BOOLEAN || type == VariableType_.NUMBER || type == VariableType_.STRING)
             var.setValue(session, par1.getType(), par1.getValueAsString());
         else
             throw new NotSupportedException(TextHelper.GetString("Error.NoScalar"));
     } 
     else
         throw new NoSuchVariableException(System.String.Format(TextHelper.GetString("Error.NoSuchVariable"), par0));
 }
Пример #34
0
        public Object lookup(Object par0)
        {
            if (par0 is String)
            {
                if (null != contextVal)
                {
                    foreach (Variable v in contextVal.getMembers(session))
                    {
                        if (v.getName().Equals(par0)) return (Object)v;
                    }
                    throw new NoSuchVariableException(System.String.Format(TextHelper.GetString("Error.NoSuchVariable"), par0));
                }

                if ((String)par0 == "this")
                {
                    return (Object)frame.getThis(session);
                }
                foreach (Variable v in frame.getArguments(session))
                {
                    if (v.getName().Equals(par0)) return (Object)v;
                }
                foreach (Variable v in frame.getLocals(session))
                {
                    if (v.getName().Equals(par0)) return (Object)v;
                }
                foreach (Variable v in frame.getThis(session).getValue().getMembers(session))
                {
                    if (v.getName().Equals(par0)) return (Object)v;
                }
                foreach (Variable scope in frame.getScopeChain(session))
                {
                    foreach (Variable v in scope.getValue().getMembers(session))
                    {
                        if (v.getName().Equals(par0)) return (Object)v;
                    }
                }
                var fullClassName = findClassName((String)par0);
                if (null != fullClassName)
                {
                    return (Object)session.getGlobal(new String(fullClassName));
                }
            }
            throw new NoSuchVariableException(System.String.Format(TextHelper.GetString("Error.NoSuchVariable"), par0));
            //Value_.UNDEFINED;
        }
Пример #35
0
 /// <summary> Resolve the object into a variable by various means and 
 /// using the current context.
 /// </summary>
 /// <returns> variable, or <code>null</code>
 /// </returns>
 internal virtual Variable resolveToVariable(Object o)
 {
     Variable v = null;
     // if o is a variable already, then we're done!
     if (o is Variable) return (Variable) o;
     // Resolve the name to something
     {
         // not an id so try as name 
         String name = o.ToString();
         long id = nameAsId(name);
         /*
         * if #N was used just pick up the variable, otherwise
         * we need to use the current context to resolve 
         * the name to a member
         */
         if (id != Value.UNKNOWN_ID)
         {
             // TODO what here?
         }
         else
         {
             // try to resolve as a member of current context (will set context if null)
             id = determineContext(name);
             v = locateForNamed((int) id, name, true);
             if (v != null) v = new VariableFacade(v, id);
             else if (v == null && m_createIfMissing && name[0] != '$')
             {
                 v = new VariableFacade(id, name);
             }
         }
     }
     return v;
 }
Пример #36
0
        public Object lookupMembers(Object par0)
        {
            String name = "?";
            Value val = null;

            if (par0 is Value)
            {
                val = (Value)par0;
            }
            
            if (par0 is Variable)
            {
                Variable var0 = (Variable)par0;
                name = var0.getName();
                val = var0.getValue();
            }

            if (val != null)
            {
                int type = val.getType();
                if (type == VariableType_.MOVIECLIP || type == VariableType_.OBJECT)
                {
                    String ret = name + " = " + FormatValue(val) + "\r\n";
                    foreach (Variable v in val.getMembers(session))
                    {
                        ret += " " + v.getName() + " = " + FormatValue(v.getValue()) + "\r\n";
                    }
                    return ret;
                }
                return new String(name + " = " + val.getValueAsString());
            }

            //NoSuchVariableException

            throw new NotImplementedException();
        }
Пример #37
0
 /* returns a string consisting of formatted member names and values */
 public virtual Object lookupMembers(Object o)
 {
     Variable var = null;
     Value val = null;
     Variable[] mems = null;
     try
     {
         var = resolveToVariable(o);
         if (var != null) val = var.getValue();
         else val = resolveToValue(o);
         mems = val.getMembers(Session);
     }
     catch (NullReferenceException)
     {
         throw new NoSuchVariableException(o);
     }
     catch (PlayerDebugException)
     {
         throw new NoSuchVariableException(o); // not quite right...
     }
     System.Text.StringBuilder sb = new System.Text.StringBuilder();
     // [mmorearty] experimenting with hierarchical display of members
     String[] classHierarchy = val.getClassHierarchy(false);
     if (classHierarchy != null && Session.getPreference(SessionManager.PREF_HIERARCHICAL_VARIABLES) != 0)
     {
         for (int c = 0; c < classHierarchy.Length; ++c)
         {
             String classname = classHierarchy[c];
             sb.Append(m_newline + "(Members of " + classname + ")"); //$NON-NLS-1$ //$NON-NLS-2$
             for (int i = 0; i < mems.Length; ++i)
             {
                 if (classname.Equals(mems[i].getDefiningClass()))
                 {
                     sb.Append(m_newline + " "); //$NON-NLS-1$
                 }
             }
         }
     }
     else
     {
         for (int i = 0; i < mems.Length; i++)
         {
             sb.Append(m_newline + " "); //$NON-NLS-1$
         }
     }
     return sb.ToString();
 }
Пример #38
0
 // determine the type from the VariableFacade or use the value object
 internal virtual int determineType(Variable var, Object value)
 {
     int type = VariableType.UNKNOWN;
     if (var is VariableFacade && ((VariableFacade) var).Variable == null)
     {
         if (value is ValueType) type = VariableType.NUMBER;
         else if (value is Boolean) type = VariableType.BOOLEAN;
         else type = VariableType.STRING;
     }
     else type = var.getValue().getType();
     return type;
 }
Пример #39
0
 // assign the object o, the value v; returns Boolean true if worked, false if failed
 public virtual Object assign(Object o, Object v)
 {
     bool worked = false;
     try
     {
         Variable var = resolveToVariable(o);
         if (var == null) throw new NoSuchVariableException((java.lang.Object)m_current);
         // set the value, for the case of a variable that does not exist it will not have a type
         // so we try to glean one from v.
         int type = determineType(var, v);
         FaultEvent faultEvent = var.setValue(Session, type, v.ToString());
         if (faultEvent != null) throw new PlayerFaultException(faultEvent);
         worked = true;
     }
     catch (PlayerDebugException)
     {
         worked = false;
     }
     return worked;
 }
Пример #40
0
        /// <summary> The Context interface which goes out and gets values from the session
        /// Expressions use this interface as a means of evaluation.
        /// 
        /// We also use this to create a reference to internal variables.
        /// </summary>
        public virtual Object lookup(Object o)
        {
            Object result = null;
            try
            {
                if ((result = resolveToVariable(o)) != null)
                {

                }
                // or value
                else if ((result = resolveToValue(o)) != null)
                {

                }
                else throw new NoSuchVariableException(o);
                // take on the path to the variable; so 'what' command prints something nice
                if ((result != null) && result is VariableFacade)
                {
                    ((VariableFacade) result).Path = getName();
                }
                // if the attempt to get the variable's value threw an exception inside the
                // player (most likely because the variable is actually a getter, and the
                // getter threw something), then throw something here
                Value resultValue = null;
                if (result is Variable) resultValue = ((Variable) result).getValue();
                else if (result is Value) resultValue = (Value) result;
                if (resultValue != null)
                {
                    if (resultValue.isAttributeSet(ValueAttribute.IS_EXCEPTION))
                    {
                        String value = resultValue.ValueAsString;
                        throw new PlayerFaultException(new ExceptionFault(value));
                    }
                }
            }
            catch (PlayerDebugException)
            {
                result = null; // null object
            }
            return result;
        }
 public DrawImage(NativeGraphics ng, WipeComponent pendingWipe, java.lang.Object image, int x, int y, int w, int h)
     : base(ng, pendingWipe)
 {
     this.image = image;
     this.x = x;
     this.y = y;
     this.w = w;
     this.h = h;
     alpha = ng.alpha;
 }
Пример #42
0
 // create a new context object by combinging the current one and o 
 public virtual Context createContext(Object o)
 {
     ExpressionContext c = new ExpressionContext(m_session);
     c.Context = o;
     c.createPseudoVariables(m_createIfMissing);
     c.m_namedPath.AddRange(m_namedPath);
     return c;
 }
Пример #43
0
 private String m_newline = Environment.NewLine; //$NON-NLS-1$
 
 // used when evaluating an expression 
 public ExpressionContext(Session session)
 {
     m_depth = 0;
     m_session = session;
     m_current = null;
     m_createIfMissing = false;
     m_namedPath = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
     m_nameLocked = false;
 }
Пример #44
0
 public Value toValue(Object par0)
 {
     if (par0 is Value) return (Value)par0;
     if (par0 is Variable) return ((Variable)par0).getValue();
     var val = DValue.forPrimitive(par0, this.getIsolateId());
     return val;
 }
Пример #45
0
 /*
 * Resolve the object into a variable by various means and 
 * using the current context.
 */
 internal virtual Value resolveToValue(Object o)
 {
     Value v = null;
     // if o is a variable or a value already, then we're done!
     if (o is Value) return (Value) o;
     else if (o is Variable) return ((Variable) o).getValue();
     {
         // not an id so try as name 
         String name = o.ToString();
         long id = nameAsId(name);
         /*
         * if #N was used just pick up the variable, otherwise
         * we need to use the current context to resolve 
         * the name to a member
         */
         if (id != Value.UNKNOWN_ID)
         {
             v = Session.getValue((int) id);
         }
         else
         {
             // TODO what here?
         }
     }
     return v;
 }
Пример #46
0
 public JvmRealProxy(Type proxyType)
     : base(proxyType)
 {
     _proxyType = proxyType;
     _proxy = new java.lang.Object(ProxyCtor.I);
 }
 protected DrawImage(DrawImage p, WipeComponent pendingWipe, int translateX, int translateY)
     : base(p, pendingWipe)
 {
     this.image = p.image;
     this.x = p.x + translateX;
     this.y = p.y + translateY;
     this.w = p.w;
     this.h = p.h;
     alpha = p.alpha;
 }