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


C# DefaultObject类代码示例

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


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

示例1: FromStringValue

        public override object FromStringValue(List<Nodes.Node.ErrorCheck> result, DefaultObject node, object parentObject, Type type, string str)
        {
            if (type.GetGenericTypeDefinition() != typeof(List<>))
            { throw new Exception(Resources.ExceptionDesignerAttributeInvalidType); }

            Type itemType = type.GetGenericArguments()[0];

            if (!itemType.IsEnum)
            { throw new Exception(Resources.ExceptionDesignerAttributeInvalidType); }

            System.Collections.IList enumArray = (System.Collections.IList)Plugin.CreateInstance(type);

            if (!string.IsNullOrEmpty(str)) {
                int index = str.IndexOf(':');

                if (index >= 0)
                { str = str.Substring(index + 1); }

                string[] tokens = str.Split('|');
                foreach(string s in tokens) {
                    enumArray.Add(Enum.Parse(itemType, s, true));
                }
            }

            return enumArray;
        }
开发者ID:675492062,项目名称:behaviac,代码行数:26,代码来源:DesignerArrayEnum.cs

示例2: FromStringValue

        public override object FromStringValue(List<Nodes.Node.ErrorCheck> result, DefaultObject node, object parentObject, Type type, string str)
        {
            if (Plugin.IsCustomClassType(type))
            { return ParseStringValue(result, type, null, str, node); }

            throw new Exception(Resources.ExceptionDesignerAttributeInvalidType);
        }
开发者ID:675492062,项目名称:behaviac,代码行数:7,代码来源:DesignerStruct.cs

示例3: ParseStringValue

        public new static object ParseStringValue(List<Nodes.Node.ErrorCheck> result, Type type, string str, DefaultObject node)
        {
            Debug.Check(type != null && Plugin.IsArrayType(type));

            object obj = Plugin.CreateInstance(type);
            Debug.Check(obj != null);

            if (!string.IsNullOrEmpty(str)) {
                System.Collections.IList list = (System.Collections.IList)obj;
                Type itemType = type.GetGenericArguments()[0];

                int index = str.IndexOf(':');

                if (index >= 0)
                { str = str.Substring(index + 1); }

                if (!string.IsNullOrEmpty(str)) {
                    System.Collections.IList structArray = (System.Collections.IList)Plugin.CreateInstance(type);
                    parseStringValue(result, node, structArray, itemType, str, 0, str.Length - 1);

                    return structArray;
                }
            }

            return obj;
        }
开发者ID:675492062,项目名称:behaviac,代码行数:26,代码来源:DesignerArrayStruct.cs

示例4: FromStringValue

        public override object FromStringValue(List<Nodes.Node.ErrorCheck> result, DefaultObject node, object parentObject, Type type, string str)
        {
            if (type != typeof(RightValueDef))
            { throw new Exception(Resources.ExceptionDesignerAttributeInvalidType); }

            if (str.Length == 0 ||
                str.Length == 2 && str == "\"\"") {
                return null;
            }

            if (!str.StartsWith("const")) {
                int pos = str.IndexOf('(');

                if (pos < 0) {
                    VariableDef var = DesignerPropertyEnum.parsePropertyVar(result, node, str);

                    return new RightValueDef(var);

                } else {
                    Nodes.Behavior behavior = node.Behavior as Nodes.Behavior;
                    AgentType agentType = (behavior != null) ? behavior.AgentType : null;

                    string valueClass = VariableDef.kSelfMethod;
                    MethodDef method = DesignerMethodEnum.parseMethodString(result, node, agentType, this.MethodType, str);

                    if (method == null) {
                        string className = Plugin.GetClassName(str);
                        method = DesignerMethodEnum.parseMethodString(result, node, Plugin.GetInstanceAgentType(className, behavior, null), this.MethodType, str);
                        valueClass = className + VariableDef.kMethod;
                    }

                    string instanceName = Plugin.GetInstanceName(str);

                    if (!string.IsNullOrEmpty(instanceName)) {
                        valueClass = instanceName + VariableDef.kMethod;
                    }

                    return new RightValueDef(method, valueClass);
                }

            } else {
                VariableDef var = this.parseConstVar(result, node, parentObject, str);

                if (var != null) {
                    return new RightValueDef(var);
                }
            }

            return null;
        }
