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


C# BehaviorNode.MakeRelative方法代码示例

本文整理汇总了C#中BehaviorNode.MakeRelative方法的典型用法代码示例。如果您正苦于以下问题:C# BehaviorNode.MakeRelative方法的具体用法?C# BehaviorNode.MakeRelative怎么用?C# BehaviorNode.MakeRelative使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BehaviorNode的用法示例。


在下文中一共展示了BehaviorNode.MakeRelative方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PreSave

		/// <summary>
		/// Before saving we must change the reference into a relative path.
		/// </summary>
		/// <param name="behavior">The behaviour this node belongs to. NOT the referenced one.</param>
		public override void PreSave(BehaviorNode behavior)
		{
			base.PreSave(behavior);

			// make the path of the reference relative
			_referenceFilename= behavior.MakeRelative(_referenceFilename);
		}
开发者ID:drzo,项目名称:opensim4opencog,代码行数:11,代码来源:ReferencedBehavior.cs

示例2: ExportBehavior

        /// <summary>
        /// Exports a behaviour to the given file.
        /// </summary>
        /// <param name="file">The file we want to export to.</param>
        /// <param name="behavior">The behaviour we want to export.</param>
        protected void ExportBehavior(BsonSerializer file, BehaviorNode behavior) {
            if (behavior.FileManager == null)
            {
                return;
            }

            file.WriteComment("EXPORTED BY TOOL, DON'T MODIFY IT!");
            file.WriteComment("Source File: " + behavior.MakeRelative(behavior.FileManager.Filename));

            file.WriteStartElement("behavior");

            Behavior b = behavior as Behavior;
            Debug.Check(b != null);
            Debug.Check(b.Id == -1);

            //'\\' ->'/'
            string behaviorName = b.MakeRelative(b.Filename);
            behaviorName = behaviorName.Replace('\\', '/');
            int pos = behaviorName.IndexOf(".xml");

            if (pos != -1) {
                behaviorName = behaviorName.Remove(pos);
            }

            file.WriteString(behaviorName);
            file.WriteString(b.AgentType.AgentTypeName);
            file.WriteBool(b.IsFSM);
            file.WriteString(b.Version.ToString());

            this.ExportProperties(file, b);

            this.ExportPars(file, b);

            if (!b.IsFSM) {
                this.ExportAttachments(file, b);
            }

            if (b.IsFSM)
            {
                file.WriteStartElement("node");

                file.WriteString("FSM");
                file.WriteString("-1");

                file.WriteStartElement("properties");
                    file.WriteAttributeString("initialid", behavior.InitialStateId.ToString());
                file.WriteEndElement();

                foreach (Node child in ((Node)behavior).FSMNodes)
                {
                    this.ExportNode(file, behavior, child);
                }

                file.WriteEndElement();
            }
            else
            {
                // export the children
                foreach (Node child in ((Node)behavior).Children)
                {
                    this.ExportNode(file, behavior, child);
                }
            }

            file.WriteEndElement();
        }
开发者ID:675492062,项目名称:behaviac,代码行数:71,代码来源:ExporterBson.cs

示例3: ExportBehavior

        /// <summary>
        /// Exports a behaviour to the given file.
        /// </summary>
        /// <param name="file">The file we want to export to.</param>
        /// <param name="behavior">The behaviour we want to export.</param>
        protected void ExportBehavior(XmlWriter file, BehaviorNode behavior) {
            file.WriteComment("EXPORTED BY TOOL, DON'T MODIFY IT!");
            file.WriteComment("Source File: " + behavior.MakeRelative(behavior.FileManager.Filename));

            file.WriteStartElement("behavior");

            Behavior b = behavior as Behavior;
            Debug.Check(b != null);
            Debug.Check(b.Id == -1);

            //'\\' ->'/'
            string behaviorName = b.MakeRelative(b.Filename);
            behaviorName = behaviorName.Replace('\\', '/');
            int pos = behaviorName.IndexOf(".xml");

            if (pos != -1) {
                behaviorName = behaviorName.Remove(pos);
            }

            file.WriteAttributeString("name", behaviorName);
            //file.WriteAttributeString("event", b.EventName);
            file.WriteAttributeString("agenttype", b.AgentType.AgentTypeName);

            if (b.IsFSM)
            { file.WriteAttributeString("fsm", "true"); }

            file.WriteAttributeString("version", b.Version.ToString());

            this.ExportProperties(file, b);

            this.ExportPars(file, b);

            if (!b.IsFSM)
            { this.ExportAttachments(file, b); }

#if QUERY_EANBLED
            //after ExportProperties as DescritorRefs are exported as property
            this.ExportDescritorRefs(file, b);
#endif//#if QUERY_EANBLED

            if (b.IsFSM)
            {
                file.WriteStartElement("node");

                file.WriteAttributeString("class", "FSM");
                file.WriteAttributeString("id", "-1");

                file.WriteStartElement("property");
                file.WriteAttributeString("initialid", behavior.InitialStateId.ToString());
                file.WriteEndElement();

                foreach (Node child in ((Node)behavior).FSMNodes)
                {
                    this.ExportNode(file, behavior, child);
                }

                file.WriteEndElement();
            }
            else
            {
                // export the children
                foreach (Node child in ((Node)behavior).Children)
                {
                    this.ExportNode(file, behavior, child);
                }
            }

            file.WriteEndElement();
        }
