Example #1
0
        protected override MathNode OnCreateClone(MathNode parent)
        {
            ParameterDef[] ps = null;
            if (_methodRef.Parameters != null)
            {
                ps = new ParameterDef[_methodRef.Parameters.Length];
                for (int i = 0; i < _methodRef.Parameters.Length; i++)
                {
                    ps[i] = (ParameterDef)_methodRef.Parameters[i].Clone();
                }
            }
            ObjectRef ow = null;

            if (_methodRef.MethodOwner != null)
            {
                ow = (ObjectRef)_methodRef.MethodOwner.Clone();
            }
            RaisDataType ret;

            if (_methodRef.ReturnType != null)
            {
                ret = (RaisDataType)_methodRef.ReturnType.Clone();
            }
            else
            {
                ret = new RaisDataType(typeof(void));
            }
            return(new MathNodeMethodInvoke(parent, ow, _methodRef.MethodName, _methodRef.MethodID, ret, ps));
        }
Example #2
0
 private void NotifyQualityChange(List <ItemState> badItems, List <ItemState> goodItems)
 {
     if (badItems.Count == 1)
     {
         string msg = "Bad quality for reading data item: " + badItems[0].Name;
         var    ev  = AlarmOrEventInfo.Warning("Quality", msg, ObjectRef.Make(moduleID, badItems[0].ID));
         notifier.Notify_AlarmOrEvent(ev);
     }
     else if (badItems.Count > 1)
     {
         string      names = string.Join(", ", badItems.Select(it => it.Name));
         string      msg   = $"Bad quality for reading {badItems.Count} data items: " + names;
         ObjectRef[] objs  = badItems.Select(it => ObjectRef.Make(moduleID, it.ID)).ToArray();
         var         ev    = AlarmOrEventInfo.Warning("Quality", msg, objs);
         notifier.Notify_AlarmOrEvent(ev);
     }
     if (goodItems.Count == 1)
     {
         string msg = "Good quality restored for data item: " + goodItems[0].Name;
         var    ev  = AlarmOrEventInfo.Info("Quality", msg, ObjectRef.Make(moduleID, goodItems[0].ID));
         notifier.Notify_AlarmOrEvent(ev);
     }
     else if (goodItems.Count > 1)
     {
         string      names = string.Join(", ", goodItems.Select(it => it.Name));
         string      msg   = $"Good quality restored for {goodItems.Count} data items: " + names;
         ObjectRef[] objs  = goodItems.Select(it => ObjectRef.Make(moduleID, it.ID)).ToArray();
         var         ev    = AlarmOrEventInfo.Info("Quality", msg, objs);
         notifier.Notify_AlarmOrEvent(ev);
     }
 }
Example #3
0
        public void Read(BinaryReader reader)
        {
            StringRef name = reader.ReadInt32();
            uint      num_controlled_blocks = reader.ReadUInt32();

            controlled_blocks = new ControllerLink[num_controlled_blocks];
            unknown_int_1     = reader.ReadUInt32();

            //Controlled Blocks: array of ControllerLink
            for (int i = 0; i < num_controlled_blocks; i++)
            {
                controlled_blocks[i] = new ControllerLink();
                controlled_blocks[i].Read(reader);
            }

            weight          = reader.ReadSingle();
            text_keys       = reader.ReadInt32();
            cycle_type      = reader.ReadUInt32();
            frequency       = reader.ReadSingle();
            start_time      = reader.ReadSingle();
            stop_time       = reader.ReadSingle();
            manager         = reader.ReadInt32();
            target_name     = reader.ReadInt32();
            unknown_short_1 = reader.ReadInt16();
        }
