当前位置: 首页>>代码示例>>C#>>正文


C# AuroraDotNetEngine.ScriptData类代码示例

本文整理汇总了C#中Aurora.ScriptEngine.AuroraDotNetEngine.ScriptData的典型用法代码示例。如果您正苦于以下问题:C# ScriptData类的具体用法?C# ScriptData怎么用?C# ScriptData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ScriptData类属于Aurora.ScriptEngine.AuroraDotNetEngine命名空间,在下文中一共展示了ScriptData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Deserialize

        public static void Deserialize(ScriptData instance, ScriptEngine engine, StateSave save)
        {
            Dictionary<string, object> vars = save.Variables as Dictionary<string, object>;
            instance.State = save.State;
            instance.Running = save.Running;

            if (vars != null && vars.Count != 0)
                instance.Script.SetStoreVars(vars);

            if(save.Plugins is object[])
                instance.PluginData = (object[])save.Plugins;
            else
                instance.PluginData = new object[1] {(object)save.Plugins};

            if (save.Permissions != " " && save.Permissions != "")
            {
                instance.InventoryItem.PermsGranter = new UUID(save.Permissions.Split(',')[0]);
                instance.InventoryItem.PermsMask = int.Parse(save.Permissions.Split(',')[1], NumberStyles.Integer, Culture.NumberFormatInfo);
            }
            instance.EventDelayTicks = (long)save.MinEventDelay;
            instance.AssemblyName = save.AssemblyName;
            instance.Disabled = save.Disabled;
            instance.UserInventoryItemID = save.UserInventoryID;
            // Add it to our script memstruct
            ScriptEngine.ScriptProtection.AddNewScript(instance);
        }
开发者ID:mugginsm,项目名称:Aurora-Sim,代码行数:26,代码来源:ScriptDataSerializers.cs

示例2: SaveStateTo

        public void SaveStateTo (ScriptData script)
        {
            StateSave stateSave = new StateSave ();
            stateSave.State = script.State;
            stateSave.ItemID = script.ItemID;
            stateSave.Running = script.Running;
            stateSave.MinEventDelay = script.EventDelayTicks;
            stateSave.Disabled = script.Disabled;
            stateSave.UserInventoryID = script.UserInventoryItemID;
            //Allow for the full path to be put down, not just the assembly name itself
            stateSave.AssemblyName = script.AssemblyName;
            stateSave.Source = script.Source;
            if (script.InventoryItem != null)
            {
                stateSave.PermsGranter = script.InventoryItem.PermsGranter;
                stateSave.PermsMask = script.InventoryItem.PermsMask;
            }
            else
            {
                stateSave.PermsGranter = UUID.Zero;
                stateSave.PermsMask = 0;
            }
            stateSave.TargetOmegaWasSet = script.TargetOmegaWasSet;

            //Vars
            Dictionary<string, Object> vars = new Dictionary<string, object> ();
            if (script.Script != null)
                vars = script.Script.GetStoreVars ();
            stateSave.Variables = WebUtils.BuildXmlResponse (vars);

            //Plugins
            stateSave.Plugins = m_module.GetSerializationData (script.ItemID, script.Part.UUID);

            CreateOSDMapForState (script, stateSave);
        }
开发者ID:kow,项目名称:Aurora-Sim,代码行数:35,代码来源:ScriptDataSerializers.cs

示例3: SaveStateTo

        public void SaveStateTo(ScriptData script, bool forced, bool saveBackup)
        {
            if (!forced)
            {
                if (script.Script == null)
                    return; //If it didn't compile correctly, this happens
                if (!script.Script.NeedsStateSaved)
                    return; //If it doesn't need a state save, don't save one
            }
            if (script.Script != null)
                script.Script.NeedsStateSaved = false;
            if (saveBackup)
                script.Part.ParentEntity.HasGroupChanged = true;
            StateSave stateSave = new StateSave
                                      {
                                          State = script.State,
                                          ItemID = script.ItemID,
                                          Running = script.Running,
                                          MinEventDelay = script.EventDelayTicks,
                                          Disabled = script.Disabled,
                                          UserInventoryID = script.UserInventoryItemID,
                                          AssemblyName = script.AssemblyName,
                                          Compiled = script.Compiled,
                                          Source = script.Source
                                      };
            //Allow for the full path to be put down, not just the assembly name itself
            if (script.InventoryItem != null)
            {
                stateSave.PermsGranter = script.InventoryItem.PermsGranter;
                stateSave.PermsMask = script.InventoryItem.PermsMask;
            }
            else
            {
                stateSave.PermsGranter = UUID.Zero;
                stateSave.PermsMask = 0;
            }
            stateSave.TargetOmegaWasSet = script.TargetOmegaWasSet;

            //Vars
            Dictionary<string, Object> vars = new Dictionary<string, object>();
            if (script.Script != null)
                vars = script.Script.GetStoreVars();
            try
            {
                stateSave.Variables = WebUtils.BuildXmlResponse(vars);
            }
            catch
            {
            }

            //Plugins
            stateSave.Plugins = m_module.GetSerializationData(script.ItemID, script.Part.UUID);

            CreateOSDMapForState(script, stateSave);
        }