开发者ID:haolly,项目名称:behaviac,代码行数:74,代码来源:ExporterXml.cs

示例4: ExportNode

		/// <summary>
		/// Exports a node to the given file.
		/// </summary>
		/// <param name="file">The file we want to export to.</param>
		/// <param name="namspace">The namespace of the behaviour we are currently exporting.</param>
		/// <param name="behavior">The behaviour we are currently exporting.</param>
		/// <param name="parentName">The name of the variable of the node which is the parent of this node.</param>
		/// <param name="node">The node we want to export.</param>
		/// <param name="indentDepth">The indent of the ocde we are exporting.</param>
		/// <param name="nodeID">The current id used for generating the variables for the nodes.</param>
		protected void ExportNode(StreamWriter file, string namspace, BehaviorNode behavior, string parentName, Node node, int indentDepth, ref int nodeID)
		{
			// generate some data
			string classname= node.ExportClass;
			string nodeName= string.Format("node{0}", ++nodeID);

			// generate the indent string
			string indent= string.Empty;
			for(int i= 0; i <indentDepth; ++i)
				indent+= '\t';

			// we have to handle a referenced behaviour differently
			if(node is ReferencedBehaviorNode)
			{
				// generate the namespace and name of the behaviour we are referencing
				string refRelativeFilename= behavior.MakeRelative(((ReferencedBehaviorNode)node).ReferenceFilename);
				string refNamespace= GetNamespace(namspace, refRelativeFilename);
				string refBehaviorName= Path.GetFileNameWithoutExtension(((ReferencedBehaviorNode)node).ReferenceFilename.Replace(" ", string.Empty));

				// simply add the instance of the behaviours we are referencing
				file.Write( string.Format("{0}{1}.AddChild({1}.GetConnector(\"{2}\"), {3}.{4}.Instance);\r\n", indent, parentName, node.ParentConnector.Identifier, refNamespace, refBehaviorName) );
			}
			else
			{
				// open some brackets for a better formatting in the generated code
				file.Write( string.Format("{0}{{\r\n", indent) );

				// export the constructor and the properties
				ExportConstructorAndProperties(file, node, indent, nodeName, classname);

				// add the node to its parent
				file.Write( string.Format("{0}\t{1}.AddChild({1}.GetConnector(\"{2}\"), {3});\r\n", indent, parentName, node.ParentConnector.Identifier, nodeName) );

				// export the child nodes
				foreach(Node child in node.Children)
					ExportNode(file, namspace, behavior, nodeName, child, indentDepth +1, ref nodeID);

				// close the brackets for a better formatting in the generated code
				file.Write( string.Format("{0}}}\r\n", indent) );
			}
		}
开发者ID:drzo,项目名称:opensim4opencog,代码行数:51,代码来源:ExporterCs.cs

示例5: ExportBehavior

        /// <summary>
        /// Exports a behaviour to the given file.
        /// </summary>
        /// <param name="file">The file we want to export to.</param>
        /// <param name="behavior">The behaviour we want to export.</param>
        protected void ExportBehavior(BsonSerializer file, BehaviorNode behavior)
        {
            file.WriteComment("EXPORTED BY TOOL, DON'T MODIFY IT!");
            file.WriteComment("Source File: " + behavior.MakeRelative(behavior.FileManager.Filename));

            file.WriteStartElement("behavior");

            Behavior b = behavior as Behavior;
            Debug.Check(b != null);
            Debug.Check(b.Id == -1);

            //'\\' ->'/'
            string behaviorName = b.MakeRelative(b.Filename);
            behaviorName = behaviorName.Replace('\\', '/');
            int pos = behaviorName.IndexOf(".xml");
            if (pos != -1)
            {
                behaviorName = behaviorName.Remove(pos);
            }

            file.WriteString(behaviorName);
            file.WriteString(b.AgentType.AgentTypeName);
            file.WriteString(b.Version.ToString());

            this.ExportProperties(file, b);

            this.ExportParameters(file, (Node)behavior);

            this.ExportAttachments(file, b);

            // export the children
            foreach (Node child in ((Node)behavior).Children)
            {
                this.ExportNode(file, behavior, (Node)behavior, child);
            }

            file.WriteEndElement();
        }
开发者ID:KeyleXiao,项目名称:behaviac,代码行数:43,代码来源:ExporterBson.cs


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