Example #4
0
        static void Read2DArray(BinBuffer bb, ModIdMap map, int xLen, int yLen, Action <int, int, int> setElemV, Action <int, int, ObjectRef> setElemM)
        {
            var dictPos   = bb.ReadInt32();
            var dataStart = bb.Position;

            bb.Position = dictPos;

            map.ReadDictionary(bb);

            var endOfStream = bb.Position;

            bb.Position = dataStart;

            int amt = 0;

            bool      isM  = false;
            ObjectRef curM = ObjectRef.Null;
            int       curV = 0;

            for (int y = 0; y < yLen; y++)
            {
                for (int x = 0; x < xLen; x++)
                {
                    if (amt == 0)
                    {
                        map.GetRef(bb.ReadUInt32(),
                                   oid =>
                        {
                            curV = oid;
                            isM  = false;

                            setElemV(x, y, curV);     // amt == 0 -> one element
                        },
                                   or =>
                        {
                            curM = or;
                            isM  = true;

                            setElemM(x, y, curM);     // amt == 0 -> one element
                        });
                        amt = bb.ReadUInt16();
                    }
                    else
                    {
                        if (isM)
                        {
                            setElemM(x, y, curM);
                        }
                        else
                        {
                            setElemV(x, y, curV);
                        }

                        amt--;
                    }
                }
            }

            bb.Position = endOfStream;
        }
Example #5
0
        /*
        ** Call a function (C or Lua). The parameters must be on the stack,
        ** between [stack+base,top). When returns, the results are on the stack,
        ** between [stack+whereRes,top). The number of results is nResults, unless
        ** nResults=MULT_RET.
        */
        private static void do_call(Object_ func, StkId @base, int nResults, StkId whereRes)
        {
            StkId firstResult;

            if (tag(func) == lua_Type.LUA_T_CFUNCTION)
            {
                firstResult = callC(fvalue(func), @base);
            }
            else if (tag(func) == lua_Type.LUA_T_FUNCTION)
            {
                firstResult = lua_execute(bvalue(func), @base);
            }
            else
            {             /* func is not a function */
                call_funcFB(func, @base, nResults, whereRes);
                return;
            }
            /* adjust the number of results */
            if (nResults != MULT_RET && ObjectRef.minus(top, new ObjectRef(stack, firstResult)) != nResults)
            {
                adjust_top(firstResult + nResults);
            }
            /* move results to the given position */
            if (firstResult != whereRes)
            {
                int i;
                nResults = ObjectRef.minus(top, new ObjectRef(stack, firstResult));          /* actual number of results */
                for (i = 0; i < nResults; i++)
                {
                    stack[whereRes + i].set(stack[firstResult + i]);
                }
                top.add(-(firstResult - whereRes));
            }
        }
Example #6
0
        protected override void ReadXmlBase(System.Xml.XmlReader reader)
        {
            base.ReadXmlBase(reader);

            if (reader.NodeType == System.Xml.XmlNodeType.Element && reader.LocalName == "folders")
            {
                LocatableList <Folder> folders = new LocatableList <Folder>();
                do
                {
                    Folder folder = new Folder();

                    folder.ReadXml(reader);

                    folder.Parent = this;
                    folders.Add(folder);
                } while (reader.LocalName == "folders" && reader.NodeType == System.Xml.XmlNodeType.Element);

                this.folders = folders;
            }

            if (reader.LocalName == "items")
            {
                AssumedTypes.List <ObjectRef> items = new AssumedTypes.List <ObjectRef>();
                do
                {
                    ObjectRef item = new ObjectRef();

                    item.ReadXml(reader);
                    items.Add(item);
                } while (reader.LocalName == "items" && reader.NodeType == System.Xml.XmlNodeType.Element);

                this.items = items;
            }
        }