开发者ID:nathanmarck,项目名称:Aurora-Sim,代码行数:55,代码来源:ScriptDataSerializers.cs

示例4: SaveState

        public static void SaveState(ScriptData instance, ScriptEngine engine)
        {
            StateSave Insert = new StateSave();
            Insert.State = instance.State;
            Insert.ItemID = instance.ItemID;
            string source = instance.Source.Replace("\n", " ");
            Insert.Source = source.Replace("'", " ");
            Insert.Running = instance.Running;
            //Vars
            Dictionary<string, Object> vars = new Dictionary<string, object>();
            if (instance.Script != null)
                vars = instance.Script.GetVars();
            string varsmap = "";
            foreach (KeyValuePair<string, Object> var in vars)
            {
                varsmap += var.Key + "," + var.Value + "\n";
            }
            Insert.Variables = varsmap;
            //Plugins
            object[] Plugins = engine.GetSerializationData( instance.ItemID, instance.part.UUID);
            string plugins = "";
            foreach (object plugin in Plugins)
                plugins += plugin + ",";
            Insert.Plugins = plugins;

            //perms
            string perms = "";
            if (instance.InventoryItem != null)
            {
                if (instance.InventoryItem.PermsMask != 0 && instance.InventoryItem.PermsGranter != UUID.Zero)
                {
                    perms += instance.InventoryItem.PermsGranter.ToString() + "," + instance.InventoryItem.PermsMask.ToString();

                }
            }
            Insert.Permissions = perms;

            Insert.MinEventDelay = instance.EventDelayTicks;
            string[] AN = instance.AssemblyName.Split('\\');
            if(AN.Length > 2)
                Insert.AssemblyName = instance.AssemblyName.Split('\\')[2];
            else
            	Insert.AssemblyName = instance.AssemblyName;
            Insert.Disabled = instance.Disabled;
            Insert.UserInventoryID = instance.UserInventoryItemID;
            IScriptDataConnector ScriptFrontend = Aurora.DataManager.DataManager.RequestPlugin<IScriptDataConnector>();
            if(ScriptFrontend != null)
                ScriptFrontend.SaveStateSave(Insert);
        }
开发者ID:shangcheng,项目名称:Aurora,代码行数:49,代码来源:ScriptDataSerializers.cs

示例5: DeleteFrom

 public void DeleteFrom(ScriptData script)
 {
     bool changed = false;
     lock (StateSaveLock)
     {
         //if we did remove something, resave it
         if (script.Part.StateSaves.Remove(script.ItemID))
             changed = true;
         if (script.Part.StateSaves.Remove(script.InventoryItem.OldItemID))
             changed = true;
         if (script.Part.StateSaves.Remove(script.InventoryItem.ItemID))
             changed = true;
     }
     if (changed)
         script.Part.ParentEntity.HasGroupChanged = true;
 }
开发者ID:KSLcom,项目名称:Aurora-Sim,代码行数:16,代码来源:ScriptDataSerializers.cs

示例6: AddEventSchQueue

        public void AddEventSchQueue(ScriptData ID, string FunctionName, DetectParams[] qParams, EventPriority priority,
                                     params object[] param)
        {
            QueueItemStruct QIS;

            if (ID == null || ID.Script == null || ID.IgnoreNew)
                return;

            if (!ID.SetEventParams(FunctionName, qParams)) // check events delay rules
                return;

            QIS = new QueueItemStruct
                      {
                          EventsProcData = new ScriptEventsProcData(),
                          ID = ID,
                          functionName = FunctionName,
                          llDetectParams = qParams,
                          param = param,
                          VersionID = Interlocked.Read(ref ID.VersionID),
                          State = ID.State,
                          CurrentlyAt = null
                      };

            ScriptEvents.Enqueue(QIS);

            long threadCount = Interlocked.Read(ref scriptThreadpool.nthreads);
            if (threadCount == 0 || threadCount < (ScriptEvents.Count + (SleepingScriptEventCount/2))*EventPerformance)
            {
                scriptThreadpool.QueueEvent(eventLoop, 2);
            }
        }