开发者ID:675492062,项目名称:behaviac,代码行数:50,代码来源:DesignerRightValueEnum.cs

示例5: FromStringValue

        public override object FromStringValue(List<Nodes.Node.ErrorCheck> result, DefaultObject node, object parentObject, Type type, string str)
        {
            if (type != typeof(bool))
            { throw new Exception(Resources.ExceptionDesignerAttributeInvalidType); }

            str = str.ToLowerInvariant();

            if (str == "true")
            { return true; }

            if (str == "false")
            { return false; }

            throw new Exception(string.Format(Resources.ExceptionDesignerAttributeIllegalBooleanValue, str));
        }
开发者ID:675492062,项目名称:behaviac,代码行数:15,代码来源:DesignerBoolean.cs

示例6: FromStringValue

        public override object FromStringValue(List<Nodes.Node.ErrorCheck> result, DefaultObject node, object parentObject, Type type, string str)
        {
            if (type != typeof(MethodDef))
            { throw new Exception(Resources.ExceptionDesignerAttributeInvalidType); }

            Nodes.Behavior behavior = node.Behavior as Nodes.Behavior;

            if (behavior != null && behavior.AgentType != null) {
                MethodDef method = parseMethodString(result, node, behavior.AgentType, this.MethodType, str);

                if (method == null) {
                    string className = Plugin.GetClassName(str);
                    method = parseMethodString(result, node, Plugin.GetInstanceAgentType(className, behavior, null), this.MethodType, str);
                }

                return method;
            }

            return null;
        }
开发者ID:675492062,项目名称:behaviac,代码行数:20,代码来源:DesignerMethodEnum.cs

示例7: FromStringValue

        public override object FromStringValue(List<Nodes.Node.ErrorCheck> result, DefaultObject node, object parentObject, Type type, string str)
        {
            foreach(Plugin.InstanceName_t t in Plugin.InstanceNames) {
                if (str == t.agentType_.AgentTypeName
#if BEHAVIAC_NAMESPACE_FIX
                    || t.agentType_.AgentTypeName.EndsWith(str)
#endif
                   ) {
                    return t.agentType_;
                }
            }

            foreach(AgentType t in Plugin.AgentTypes) {
                if (str == t.ToString()
#if BEHAVIAC_NAMESPACE_FIX
                    || t.AgentTypeName.EndsWith(str)
#endif
                   ) {
                    return t;
                }
            }

            return null;
        }
开发者ID:675492062,项目名称:behaviac,代码行数:24,代码来源:DesignerTypeEnum.cs

示例8: AcceptsAttachment

 public override bool AcceptsAttachment(DefaultObject obj)
 {
     return (obj != null) && (obj is WaitTransition);
 }
开发者ID:wuzhen,项目名称:behaviac,代码行数:4,代码来源:WaitState.cs

示例9: createVariable

        private static VariableDef createVariable(List<Nodes.Node.ErrorCheck> result, DefaultObject node, AgentType agentType, string instacneName, string propertyName)
        {
            List<string> tokens = DesignerPropertyEnum.SplitTokens(propertyName);
            Debug.Check(tokens.Count > 0);
            string arrayIndexStr = null;

            if (tokens.Count > 1) {
                propertyName = tokens[0] + "[]";
                arrayIndexStr = tokens[1];
            }

            Nodes.Behavior behavior = node.Behavior as Nodes.Behavior;
            agentType = Plugin.GetInstanceAgentType(instacneName, behavior, agentType);

            if (agentType != null) {
                IList<PropertyDef> properties = agentType.GetProperties();
                foreach(PropertyDef p in properties) {
                    if (p.Name == propertyName
#if BEHAVIAC_NAMESPACE_FIX
                        || p.Name.EndsWith(propertyName)
#endif
                       ) {
                        VariableDef v = new VariableDef(p, instacneName);

                        if (v != null && !string.IsNullOrEmpty(arrayIndexStr)) {
                            v.ArrayIndexElement = new MethodDef.Param("ArrayIndex", typeof(int), "int", "ArrayIndex", "ArrayIndex");
                            v.ArrayIndexElement.IsArrayIndex = true;
                            DesignerMethodEnum.parseParam(result, node, null, v.ArrayIndexElement, arrayIndexStr);
                        }

                        return v;
                    }
                }
            }

            return null;
        }