Example #7
0
 public void Read(BinaryReader reader)
 {
     reader.ReadVector3(out translation);
     reader.ReadQuaternion(out rotation);
     scale = reader.ReadSingle();
     data  = reader.ReadInt32();
 }
        private List <ObjectRef> GetTypeCountList()
        {
            ObjectTranslator objectTranslator = LuaState.GetTranslator(IntPtr.Zero);
            List <ObjectRef> result           = new List <ObjectRef>();

            foreach (var each in objectTranslator.objectsBackMap)
            {
                Type t    = each.Key.GetType();
                bool find = false;
                for (int i = 0; i < result.Count; i++)
                {
                    if (result[i]._objectType == t)
                    {
                        result[i]._objectCount++;
                        find = true;
                        break;
                    }
                }
                if (!find)
                {
                    ObjectRef objectRef = new ObjectRef();
                    objectRef._objectType  = t;
                    objectRef._objectCount = 1;
                    result.Add(objectRef);
                }
            }
            result.Sort((x, y) => - x._objectCount.CompareTo(y._objectCount));
            return(result);
        }
Example #9
0
 public ObjInfo GetObjectInfo(string moduleID, IEnumerable <IModelObject> parents) => new ObjInfo(
     ObjectRef.Make(moduleID, GetID(parents)),
     GetDisplayName(parents),
     GetClassName(),
     GetChildObjectsInMember(),
     GetVariablesOrNull(parents),
     GetLocation());
Example #10
0
        public Action(DvText name, string archetypeNodeId, UidBasedId uid,
                      Link[] links, Archetyped archetypeDetails, FeederAudit feederAudit,
                      CodePhrase language, CodePhrase encoding, PartyProxy subject, PartyProxy proider,
                      Participation[] otherParticipations, ObjectRef workflowId, ItemStructure protocol,
                      ObjectRef guidelineId, DvDateTime time, ItemStructure description,
                      IsmTransition ismTransition, InstructionDetails instructionDetails)
            : base(name, archetypeNodeId, uid, links, archetypeDetails, feederAudit, language,
                   encoding, subject, proider, otherParticipations, workflowId, protocol, guidelineId)
        {
            Check.Require(time != null, "time must not be null");
            Check.Require(description != null, "description must not be null");
            Check.Require(ismTransition != null, "ismTransition must not be null");

            this.time        = time;
            this.description = description;
            if (this.description != null)
            {
                this.description.Parent = this;
            }
            this.ismTransition = ismTransition;
            if (this.ismTransition != null)
            {
                this.ismTransition.Parent = this;
            }
            this.instructionDetails = instructionDetails;
            if (this.instructionDetails != null)
            {
                this.instructionDetails.Parent = this;
            }

            SetAttributeDictionary();
            CheckInvariants();
        }
Example #11
0
 public int AddObject(object o)
 {
     if (o != null)
     {
         if (_freeIndex < 0)
         {
             var freeEntry = new ObjectRef();
             var id        = _map.Count;
             _map.Add(freeEntry);
             freeEntry.next   = -1;
             freeEntry.target = o;
             // UnityEngine.Debug.LogFormat("[cache] (new) add object at {0}", id);
             return(id);
         }
         else
         {
             var id        = _freeIndex;
             var freeEntry = _map[id];
             _freeIndex       = freeEntry.next;
             freeEntry.next   = -1;
             freeEntry.target = o;
             // UnityEngine.Debug.LogFormat("[cache] (reuse) add object at {0} [{1}]", id, o.GetType());
             return(id);
         }
     }
     return(0);
 }
 private List<ObjectRef> GetTypeCountList()
 {
     var objectTranslator = LuaState.GetTranslator(IntPtr.Zero);
     var result = new List<ObjectRef>();
     foreach (var each in objectTranslator.objectsBackMap)
     {
         var t = each.Key.GetType();
         var find = false;
         for (var i = 0; i < result.Count; i++)
         {
             if (result[i]._objectType == t)
             {
                 result[i]._objectCount++;
                 find = true;
                 break;
             }
         }
         if (!find)
         {
             var objectRef = new ObjectRef
             {
                 _objectType = t,
                 _objectCount = 1
             };
             result.Add(objectRef);
         }
     }
     result.Sort((x, y) => -x._objectCount.CompareTo(y._objectCount));
     return result;
 }