开发者ID:velus,项目名称:Async-Sim-Testing,代码行数:31,代码来源:MaintenanceThread.cs

示例7: RemoveFromEventSchQueue

        public void RemoveFromEventSchQueue(ScriptData ID, bool abortcur)
        {
            if (ID == null)
                return;

            //Ignore any events to be added after this
            ID.IgnoreNew = true;
            //Clear out the old events
            Interlocked.Increment(ref ID.VersionID);
        }
开发者ID:velus,项目名称:Async-Sim-Testing,代码行数:10,代码来源:MaintenanceThread.cs

示例8: DeleteFrom

 public void DeleteFrom(ScriptData script)
 {
     OSDMap component = m_manager.GetComponentState(script.Part, m_componentName) as OSDMap;
     //Attempt to find the state saves we have
     if (component != null)
     {
         bool changed = false;
         //if we did remove something, resave it
         if (component.Remove(script.ItemID.ToString()))
             changed = true;
         if (component.Remove(script.InventoryItem.OldItemID.ToString()))
             changed = true;
         if (component.Remove(script.InventoryItem.ItemID.ToString()))
             changed = true;
         if (changed)
         {
             if (component.Count == 0)
                 m_manager.RemoveComponentState(script.Part.UUID, m_componentName);
             else
                 m_manager.SetComponentState(script.Part, m_componentName, component);
             script.Part.ParentEntity.HasGroupChanged = true;
         }
     }
 }
开发者ID:nathanmarck,项目名称:Aurora-Sim,代码行数:24,代码来源:ScriptDataSerializers.cs

示例9: Deserialize

        public void Deserialize(ScriptData instance, StateSave save)
        {
            instance.State = save.State;
            instance.Running = save.Running;
            instance.EventDelayTicks = (long)save.MinEventDelay;
            instance.AssemblyName = save.AssemblyName;
            instance.Disabled = save.Disabled;
            instance.UserInventoryItemID = save.UserInventoryID;
            instance.PluginData = save.Plugins;
            m_module.CreateFromData(instance.Part.UUID, instance.ItemID, instance.Part.UUID,
                                    instance.PluginData);
            instance.Source = save.Source;
            instance.InventoryItem.PermsGranter = save.PermsGranter;
            instance.InventoryItem.PermsMask = save.PermsMask;
            instance.TargetOmegaWasSet = save.TargetOmegaWasSet;

            try
            {
                Dictionary<string, object> vars = WebUtils.ParseXmlResponse(save.Variables);
                if (vars != null && vars.Count != 0 || instance.Script != null)
                    instance.Script.SetStoreVars(vars);
            }
            catch
            {
            }
        }
开发者ID:nathanmarck,项目名称:Aurora-Sim,代码行数:26,代码来源:ScriptDataSerializers.cs

示例10: AddEventSchQueue

        public void AddEventSchQueue(ScriptData ID, string FunctionName, DetectParams[] qParams, EventPriority priority, params object[] param)
        {
            QueueItemStruct QIS;

            if (ID == null || ID.Script == null || ID.IgnoreNew)
                return;

            if (!ID.SetEventParams(FunctionName, qParams)) // check events delay rules
                return;

            QIS = new QueueItemStruct();
            QIS.EventsProcData = new ScriptEventsProcData ();
            QIS.ID = ID;
            QIS.functionName = FunctionName;
            QIS.llDetectParams = qParams;
            QIS.param = param;
            QIS.VersionID = Interlocked.Read(ref ID.VersionID);
            QIS.State = ID.State;
            QIS.CurrentlyAt = null;

            lock (ScriptEvents)
            {
                ScriptEvents.Enqueue (QIS);
                ScriptEventCount++;
#if Debug
                m_log.Warn (ScriptEventCount + ", " + QIS.functionName);
#endif
            }

            long threadCount = Interlocked.Read (ref scriptThreadpool.nthreads);
            if (threadCount == 0 || threadCount < (ScriptEventCount + (SleepingScriptEventCount / 2)) * EventPerformance)
            {
                scriptThreadpool.QueueEvent (eventLoop, 2);
            }
        }