开发者ID:675492062,项目名称:behaviac,代码行数:37,代码来源:DesignerMethodEnum.cs

示例10: AcceptsAttachment

 /// <summary>
 /// Determines if an attachment of a certain type is aceepted by this node or not.
 /// </summary>
 /// <param name="type">The type of the attachment we want to add.</param>
 /// <returns>Returns if the attachment may be added or not</returns>
 public virtual bool AcceptsAttachment(DefaultObject obj) {
     return (obj != null) && !obj.IsFSM && obj.CanBeAttached;
 }
开发者ID:haolly,项目名称:behaviac,代码行数:8,代码来源:Node.cs

示例11: FromStringValue

        public override object FromStringValue(List<Nodes.Node.ErrorCheck> result, DefaultObject node, object parentObject, Type type, string str)
        {
            if (!Plugin.IsIntergerNumberType(type))
                throw new Exception(Resources.ExceptionDesignerAttributeInvalidType);

            int resultValue = 0;

            if (int.TryParse(str, NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat, out resultValue))
                return resultValue;

            throw new Exception(string.Format(Resources.ExceptionDesignerAttributeIllegalIntegerValue, str));
        }
开发者ID:Just4F,项目名称:behaviac,代码行数:12,代码来源:DesignerInteger.cs

示例12: setProperty

        protected static VariableDef setProperty(List<Nodes.Node.ErrorCheck> result, DefaultObject node, AgentType agentType, string propertyName, string arrayIndexStr, string valueType)
        {
            if (agentType != null)
            {
                IList<PropertyDef> properties = agentType.GetProperties();
                foreach (PropertyDef p in properties)
                {
                    if (p.Name == propertyName
#if BEHAVIAC_NAMESPACE_FIX
                        || p.Name.EndsWith(propertyName)
#endif
                        )
                    {
                        PropertyDef prop = p.Clone();
                        prop.Owner = valueType;

                        VariableDef v = new VariableDef(prop, valueType);

                        if (v != null && !string.IsNullOrEmpty(arrayIndexStr))
                        {
                            v.ArrayIndexElement = new MethodDef.Param("ArrayIndex", typeof(int), "int", "ArrayIndex", "ArrayIndex");
                            v.ArrayIndexElement.IsArrayIndex = true;
                            DesignerMethodEnum.parseParam(result, node, null, v.ArrayIndexElement, arrayIndexStr);
                        }

                        return v;
                    }
                }
            }

            return null;
        }
开发者ID:675492062,项目名称:behaviac,代码行数:32,代码来源:DesignerPropertyEnum.cs

示例13: parseConstVar

        protected VariableDef parseConstVar(List<Nodes.Node.ErrorCheck> result, DefaultObject node, object parentObject, string str)
        {
            Debug.Check(str.StartsWith("const"));

            //const Int32 1
            object propertyMemberDepended = null;
            Type objType = node.GetType();

            if (this.DependedProperty != "") {
                System.Reflection.PropertyInfo pi = objType.GetProperty(this.DependedProperty);

                if (pi != null) {
                    propertyMemberDepended = pi.GetValue(node, null);

                } else if (pi == null && parentObject != null) {
                    Type parentType = parentObject.GetType();
                    pi = parentType.GetProperty(this.DependedProperty);
                    propertyMemberDepended = pi.GetValue(parentObject, null);
                }
            }

            Type valueType = null;
            VariableDef variableDepended = propertyMemberDepended as VariableDef;

            if (variableDepended != null) {
                valueType = variableDepended.GetValueType();

            } else if (propertyMemberDepended != null) {
                MethodDef methodDepended = propertyMemberDepended as MethodDef;

                if (methodDepended != null) {
                    valueType = methodDepended.ReturnType;

                } else {
                    RightValueDef varRV = propertyMemberDepended as RightValueDef;

                    if (varRV != null) {
                        valueType = varRV.ValueType;
                    }
                }

            } else {
                string[] tokens = str.Split(' ');
                Debug.Check(tokens.Length >= 3);

                valueType = Plugin.GetTypeFromName(tokens[1]);
            }

            if (valueType != null) {
                VariableDef variable = new VariableDef(null);

                //string[] tokens = str.Split(' ');
                //Debug.Check(tokens.Length == 3);
                Debug.Check(str.StartsWith("const"));
                //skip 'const '
                int pos = str.IndexOf(' ');
                Debug.Check(pos != -1);
                pos = str.IndexOf(' ', pos + 1);
                string token = str.Substring(pos + 1);

                Plugin.InvokeTypeParser(result, valueType, token,
                                        (object value) => variable.Value = value,
                                        node);

                return variable;
            }

            return null;
        }