Example #13
0
        private static void comparison(lua_Type tag_less, lua_Type tag_equal,
                                       lua_Type tag_great, CharPtr op)
        {
            Object_ l = top.get(-2);
            Object_ r = top.get(-1);
            int     result;

            if (tag(l) == lua_Type.LUA_T_NUMBER && tag(r) == lua_Type.LUA_T_NUMBER)
            {
                result = (nvalue(l) < nvalue(r)) ? -1 : (nvalue(l) == nvalue(r)) ? 0 : 1;
            }
            else if (tostring(l) || tostring(r))
            {
                lua_pushstring(op);
                do_call(luaI_fallBacks[FB_ORDER].function, ObjectRef.minus(top, stack) - 3, 1, ObjectRef.minus(top, stack) - 3);
                return;
            }
            else
            {
                result = strcmp(svalue(l), svalue(r));
            }
            top.dec();
            nvalue(top.get(-1), 1);
            tag(top.get(-1), (result < 0) ? tag_less : ((result == 0) ? tag_equal : tag_great));
        }
Example #14
0
 /// <summary>
 /// Constructor for RunspaceRef.
 /// </summary>
 internal RunspaceRef(Runspace runspace)
 {
     Dbg.Assert(runspace != null, "Expected runspace != null");
     _runspaceRef = new ObjectRef<Runspace>(runspace);
     _stopInvoke = false;
     _localSyncObject = new object();
 }
Example #15
0
 /*
 ** Push an object (tag=string) on stack and register it on the constant table.
 */
 public static void lua_pushliteral(CharPtr s)
 {
     lua_checkstack(ObjectRef.minus(top, stack) + 1);
     tsvalue(top.get(), lua_constant[luaI_findconstant(lua_constcreate(s))]);
     tag(top.get(), lua_Type.LUA_T_STRING);
     top.inc();
 }
Example #16
0
 /*
 ** Push an object (tag=string) to stack.
 */
 public static void lua_pushstring(CharPtr s)
 {
     lua_checkstack(ObjectRef.minus(top, stack) + 1);
     tsvalue(top.get(), lua_createstring(s));
     tag(top.get(), lua_Type.LUA_T_STRING);
     top.inc();
 }
Example #17
0
        private static int do_protectedmain()
        {
            BytePtr code = null;
            int     status;
            StkId   oldCBase   = CBase;
            jmp_buf myErrorJmp = new jmp_buf();
            jmp_buf oldErr     = errorJmp;

            errorJmp = myErrorJmp;
            try             //if (setjmp(myErrorJmp) == 0)
            {
                Object_ f = new Object_();
                lua_parse(ref code);
                tag(f, lua_Type.LUA_T_FUNCTION); bvalue(f, code);
                do_call(f, CBase, 0, CBase);
                status = 0;
            }
            catch (LongjmpException) {             //else {
                status = 1;
            }
            if (code != null)
            {
                luaI_free_BytePtr(ref code);
            }
            errorJmp = oldErr;
            CBase    = oldCBase;
            top      = new ObjectRef(stack, CBase);
            return(status);
        }
Example #18
0
        protected override void ReadXmlBase(System.Xml.XmlReader reader)
        {
            base.ReadXmlBase(reader);

            Check.Assert(reader.LocalName == "language", "Expected LocalName is 'language' rather than " +
                         reader.LocalName);
            this.language = new OpenEhr.RM.DataTypes.Text.CodePhrase();
            this.language.ReadXml(reader);

            Check.Assert(reader.LocalName == "encoding", "Expected LocalName is 'encoding' rather than " +
                         reader.LocalName);
            this.encoding = new OpenEhr.RM.DataTypes.Text.CodePhrase();
            this.encoding.ReadXml(reader);

            Check.Assert(reader.LocalName == "subject", "Expected LocalName is 'subject' rather than " +
                         reader.LocalName);
            string subjectType = RmXmlSerializer.ReadXsiType(reader);

            this.subject = RmFactory.PartyProxy(subjectType);

            this.subject.ReadXml(reader);


            if (reader.LocalName == "provider")
            {
                string providerType = RmXmlSerializer.ReadXsiType(reader);
                this.provider = RmFactory.PartyProxy(providerType);

                this.provider.ReadXml(reader);
            }

            if (reader.LocalName == "other_participations")
            {
                this.otherParticipations = new OpenEhr.AssumedTypes.List <Participation>();
                do
                {
                    Participation p = new Participation();
                    p.ReadXml(reader);

                    this.otherParticipations.Add(p);
                } while (reader.LocalName == "other_participations");
            }

            if (reader.LocalName == "work_flow_id")
            {
                string workFlowIdType = reader.GetAttribute("type", RmXmlSerializer.XsiNamespace);

                // CM: 06/09/10 when workFlowIdType is null or empty, it's type of OBJECT_REF
                if (string.IsNullOrEmpty(workFlowIdType))
                {
                    this.workflowId = new ObjectRef();
                }
                else
                {
                    this.workflowId = ObjectRef.GetObjectRefByType(workFlowIdType);
                }

                this.workflowId.ReadXml(reader);
            }
        }