开发者ID:RevolutionSmythe,项目名称:Aurora-Sim,代码行数:35,代码来源:MaintenanceThread.cs

示例11: AddNewScript

 public void AddNewScript(ScriptData ID)
 {
     lock (Scripts)
     {
         ScriptsItems[ID.ItemID] = ID.part.UUID;
         Dictionary<UUID, ScriptData> Instances = new Dictionary<UUID, ScriptData>();
         if (!Scripts.TryGetValue(ID.part.UUID, out Instances))
         {
             Instances = new Dictionary<UUID, ScriptData>();
         }
         Instances[ID.ItemID] = ID;
         Scripts[ID.part.UUID] = Instances;
     }
 }
开发者ID:shangcheng,项目名称:Aurora,代码行数:14,代码来源:ScriptProtectionModule.cs

示例12: AddPreviouslyCompiled

 public void AddPreviouslyCompiled(string source, ScriptData ID)
 {
     lock (PreviouslyCompiled)
     {
         if (!PreviouslyCompiled.ContainsKey(source))
         {
             PreviouslyCompiled.Add(source, ID.AssemblyName);
         }
     }
 }
开发者ID:shangcheng,项目名称:Aurora,代码行数:10,代码来源:ScriptProtectionModule.cs

示例13: SetXMLState

        public static void SetXMLState(string xml, ScriptData instance, ScriptEngine engine)
        {
            XmlDocument doc = new XmlDocument();

            Dictionary<string, object> vars = instance.Script.GetVars();

            doc.LoadXml(xml);

            XmlNodeList rootL = doc.GetElementsByTagName("ScriptState");
            if (rootL.Count != 1)
            {
                return;
            }
            XmlNode rootNode = rootL[0];

            if (rootNode != null)
            {
                object varValue;
                XmlNodeList partL = rootNode.ChildNodes;

                foreach (XmlNode part in partL)
                {
                    switch (part.Name)
                    {
                        case "State":
                            instance.State = part.InnerText;
                            break;
                        case "Running":
                            instance.Running = bool.Parse(part.InnerText);
                            break;
                        case "Variables":
                            XmlNodeList varL = part.ChildNodes;
                            foreach (XmlNode var in varL)
                            {
                                string varName;
                                varValue = ReadTypedValue(var, out varName);

                                if (vars.ContainsKey(varName))
                                    vars[varName] = varValue;
                            }
                            instance.Script.SetVars(vars);
                            break;
                        case "Plugins":
                            instance.PluginData = ReadList(part).Data;
                            break;
                        case "Permissions":
                            string tmpPerm;
                            int mask = 0;
                            tmpPerm = part.Attributes.GetNamedItem("mask").Value;
                            if (tmpPerm != null)
                            {
                                int.TryParse(tmpPerm, out mask);
                                if (mask != 0)
                                {
                                    tmpPerm = part.Attributes.GetNamedItem("granter").Value;
                                    if (tmpPerm != null)
                                    {
                                        UUID granter = new UUID();
                                        UUID.TryParse(tmpPerm, out granter);
                                        if (granter != UUID.Zero)
                                        {
                                            instance.InventoryItem.PermsMask = mask;
                                            instance.InventoryItem.PermsGranter = granter;
                                        }
                                    }
                                }
                            }
                            break;
                        case "MinEventDelay":
                            double minEventDelay = 0.0;
                            double.TryParse(part.InnerText, NumberStyles.Float, Culture.NumberFormatInfo, out minEventDelay);
                            instance.EventDelayTicks = (long)minEventDelay;
                            break;
                    }
                }
            }
        }
开发者ID:shangcheng,项目名称:Aurora,代码行数:77,代码来源:ScriptDataSerializers.cs