开发者ID:675492062,项目名称:behaviac,代码行数:69,代码来源:DesignerPropertyEnum.cs

示例14: parseParam

        public static bool parseParam(List<Nodes.Node.ErrorCheck> result, DefaultObject node, MethodDef method, MethodDef.Param par, string param)
        {
            string propName = null;

            if (param[0] == '\"')
            {
                param = param.Substring(1, param.Length - 2);
            }
            else if (param[0] == '{') //struct
            {
                //to set it as action.Method is used in the following parsing
                Nodes.Action action = node as Nodes.Action;

                if (action != null)
                {
                    action.Method = method;
                }
            }
            else
            {
                string noStaticParam = param.Replace("static ", "");
                int index = noStaticParam.IndexOf(" ");
                if (index >= 0)
                    propName = noStaticParam.Substring(index + 1);
            }

            bool bOk = false;

            if (propName != null)
            {
                VariableDef var = setParameter(result, node, propName);

                if (var != null)
                {
                    par.Value = var;
                    bOk = true;
                }
            }
            else
            {
                bOk = Plugin.InvokeTypeParser(result, par.Type, param, 
                    (object value) => par.Value = value, 
                    node, par.Name);
            }

            return bOk;
        }
开发者ID:tachen,项目名称:behaviac,代码行数:47,代码来源:DesignerMethodEnum.cs

示例15: NodeTag

        /// <summary>
        /// Creates a new NodeTag and an instance of the node for the defaults.
        /// </summary>
        /// <param name="type">The type of the node in the node explorer.</param>
        /// <param name="nodetype">The type of the node which will be added to the behaviour tree.</param>
        /// <param name="filename">The filename of the behaviour we want to load. Use string.Empty if the node is not a behaviour.</param>
        public NodeTag(NodeTagType type, Type nodetype, string filename)
        {
            if((type ==NodeTagType.BehaviorFolder || type ==NodeTagType.NodeFolder) && nodetype !=null)
                throw new Exception(Resources.ExceptionWrongNodeTagType);

            _type= type;
            _nodetype= nodetype;
            _filename= filename;

            if(nodetype ==null)
            {
                _defaults= null;
            }
            else
            {
                //if(!nodetype.IsSubclassOf(typeof(DefaultObject)))
                //	throw new Exception(Resources.ExceptionNotImplementDefaultObject);

                if(nodetype.IsSubclassOf(typeof(Events.Event)) && type !=NodeTagType.Event)
                    throw new Exception(Resources.ExceptionWrongNodeTagType);

                if(nodetype.IsSubclassOf(typeof(Nodes.Node)) && type !=NodeTagType.Node && type !=NodeTagType.Behavior)
                    throw new Exception(Resources.ExceptionWrongNodeTagType);

                _defaults=type ==NodeTagType.Event ? (DefaultObject)Brainiac.Design.Events.Event.Create(nodetype, null) : (DefaultObject)Nodes.Node.Create(nodetype);
            }
        }
开发者ID:yiliu1203,项目名称:Brainiac-Designer,代码行数:33,代码来源:Plugin.cs


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