Example #19
0
 public int AddObject(object o, bool finalizer)
 {
     if (!_disposed && o != null)
     {
         if (_freeIndex < 0)
         {
             var freeEntry = new ObjectRef();
             var id        = _map.Count;
             _map.Add(freeEntry);
             freeEntry.next      = -1;
             freeEntry.target    = o;
             freeEntry.finalizer = finalizer;
             return(id);
         }
         else
         {
             var id        = _freeIndex;
             var freeEntry = _map[id];
             _freeIndex          = freeEntry.next;
             freeEntry.next      = -1;
             freeEntry.target    = o;
             freeEntry.finalizer = finalizer;
             return(id);
         }
     }
     return(-1);
 }
Example #20
0
        protected override async Task OnConfigModelChanged(bool init)
        {
            await base.OnConfigModelChanged(init);

            var t          = Timestamp.Now.TruncateMilliseconds();
            var newVarVals = new Dictionary <ObjectRef, VariableValue[]>();

            foreach (var entry in mapObjectInfos)
            {
                ObjectInfo obj       = entry.Value;
                ObjectRef  id        = obj.ID;
                Variable[] variables = obj.Variables;

                VariableValue[]? existingValues = null;
                if (varVals.ContainsKey(id))
                {
                    existingValues = varVals[id];
                }
                int VarLen = variables == null ? 0 : variables.Length;
                if (existingValues != null || VarLen > 0)
                {
                    VariableValue[] newValues = new VariableValue[VarLen];
                    for (int i = 0; i < VarLen; ++i)
                    {
                        Variable variable = variables ![i];
        protected static void InitFromModelImpl(string moduleID, IModelObject root, Stack <IModelObject> parents, MemberRefIdx?parent, List <ObjectInfo> res, Dictionary <ObjectRef, IModelObject> mapObjests)
        {
            ObjInfo info = root.GetObjectInfo(moduleID, parents);

            res.Add(new ObjectInfo(info.ID, info.DisplayName, info.ClassName, parent, info.Variables));
            ObjectRef key = info.ID;

            if (mapObjests.ContainsKey(key))
            {
                throw new Exception("Object id is not unique: " + key);
            }
            mapObjests[key] = root;
            if (info.ChildObjects == null)
            {
                return;
            }
            parents.Push(root);
            foreach (ChildObjectsInMember member in info.ChildObjects)
            {
                int i = 0;
                foreach (IModelObject obj in member.ChildObjects)
                {
                    MemberRefIdx par = MemberRefIdx.Make(info.ID, member.MemberName, i);
                    InitFromModelImpl(moduleID, obj, parents, par, res, mapObjests);
                    i += 1;
                }
            }
            parents.Pop();
        }
Example #22
0
        protected XVersionedObject(HierObjectId uid, ObjectRef ownerId, DvDateTime timeCreated,
                                   int totalVersionCount, List <OriginalVersion <T> > versions)
            : this(uid, ownerId, timeCreated, totalVersionCount)
        {
            Check.Require(totalVersionCount >= 1, "totalVersionCount must not be less than 1");

            this.versions = versions;
        }
Example #23
0
 internal InternalHost(PSHost externalHost, ExecutionContext executionContext)
 {
     this.externalHostRef  = new ObjectRef <PSHost>(externalHost);
     this.executionContext = executionContext;
     this.internalUIRef    = new ObjectRef <InternalHostUserInterface>(new InternalHostUserInterface(externalHost.UI, this));
     this.zeroGuid         = new Guid(0, (short)0, (short)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0);
     this.idResult         = this.zeroGuid;
 }
Example #24
0
        protected Version(AuditDetails commitAudit, ObjectRef contribution)
        {
            Check.Require(commitAudit != null, "commitAudit must not be null.");

            // set local data
            this.contribution = contribution;
            this.commitAudit  = commitAudit;
        }
Example #25
0
 public int minus(ObjectRef oref)
 {
     if (this.obj == oref.obj)
     {
         return(this.index - oref.index);
     }
     throw new Exception("objs not same");
 }
Example #26
0
 public bool isLessEquals(ObjectRef oref)
 {
     if (this.obj != oref.obj)
     {
         throw new Exception("objs not same");
     }
     return(this.index <= oref.index);
 }
Example #27
0
        public override async Task <ReqResult> OnUiRequestAsync(string command, DataValue parameters)
        {
            switch (command)
            {
            case "ReadModuleVariables":

                if (activeModuleID != "")
                {
                    await Connection.DisableChangeEvents();
                }

                var    pars     = parameters.Object <ReadModuleVariables_Params>();
                string moduleID = string.IsNullOrEmpty(pars.ModuleID) ? modules[0].ID : pars.ModuleID;

                ObjectInfo rootObjInfo = await Connection.GetRootObject(moduleID);

                ObjectRef rootObj = rootObjInfo.ID;

                ObjectInfo[] objects = await Connection.GetAllObjects(moduleID);

                SetObjectNameMap(objects);

                VariableValue[] values = await Connection.ReadAllVariablesOfObjectTree(rootObj);

                await Connection.EnableVariableValueChangedEvents(SubOptions.AllUpdates(sendValueWithEvent: true), rootObj);

                VarEntry[] entries = values.Select(MapVarValue).ToArray();

                activeModuleID = moduleID;

                var result = new ReadModuleVariables_Result()
                {
                    Modules    = modules,
                    ModuleID   = moduleID,
                    ModuleName = modules.FirstOrDefault(m => m.ID == moduleID).Name,
                    Variables  = entries
                };

                mapIdx.Clear();
                for (int n = 0; n < values.Length; ++n)
                {
                    mapIdx[values[n].Variable] = n;
                }

                return(ReqResult.OK(result));

            case "WriteVariable":

                var write = parameters.Object <WriteVariable_Params>();
                VTQ vtq   = new VTQ(Timestamp.Now, Quality.Good, DataValue.FromJSON(write.V));
                await Connection.WriteVariable(ObjectRef.FromEncodedString(write.ObjID), write.Var, vtq);

                return(ReqResult.OK());

            default:
                return(ReqResult.Bad("Unknown command: " + command));
            }
        }
Example #28
0
        protected EntityRef(ObjectRef objRef, Assembly calling)
            : this(() => objRef.Name)
        {
            resName = new Lazy <string>(() => objRef.Name);

            ModName = objRef.ModName;

            Requesting = ModData.ModFromAssembly(calling);
        }
Example #29
0
 internal InternalHost(PSHost externalHost, ExecutionContext executionContext)
 {
     this.externalHostRef = new ObjectRef<PSHost>(externalHost);
     this.executionContext = executionContext;
     PSHostUserInterface uI = externalHost.UI;
     this.internalUIRef = new ObjectRef<InternalHostUserInterface>(new InternalHostUserInterface(uI, this));
     this.zeroGuid = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
     this.idResult = this.zeroGuid;
 }
 protected override void OnSave(XmlNode node)
 {
     base.OnSave(node);
     if (_value == null)
     {
         _value = new ObjectRef(null);
     }
     XmlSerialization.WriteToChildXmlNode(GetWriter(), node, "ObjRef", _value);
 }
        private async Task <List <ObjectMember> > GetObjectMembers(string id, string type)
        {
            ObjectRef obj  = ObjectRef.FromEncodedString(id);
            ClassInfo info = objTypes[type];

            MemberRef[]        members   = info.SimpleMember.Select(m => MemberRef.Make(obj, m.Name)).ToArray();
            List <MemberValue> memValues = await Connection.GetMemberValues(members);

            var values = new List <ObjectMember>();

            for (int i = 0; i < info.SimpleMember.Count; ++i)
            {
                SimpleMember m = info.SimpleMember[i];
                if (m.Type == DataType.LocationRef && !hasLocations)
                {
                    continue;
                }

                MemberValue v            = memValues[i];
                string      defaultValue = "";
                if (m.DefaultValue.HasValue && m.Dimension != Dimension.Array)
                {
                    defaultValue = m.DefaultValue.Value.JSON;
                }
                else if (m.Type == DataType.Struct)
                {
                    defaultValue = StdJson.ObjectToString(GetStructDefaultValue(m) !, indented: true, ignoreShouldSerializeMembers: false);
                    //Console.WriteLine("=> " + m.Name + ": " + defaultValue);
                }
                else if (m.Type == DataType.LocationRef && rootLocation.HasValue)
                {
                    defaultValue = DataValue.FromLocationRef(rootLocation.Value).JSON;
                }
                else
                {
                    defaultValue = DataValue.FromDataType(m.Type, 1).JSON;
                }
                var member = new ObjectMember()
                {
                    Key           = obj.ToEncodedString() + "__" + m.Name,
                    Name          = m.Name,
                    Type          = m.Type.ToString(),
                    IsScalar      = m.Dimension == Dimension.Scalar,
                    IsOption      = m.Dimension == Dimension.Optional,
                    IsArray       = m.Dimension == Dimension.Array,
                    Category      = m.Category,
                    Browseable    = m.Browseable,
                    Value         = new JRaw(v.Value.JSON),
                    ValueOriginal = new JRaw(v.Value.JSON),
                    EnumValues    = ResolveEnum(m),
                    StructMembers = ResolveStruct(m),
                    DefaultValue  = defaultValue
                };
                values.Add(member);
            }
            return(values);
        }
Example #32
0
 public ObjInfo(ObjectRef id, string displayName, string className, IEnumerable <ChildObjectsInMember> childObjects, Variable[]?variables, LocationRef?location)
 {
     ID           = id;
     DisplayName  = displayName;
     ClassName    = className;
     ChildObjects = childObjects;
     Variables    = variables;
     Location     = location;
 }
Example #33
0
        /// <summary>
        /// 
        /// There should only be one instance of InternalHost per runspace (i.e. per engine), and all engine use of the host 
        /// should be through that single instance.  If we ever accidentally create more than one instance of InternalHost per
        /// runspace, then some of the internal state checks that InternalHost makes, like checking the nestedPromptCounter, can
        /// be messed up.
        /// 
        /// To ensure that this constraint is met, I wanted to make this class a singleton.  However, Hitesh rightly pointed out
        /// that a singleton would be appdomain-global, which would prevent having multiple runspaces per appdomain. So we will 
        /// just have to be careful not to create extra instances of InternalHost per runspace.
        /// 
        /// </summary>
        internal InternalHost(PSHost externalHost, ExecutionContext executionContext)
        {
            Dbg.Assert(externalHost != null, "must supply an PSHost");
            Dbg.Assert(!(externalHost is InternalHost), "try to create an InternalHost from another InternalHost");

            Dbg.Assert(executionContext != null, "must supply an ExecutionContext");

            _externalHostRef = new ObjectRef<PSHost>(externalHost);
            Context = executionContext;

            PSHostUserInterface ui = externalHost.UI;

            _internalUIRef = new ObjectRef<InternalHostUserInterface>(new InternalHostUserInterface(ui, this));
            _zeroGuid = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
            _idResult = _zeroGuid;
        }
Example #34
0
 public MCAttribute(long id, string name)
 {
     data = new ObjectRef {id = id.ToString(), name = name};
 }
Example #35
0
 public void SetStatusMappings(ObjectRef[] statusEnum)
 {
     statusMapping.Clear();
     IEnumerator e = statusEnum.GetEnumerator();
     while (e.MoveNext())
     {
         ObjectRef status = (ObjectRef)e.Current;
         statusMapping.Add(status.id, status.name);
     }
     ListIssues();
 }
Example #36
0
        public void TestBtreePerformanceAfterManyInsertsOfObjectRefPayload()
        {
            var timer = new Stopwatch();
            timer.Start();
            var storeId = Guid.NewGuid();
            var store = _storeManager.CreateStore(BrightstarDB.Configuration.StoreLocation + "\\" + storeId) as Store;
            var btree = store.MakeNewTree<ObjectRef>(201);

            for (ulong j = 0; j < 10; j++)
            {
                for (ulong i = 0; i < 1000000; i++)
                {
                    var id = (j*1000000) + i;
                    var objRef = new ObjectRef(id);
                    btree.Insert(id, objRef);
                }
                store.FlushChanges();
            }
            store.Commit(Guid.Empty);

            timer.Stop();
            Console.WriteLine("Time to insert and persist 10 million related resource lists: {0}ms", timer.ElapsedMilliseconds);
        }
Example #37
0
 internal RunspaceRef(System.Management.Automation.Runspaces.Runspace runspace)
 {
     this._runspaceRef = new ObjectRef<System.Management.Automation.Runspaces.Runspace>(runspace);
     this._stopInvoke = false;
     this._localSyncObject = new object();
 }
Example #38
0
 internal MCAttribute(ObjectRef objData)
 {
     data = objData;
 }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="driverInvoker"></param>
        /// <param name="runspace"></param>
        /// <param name="debugger"></param>
        internal ServerRemoteDebugger(
            IRSPDriverInvoke driverInvoker,
            Runspace runspace,
            Debugger debugger)
        {
            if (driverInvoker == null)
            {
                throw new PSArgumentNullException("driverInvoker");
            }
            if (runspace == null)
            {
                throw new PSArgumentNullException("runspace");
            }
            if (debugger == null)
            {
                throw new PSArgumentNullException("debugger");
            }
            _driverInvoker = driverInvoker;
            _runspace = runspace;

            _wrappedDebugger = new ObjectRef<Debugger>(debugger);

            SetDebuggerCallbacks();

            _runspace.Name = "RemoteHost";
            _runspace.InternalDebugger = this;
        }
Example #40
0
        public PackedValue Register(ObjectRef obj)
        {
            if (obj.IsNull)
                return 0;
            if (String.IsNullOrEmpty(obj.ModName) || obj.Mod == PrismApi.VanillaInfo)
                return unchecked((PackedValue)GetVanillaID(obj)); // vanilla - no need to register

            ModName mn = obj.ModName;
            ModID mid;

            if (Mods.ContainsKey(mn))
                mid = Mods.Forward[mn];
            else
            {
                mid = (ModID)Mods.Count;
                Mods.Add(mn, mid);

                ModObjects.Add(mid, new BiDictionary<ObjName, ObjID>());
            }

            ObjName on = obj.Name;
            ObjID oid;

            var mod = ModObjects[mid];

            if (mod.ContainsKey(on))
                oid = mod[on];
            else
            {
                oid = (ObjID)mod.Count;
                mod.Add(on, oid);
            }

            #pragma warning disable 675
            return unchecked((PackedValue)oid | ((PackedValue)mid << 8 * sizeof(ObjID)) | IsModFlag);
            #pragma warning restore 675
        }