示例14: GetXMLState

        public static string GetXMLState(ScriptData instance, ScriptEngine engine)
        {
            if (instance.Script == null)
                return "";
            //Update PluginData
            instance.PluginData = engine.GetSerializationData(instance.ItemID, instance.part.UUID);

            bool running = instance.Running;

            XmlDocument xmldoc = new XmlDocument();

            XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration,
                                                "", "");
            xmldoc.AppendChild(xmlnode);

            XmlElement rootElement = xmldoc.CreateElement("", "ScriptState",
                                                          "");
            xmldoc.AppendChild(rootElement);

            XmlElement state = xmldoc.CreateElement("", "State", "");
            state.AppendChild(xmldoc.CreateTextNode(instance.State));

            rootElement.AppendChild(state);

            XmlElement run = xmldoc.CreateElement("", "Running", "");
            run.AppendChild(xmldoc.CreateTextNode(
                    running.ToString()));

            rootElement.AppendChild(run);

            Dictionary<string, Object> vars = instance.Script.GetVars();

            XmlElement variables = xmldoc.CreateElement("", "Variables", "");

            foreach (KeyValuePair<string, Object> var in vars)
                WriteTypedValue(xmldoc, variables, "Variable", var.Key,
                                var.Value);

            rootElement.AppendChild(variables);

            #region Queue

            //We don't do queue...
            XmlElement queue = xmldoc.CreateElement("", "Queue", "");
            rootElement.AppendChild(queue);

            #endregion

            XmlNode plugins = xmldoc.CreateElement("", "Plugins", "");
            DumpList(xmldoc, plugins,
                     new LSL_Types.list(instance.PluginData));

            rootElement.AppendChild(plugins);

            if (instance.InventoryItem != null)
            {
                if (instance.InventoryItem.PermsMask != 0 && instance.InventoryItem.PermsGranter != UUID.Zero)
                {
                    XmlNode permissions = xmldoc.CreateElement("", "Permissions", "");
                    XmlAttribute granter = xmldoc.CreateAttribute("", "granter", "");
                    granter.Value = instance.InventoryItem.PermsGranter.ToString();
                    permissions.Attributes.Append(granter);
                    XmlAttribute mask = xmldoc.CreateAttribute("", "mask", "");
                    mask.Value = instance.InventoryItem.PermsMask.ToString();
                    permissions.Attributes.Append(mask);
                    rootElement.AppendChild(permissions);
                }
            }

            if (instance.EventDelayTicks > 0.0)
            {
                XmlElement eventDelay = xmldoc.CreateElement("", "MinEventDelay", "");
                eventDelay.AppendChild(xmldoc.CreateTextNode(instance.EventDelayTicks.ToString()));
                rootElement.AppendChild(eventDelay);
            }
            Type type = instance.Script.GetType();
            FieldInfo[] mi = type.GetFields();
            string xml = xmldoc.InnerXml;

            XmlDocument sdoc = new XmlDocument();
            sdoc.LoadXml(xml);
            XmlNodeList rootL = sdoc.GetElementsByTagName("ScriptState");
            XmlNode rootNode = rootL[0];

            // Create <State UUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx">
            XmlDocument doc = new XmlDocument();
            XmlElement stateData = doc.CreateElement("", "State", "");
            XmlAttribute stateID = doc.CreateAttribute("", "UUID", "");
            stateID.Value = instance.ItemID.ToString();
            stateData.Attributes.Append(stateID);
            XmlAttribute assetID = doc.CreateAttribute("", "Asset", "");
            assetID.Value = instance.InventoryItem.AssetID.ToString();
            stateData.Attributes.Append(assetID);
            XmlAttribute engineName = doc.CreateAttribute("", "Engine", "");
            engineName.Value = engine.ScriptEngineName;
            stateData.Attributes.Append(engineName);
            doc.AppendChild(stateData);

            // Add <ScriptState>...</ScriptState>
            XmlNode xmlstate = doc.ImportNode(rootNode, true);
//.........这里部分代码省略.........
开发者ID:shangcheng,项目名称:Aurora,代码行数:101,代码来源:ScriptDataSerializers.cs

示例15: DeleteFrom

 public void DeleteFrom (ScriptData script)
 {
     OSDMap component = m_manager.GetComponentState (script.Part, m_componentName) as OSDMap;
     //Attempt to find the state saves we have
     if (component != null)
     {
         //if we did remove something, resave it
         if(component.Remove(script.ItemID.ToString()))
         {
             if (component.Count == 0)
                 m_manager.RemoveComponentState(script.Part.UUID, m_componentName);
             else
                 m_manager.SetComponentState (script.Part, m_componentName, component);
         }
     }
 }
开发者ID:kchi059,项目名称:Aurora-Sim,代码行数:16,代码来源:ScriptDataSerializers.cs


注:本文中的Aurora.ScriptEngine.AuroraDotNetEngine.ScriptData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。