コード例 #1
0
 public void Constructs_ok()
 {
     var attribute = new NodeAttribute(123, "planet", "Saturn", 456);
     Assert.AreEqual(123, attribute.Index);
     Assert.AreEqual("planet", attribute.Name);
     Assert.AreEqual("Saturn", attribute.Value);
 }
コード例 #2
0
        public TreeNode GetTreeNodeRecursive(Node node)
        {
            if (node == null)
            {
                return(null);
            }

            NodeAttribute attribute = node.Attribute;

            TreeNode viewNode;

            if (attribute != null)
            {
                viewNode = new TreeNode(string.Format("{0} {1}", node.Name, attribute.Type.ToString()));

                if (attribute.Type == AttributeType.Mesh)
                {
                    UnpackMesh(viewNode, node);
                }
            }
            else
            {
                viewNode = new TreeNode(string.Format("{0} {1}", node.Name, "null"));
            }

            for (int i = 0; i < node.GetChildCount(); i++)
            {
                Node     child     = node.GetChild(i);
                TreeNode viewChild = GetTreeNodeRecursive(child);
                if (viewChild != null)
                {
                    viewNode.Nodes.Add(viewChild);
                }
            }

            return(viewNode);
        }
コード例 #3
0
ファイル: NodeMetaHelper.cs プロジェクト: ycllz/Egametang
        public static NodeMeta GetNodeTypeProtoFromType(Type type)
        {
            object[] nodeAttrs = type.GetCustomAttributes(typeof(NodeAttribute), false);
            if (nodeAttrs.Length == 0)
            {
                return(null);
            }
            object[]                nodeDeprecatedAttrs     = type.GetCustomAttributes(typeof(NodeDeprecatedAttribute), false);
            NodeAttribute           nodeAttribute           = nodeAttrs[0] as NodeAttribute;
            NodeDeprecatedAttribute nodeDeprecatedAttribute = null;

            if (nodeDeprecatedAttrs.Length != 0)
            {
                nodeDeprecatedAttribute = nodeDeprecatedAttrs[0] as NodeDeprecatedAttribute;
            }

            NodeMeta proto = new NodeMeta()
            {
                type     = nodeAttribute.ClassifytType.ToString(),
                name     = type.Name,
                describe = nodeAttribute.Desc
            };

            if (nodeDeprecatedAttribute != null)
            {
                proto.isDeprecated   = true;
                proto.deprecatedDesc = nodeDeprecatedAttribute.Desc;
            }

            proto.new_args_desc.AddRange(GetNodeFieldDesc(type, typeof(NodeInputAttribute)));
            proto.new_args_desc.AddRange(GetNodeFieldDesc(type, typeof(NodeOutputAttribute)));
            proto.new_args_desc.AddRange(GetNodeFieldDesc(type, typeof(NodeFieldAttribute)));

            proto.child_limit = NodeTypeCountDict[nodeAttribute.ClassifytType];
            proto.classify    = nodeAttribute.ClassifytType.ToString();
            return(proto);
        }
コード例 #4
0
ファイル: NodeTypes.cs プロジェクト: cl4nk/NodalEditor
    /// <summary>
    /// Fetches every Node Declaration in the script assemblies to provide the framework with custom node types
    /// </summary>
    public static void FetchNodeTypes()
    {
        nodes = new Dictionary <string, NodeTypeData> ();
        foreach (Type type in ReflectionUtility.getSubTypes(typeof(Node)))
        {
            object[]      nodeAttributes = type.GetCustomAttributes(typeof(NodeAttribute), false);
            NodeAttribute attr           = nodeAttributes[0] as NodeAttribute;
            if (attr == null || !attr.hide)
            {             // Only regard if it is not marked as hidden
                // Fetch node information
                string className = type.FullName;
                string Title     = "None";
                Node   sample    = (Node)ScriptableObject.CreateInstance(type);
                Title = sample.Title;
                UnityEngine.Object.DestroyImmediate(sample);

                // Create Data from information
                NodeTypeData data = attr == null?                  // Switch between explicit information by the attribute or node information
                                    new NodeTypeData(className, Title, type, new Type[0]) :
                                    new NodeTypeData(className, attr.contextText, type, attr.limitToCanvasTypes);
                nodes.Add(className, data);
            }
        }
    }
コード例 #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="res"></param>
        /// <param name="modsList"></param>
        /// <returns></returns>
        private Node WriteMods(Resource res, List <Dos2Mod> modsList)
        {
            // Get Node to change
            Node Mods = res.Regions.First().Value.Children["Mods"].First();
            // get Dos2 mod
            Node dos2main = Mods.Children["ModuleShortDesc"].First(x => x.Attributes["Name"].Value.ToString() == "Divinity: Original Sin 2");
            // Get changes
            List <ModuleShortDesc> _modDescriptions = new List <ModuleShortDesc>();

            foreach (var item in modsList.Where(x => x.IsEnabled).ToList())
            {
                ModuleShortDesc temp = new ModuleShortDesc
                {
                    Folder  = item.Folder,
                    MD5     = item.MD5,
                    Name    = item.Name,
                    UUID    = item.UUID,
                    Version = item.Version
                };
                _modDescriptions.Add(temp);
            }
            // Write as LS.Node

            Dictionary <string, List <Node> > childrenDict = new Dictionary <string, List <Node> >();
            List <Node> children = new List <Node>();

            children.Add(dos2main);

            foreach (ModuleShortDesc item in _modDescriptions)
            {
                Dictionary <string, NodeAttribute> attributes = new Dictionary <string, NodeAttribute>();
                NodeAttribute Folder = new NodeAttribute(NodeAttribute.DataType.DT_LSWString)
                {
                    Value = item.Folder
                };
                attributes.Add("Folder", Folder);
                NodeAttribute MD5 = new NodeAttribute(NodeAttribute.DataType.DT_LSString)
                {
                    Value = item.MD5
                };
                attributes.Add("MD5", MD5);
                NodeAttribute Name = new NodeAttribute(NodeAttribute.DataType.DT_FixedString)
                {
                    Value = item.Name
                };
                attributes.Add("Name", Name);
                NodeAttribute UUID = new NodeAttribute(NodeAttribute.DataType.DT_FixedString)
                {
                    Value = item.UUID
                };
                attributes.Add("UUID", UUID);
                NodeAttribute Version = new NodeAttribute(NodeAttribute.DataType.DT_Int)
                {
                    Value = item.Version
                };
                attributes.Add("Version", Version);


                Node child = new Node
                {
                    Name       = "ModuleShortDesc",
                    Parent     = Mods,
                    Attributes = attributes,
                };
                children.Add(child);
            }
            childrenDict.Add("ModuleShortDesc", children);
            // write to resource
            Mods.Children = childrenDict;

            return(Mods);
        }
コード例 #6
0
 public void Diff_attributes_ignoring_value_case()
 {
     var actual = new NodeAttribute(123, "planet", "sAtUrN", 456);
     var expected = new NodeAttribute(123, "planet", "Saturn", 456);
     var diff = actual.Diff(expected, XmlPathRoot.Strict.Element(0), XmlPathRoot.Strict.Element(0), Options.IgnoreAttributesValueCase);
     Assert.IsTrue(diff.IsEmpty);
 }
コード例 #7
0
        private void ShowCreateNodeMenu()
        {
            List <string> showStrs = new List <string>();

            //控制节点
            List <Type> controlTypes = LCReflect.GetClassByType <NodeControl>();

            for (int i = 0; i < controlTypes.Count; i++)
            {
                NodeAttribute nodeAttribute = LCReflect.GetTypeAttr <NodeAttribute>(controlTypes[i]);
                if (nodeAttribute != null)
                {
                    showStrs.Add("控制节点/" + nodeAttribute.ViewName);
                }
                else
                {
                    showStrs.Add("控制节点/" + controlTypes[i].FullName);
                }
            }

            //行为节点
            List <Type> actionTypes     = LCReflect.GetClassByType <NodeAction>();
            List <Type> actionShowTypes = new List <Type>();

            for (int i = 0; i < actionTypes.Count; i++)
            {
                NodeAttribute nodeAttribute = LCReflect.GetTypeAttr <NodeAttribute>(actionTypes[i]);
                if (nodeAttribute == null)
                {
                    showStrs.Add("基础行为节点/" + nodeAttribute.ViewName);
                    actionShowTypes.Add(actionTypes[i]);
                }
                else
                {
                    if (nodeAttribute.IsCommonAction)
                    {
                        showStrs.Add("基础行为/" + nodeAttribute.ViewName);
                        actionShowTypes.Add(actionTypes[i]);
                    }
                    else
                    {
                        if (ShowDec)
                        {
                            if (nodeAttribute.IsBevNode == false)
                            {
                                showStrs.Add("扩展行为/" + nodeAttribute.ViewName);
                                actionShowTypes.Add(actionTypes[i]);
                            }
                        }
                        else
                        {
                            if (nodeAttribute.IsBevNode)
                            {
                                showStrs.Add("扩展行为/" + nodeAttribute.ViewName);
                                actionShowTypes.Add(actionTypes[i]);
                            }
                        }
                    }
                }
            }

            EDPopMenu.CreatePopMenu(showStrs, (int index) =>
            {
                Debug.Log("创建节点》》》》》》》》》" + index + "  " + controlTypes.Count + "   >>" + actionShowTypes.Count);
                //创建控制
                if (index <= controlTypes.Count - 1)
                {
                    NodeDataJson node = CreateNodeJson(NodeType.Control, controlTypes[index].FullName, showStrs[index], curMousePos);
                    //创建显示
                    NodeEditor nodeEditor = new NodeEditor(new Rect(new Vector2((float)node.PosX, (float)node.PosY), new Vector2(200, 100)), node, null, NodeEventCallBack);
                    showNodeEditor.Add(nodeEditor);
                    GUI.changed = true;
                }
                //创建行为
                else
                {
                    Debug.Log("创建行为节点》》》》》》》》》" + (index - controlTypes.Count));
                    NodeDataJson node = CreateNodeJson(NodeType.Action, actionShowTypes[index - controlTypes.Count].FullName, showStrs[index], curMousePos);
                    //创建显示
                    NodeEditor nodeEditor = new NodeEditor(new Rect(new Vector2((float)node.PosX, (float)node.PosY), new Vector2(200, 100)), node, null, NodeEventCallBack);
                    showNodeEditor.Add(nodeEditor);
                    GUI.changed = true;
                }
            });
        }
コード例 #8
0
 public BinaryExpression(NodeAttribute property, Operator op, NodeAttribute value)
 {
     _leftValue  = new PropertyLiteral(property);
     _operator   = op;
     _rightValue = new Literal(value);
 }
コード例 #9
0
 public void Diff_equal_attributes_with_different_index()
 {
     var actual = new NodeAttribute(123, "planet", "Saturn", 456);
     var expected = new NodeAttribute(456, "planet", "Saturn", 789);
     var diff = actual.Diff(expected, XmlPathRoot.Strict.Element(0), XmlPathRoot.Strict.Element(0), XmlOptions.Strict.Value);
     Assert.IsTrue(diff.IsEmpty);
 }
コード例 #10
0
 public virtual bool CheckIfStandardField(NodeAttribute attribute, string field)
 {
     return(attribute.Name.ToLower() == _fieldMappings.GetOrDefault(field).NullSafeToLower());
 }
コード例 #11
0
        private void AggregateAttribute(NodeAttribute node)
        {
            var output = new StringBuilder(" ");

            if (!node.IsFirst)
                output.Append(Ellipsis + " ");

            output.Append(FormatAttribute(node));

            if (!node.IsLast)
                output.Append(" " + Ellipsis);

            pendingAttribute = output.ToString();
        }
コード例 #12
0
        internal static string ToSerializedValue(this NodeAttribute value)
        {
            switch (value)
            {
            case NodeAttribute.NodeClass:
                return("NodeClass");

            case NodeAttribute.BrowseName:
                return("BrowseName");

            case NodeAttribute.DisplayName:
                return("DisplayName");

            case NodeAttribute.Description:
                return("Description");

            case NodeAttribute.WriteMask:
                return("WriteMask");

            case NodeAttribute.UserWriteMask:
                return("UserWriteMask");

            case NodeAttribute.IsAbstract:
                return("IsAbstract");

            case NodeAttribute.Symmetric:
                return("Symmetric");

            case NodeAttribute.InverseName:
                return("InverseName");

            case NodeAttribute.ContainsNoLoops:
                return("ContainsNoLoops");

            case NodeAttribute.EventNotifier:
                return("EventNotifier");

            case NodeAttribute.Value:
                return("Value");

            case NodeAttribute.DataType:
                return("DataType");

            case NodeAttribute.ValueRank:
                return("ValueRank");

            case NodeAttribute.ArrayDimensions:
                return("ArrayDimensions");

            case NodeAttribute.AccessLevel:
                return("AccessLevel");

            case NodeAttribute.UserAccessLevel:
                return("UserAccessLevel");

            case NodeAttribute.MinimumSamplingInterval:
                return("MinimumSamplingInterval");

            case NodeAttribute.Historizing:
                return("Historizing");

            case NodeAttribute.Executable:
                return("Executable");

            case NodeAttribute.UserExecutable:
                return("UserExecutable");

            case NodeAttribute.DataTypeDefinition:
                return("DataTypeDefinition");

            case NodeAttribute.RolePermissions:
                return("RolePermissions");

            case NodeAttribute.UserRolePermissions:
                return("UserRolePermissions");

            case NodeAttribute.AccessRestrictions:
                return("AccessRestrictions");
            }
            return(null);
        }
コード例 #13
0
ファイル: LSFWriter.cs プロジェクト: Norbyte/lslib
        private void WriteAttributeValue(BinaryWriter writer, NodeAttribute attr)
        {
            switch (attr.Type)
            {
                case NodeAttribute.DataType.DT_String:
                case NodeAttribute.DataType.DT_Path:
                case NodeAttribute.DataType.DT_FixedString:
                case NodeAttribute.DataType.DT_LSString:
                case NodeAttribute.DataType.DT_WString:
                case NodeAttribute.DataType.DT_LSWString:
                    WriteString(writer, (string)attr.Value);
                    break;

                case NodeAttribute.DataType.DT_TranslatedString:
                    var str = (TranslatedString)attr.Value;
                    WriteStringWithLength(writer, str.Value);
                    WriteStringWithLength(writer, str.Handle);
                    break;

                case NodeAttribute.DataType.DT_ScratchBuffer:
                    var buffer = (byte[])attr.Value;
                    writer.Write(buffer);
                    break;

                default:
                    BinUtils.WriteAttribute(writer, attr);
                    break;
            }
        }
コード例 #14
0
        private void CreateAbsoluteXpathsRecursivelyOnRequiredNodes(ref List <string> xpaths, NodeAttribute node, string currentXpath = "")
        {
            string nodeXpath = node.Xpath;

            if (currentXpath != "")
            {
                nodeXpath = nodeXpath.Replace("./", "/"); //removes relative prefix and prepares xpath for absolute path
            }
            currentXpath += nodeXpath;
            if (node.Attributes == null)
            {
                xpaths.Add(currentXpath);
            }
            else
            {
                foreach (var attribute in node.Attributes.Where(x => x.IsRequired == true))
                {
                    CreateAbsoluteXpathsRecursivelyOnRequiredNodes(ref xpaths, attribute, currentXpath);
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of the AttributeReadRequestApiModel
 /// class.
 /// </summary>
 /// <param name="nodeId">Node to read from or write to
 /// (mandatory)</param>
 /// <param name="attribute">Attribute to read or write. Possible values
 /// include: 'NodeClass', 'BrowseName', 'DisplayName', 'Description',
 /// 'WriteMask', 'UserWriteMask', 'IsAbstract', 'Symmetric',
 /// 'InverseName', 'ContainsNoLoops', 'EventNotifier', 'Value',
 /// 'DataType', 'ValueRank', 'ArrayDimensions', 'AccessLevel',
 /// 'UserAccessLevel', 'MinimumSamplingInterval', 'Historizing',
 /// 'Executable', 'UserExecutable', 'DataTypeDefinition',
 /// 'RolePermissions', 'UserRolePermissions',
 /// 'AccessRestrictions'</param>
 public AttributeReadRequestApiModel(string nodeId, NodeAttribute attribute)
 {
     NodeId    = nodeId;
     Attribute = attribute;
     CustomInit();
 }
コード例 #16
0
 public NodeXMLAttrViewModel(NodeAttribute attribute, NodeXMLViewModel parent)
 {
     Attribute = attribute;
     Parent    = parent;
 }
コード例 #17
0
ファイル: LSFReader.cs プロジェクト: Norbyte/lslib
        private NodeAttribute ReadAttribute(NodeAttribute.DataType type, BinaryReader reader, uint length)
        {
            // LSF and LSB serialize the buffer types differently, so specialized
            // code is added to the LSB and LSf serializers, and the common code is
            // available in BinUtils.ReadAttribute()
            switch (type)
            {
                case NodeAttribute.DataType.DT_String:
                case NodeAttribute.DataType.DT_Path:
                case NodeAttribute.DataType.DT_FixedString:
                case NodeAttribute.DataType.DT_LSString:
                case NodeAttribute.DataType.DT_WString:
                case NodeAttribute.DataType.DT_LSWString:
                { 
                    var attr = new NodeAttribute(type);
                    attr.Value = ReadString(reader, (int)length);
                    return attr;
                }

                case NodeAttribute.DataType.DT_TranslatedString:
                {
                    var attr = new NodeAttribute(type);
                    var str = new TranslatedString();
                    var valueLength = reader.ReadInt32();
                    str.Value = ReadString(reader, valueLength);
                    var handleLength = reader.ReadInt32();
                    str.Handle = ReadString(reader, handleLength);
                    attr.Value = str;
                    return attr;
                }

                case NodeAttribute.DataType.DT_ScratchBuffer:
                { 
                    var attr = new NodeAttribute(type);
                    attr.Value = reader.ReadBytes((int)length);
                    return attr;
                }

                default:
                    return BinUtils.ReadAttribute(type, reader);
            }
        }
コード例 #18
0
 // Description:
 // Return the whether a node has a particular attribute
 public Boolean getAttribute(NodeAttribute att)
 {
     return(m_Attributes.Contains(att));
 }
コード例 #19
0
        public void Customize(INode root, IDictionary <string, string> parameters, ILogger logger)
        {
            if (root.TryAttribute("mode", out var mode))
            {
                if (mode.Value.Equals("form"))
                {
                    var parameterCollection = root.SubNodes.FirstOrDefault(n => n.Name.Equals("parameters", StringComparison.OrdinalIgnoreCase));

                    if (parameterCollection != null)
                    {
                        var parameterNames = new HashSet <string>();

                        foreach (var node in parameterCollection.SubNodes)
                        {
                            if (node.TryAttribute("name", out var name))
                            {
                                parameterNames.Add(name.Value.ToString());
                            }
                        }

                        var entityCollection = root.SubNodes.FirstOrDefault(n => n.Name.Equals("entities", StringComparison.OrdinalIgnoreCase));
                        if (entityCollection != null)
                        {
                            foreach (var entity in entityCollection.SubNodes)
                            {
                                var fieldCollection = entity.SubNodes.FirstOrDefault(n => n.Name.Equals("fields", StringComparison.OrdinalIgnoreCase));
                                if (fieldCollection != null)
                                {
                                    foreach (var field in fieldCollection.SubNodes)
                                    {
                                        if (field.TryAttribute("name", out var name))
                                        {
                                            var add = false;
                                            if (field.TryAttribute("input", out var input))
                                            {
                                                if (input.Value.ToString().ToLower() == "true")
                                                {
                                                    add = true;
                                                }
                                            }
                                            else
                                            {
                                                add = true;
                                            }

                                            if (!parameterNames.Contains(name.Value) && add)
                                            {
                                                var node = new FormParameterNode("add");
                                                node.Attributes.Add(new NodeAttribute("name", name.Value));
                                                if (field.TryAttribute("default", out var def))
                                                {
                                                    NodeAttribute n = new NodeAttribute("value", null);
                                                    if (def.Value.ToString() == Constants.DefaultSetting)
                                                    {
                                                        n.Value = string.Empty;
                                                    }
                                                    else
                                                    {
                                                        n.Value = def.Value;
                                                    }
                                                    node.Attributes.Add(n);
                                                }
                                                else
                                                {
                                                    node.Attributes.Add(new NodeAttribute("value", string.Empty));
                                                }
                                                node.Attributes.Add(new NodeAttribute("label", "n/a"));
                                                node.Attributes.Add(new NodeAttribute("invalid-characters", string.Empty));

                                                if (field.TryAttribute("type", out var type))
                                                {
                                                    if (type != null && type.Value != null && type.Value.ToString().ToLower().StartsWith("bool"))
                                                    {
                                                        node.Attributes.Add(new NodeAttribute("type", "bool"));
                                                    }
                                                }

                                                parameterCollection.SubNodes.Add(node);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            _after.Customize(root, parameters, logger);
        }
コード例 #20
0
ファイル: PropertyLiteral.cs プロジェクト: pchaozhong/FlexNet
 public PropertyLiteral(NodeAttribute nodeAttribute)
 {
     _nodeAttribute = nodeAttribute;
 }
コード例 #21
0
        /// <summary>
        /// Extract NodeField information from class reflection + attributes
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        private static NodeReflectionData LoadClassReflection(Type type, NodeAttribute nodeAttr)
        {
            string name = nodeAttr.name ?? type.Name;
            string path = nodeAttr.module;

            var node = new NodeReflectionData()
            {
                type    = type,
                path    = path?.Split('/'),
                name    = name,
                tooltip = nodeAttr.help
            };

            var fields = new List <FieldInfo>(type.GetFields(
                                                  BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance
                                                  ));

            // Iterate through inherited private fields as well
            var temp = type;

            while ((temp = temp.BaseType) != typeof(AbstractNode))
            {
                fields.AddRange(temp.GetFields(BindingFlags.NonPublic | BindingFlags.Instance));
            }

            // Extract port and editable metadata from each tagged field
            var ports = new List <PortReflectionData>();

            for (int i = 0; i < fields.Count; i++)
            {
                object[] attribs = fields[i].GetCustomAttributes(true);
                for (int j = 0; j < attribs.Length; j++)
                {
                    if (attribs[j] is InputAttribute)
                    {
                        var attr = attribs[j] as InputAttribute;

                        node.ports.Add(new PortReflectionData()
                        {
                            type       = fields[i].FieldType,
                            portName   = attr.name ?? ObjectNames.NicifyVariableName(fields[i].Name),
                            fieldName  = fields[i].Name,
                            isInput    = true,
                            isMulti    = attr.multiple,
                            isEditable = attr.editable
                        });
                    }
                    else if (attribs[j] is OutputAttribute)
                    {
                        var attr = attribs[j] as OutputAttribute;

                        node.ports.Add(new PortReflectionData()
                        {
                            type       = fields[i].FieldType,
                            portName   = attr.name ?? ObjectNames.NicifyVariableName(fields[i].Name),
                            fieldName  = fields[i].Name,
                            isInput    = false,
                            isMulti    = attr.multiple,
                            isEditable = false
                        });
                    }
                    else if (attribs[j] is EditableAttribute)
                    {
                        var attr = attribs[j] as EditableAttribute;

                        node.editables.Add(new EditableReflectionData()
                        {
                            type      = fields[i].FieldType,
                            fieldName = fields[i].Name
                        });
                    }
                }
            }

            return(node);
        }
コード例 #22
0
ファイル: SearchOrder.cs プロジェクト: maxpavlov/FlexNet
		internal SearchOrder(NodeAttribute propertyToOrder, OrderDirection direction)
		{
			_propertyToOrder = new PropertyLiteral(propertyToOrder);
			_direction = direction;
		}
コード例 #23
0
ファイル: BinaryExpression.cs プロジェクト: maxpavlov/FlexNet
		public BinaryExpression(NodeAttribute property, Operator op, NodeAttribute value)
		{
			_leftValue = new PropertyLiteral(property);
			_operator = op;
			_rightValue = new Literal(value);
		}
コード例 #24
0
 private static string FormatAttribute(NodeAttribute node)
 {
     return(String.Format("{0}='{1}'", node.Name, node.Value));
 }
コード例 #25
0
ファイル: ActiveSchema.cs プロジェクト: maxpavlov/FlexNet
        /// <summary>
        /// Gets the type of the node attribute data.
        /// </summary>
        /// <param name="attributeName">Name of the attribute.</param>
        /// <returns></returns>
		public static DataType GetNodeAttributeDataType(NodeAttribute attribute)
		{
			DataType result;
			if (_nodeAttributeDataTypes.TryGetValue(attribute, out result))
				return result;
			throw new NotImplementedException(String.Concat(SR.Exceptions.Schema.Msg_NodeAttributeDoesNotEsist, " ", attribute));
		}
コード例 #26
0
ファイル: PropertyLiteral.cs プロジェクト: maxpavlov/FlexNet
		public PropertyLiteral(NodeAttribute nodeAttribute)
		{
			_nodeAttribute = nodeAttribute;
		}
コード例 #27
0
 private static string FormatAttribute(NodeAttribute node)
 {
     return String.Format("{0}='{1}'", node.Name, node.Value);
 }
コード例 #28
0
        public void Diff_with_null_expected_value_should_throw_exception()
        {
            var actual = new NodeAttribute(123, "planet", "Saturn", 456);

            actual.Diff(null, XmlPathRoot.Strict.Element(0), XmlPathRoot.Strict.Element(0), XmlOptions.Strict.Value);
        }
コード例 #29
0
 public ServerMonitorKey(NodeId nodeId, NodeAttribute attribute)
 {
     this.NodeId    = nodeId;
     this.Attribute = attribute;
 }
コード例 #30
0
ファイル: Graph.cs プロジェクト: muba24/flumin-master
 void IAttributable.AddAttribute(NodeAttribute attr)
 {
     _attributes.Add(attr.Name, attr);
 }
コード例 #31
0
 public void Diff_with_null_pathExpected_should_throw_exception()
 {
     var actual = new NodeAttribute(123, "planet", "Saturn", 456);
     var expected = new NodeAttribute(123, "planet", "Saturn", 456);
     actual.Diff(expected, XmlPathRoot.Strict.Element(0), null, XmlOptions.Strict.Value);
 }
コード例 #32
0
ファイル: SnLucCompiler.cs プロジェクト: kimduquan/DMIS
        private string CompileNodeAttribute(NodeAttribute attr)
        {
            switch (attr)
            {
            case NodeAttribute.Id: return(LucObject.FieldName.NodeId);

            case NodeAttribute.IsDeleted: return(LucObject.FieldName.IsDeleted);

            case NodeAttribute.IsInherited: return(LucObject.FieldName.IsInherited);

            case NodeAttribute.ParentId: return(LucObject.FieldName.ParentId);

            case NodeAttribute.Parent: return(LucObject.FieldName.ParentId);

            case NodeAttribute.Name: return(LucObject.FieldName.Name);

            case NodeAttribute.Path: return(LucObject.FieldName.Path);

            case NodeAttribute.Index: return(LucObject.FieldName.Index);

            case NodeAttribute.Locked: return(LucObject.FieldName.Locked);

            case NodeAttribute.LockedById: return(LucObject.FieldName.LockedById);

            case NodeAttribute.LockedBy: return(LucObject.FieldName.LockedById);

            case NodeAttribute.ETag: return(LucObject.FieldName.ETag);

            case NodeAttribute.LockType: return(LucObject.FieldName.LockType);

            case NodeAttribute.LockTimeout: return(LucObject.FieldName.LockTimeout);

            case NodeAttribute.LockDate: return(LucObject.FieldName.LockDate);

            case NodeAttribute.LockToken: return(LucObject.FieldName.LockToken);

            case NodeAttribute.LastLockUpdate: return(LucObject.FieldName.LastLockUpdate);

            case NodeAttribute.MajorVersion: return(LucObject.FieldName.MajorNumber);

            case NodeAttribute.MinorVersion: return(LucObject.FieldName.MinorNumber);

            case NodeAttribute.CreationDate: return(LucObject.FieldName.CreationDate);

            case NodeAttribute.CreatedById: return(LucObject.FieldName.CreatedById);

            case NodeAttribute.CreatedBy: return(LucObject.FieldName.CreatedById);

            case NodeAttribute.ModificationDate: return(LucObject.FieldName.ModificationDate);

            case NodeAttribute.ModifiedById: return(LucObject.FieldName.ModifiedById);

            case NodeAttribute.ModifiedBy: return(LucObject.FieldName.ModifiedById);

            case NodeAttribute.IsSystem: return(LucObject.FieldName.IsSystem);

            case NodeAttribute.ClosestSecurityNodeId: return(LucObject.FieldName.ClosestSecurityNodeId);

            case NodeAttribute.SavingState: return(LucObject.FieldName.SavingState);

            default:
                throw new NotSupportedException(String.Concat("NodeAttribute attr = ", attr, ")"));
            }
        }
コード例 #33
0
 public void Diff_attributes_with_name_differing_by_case()
 {
     var actual = new NodeAttribute(123, "planet", "Saturn", 456);
     var expected = new NodeAttribute(123, "PLANET", "Saturn", 456);
     var diff = actual.Diff(expected, XmlPathRoot.Strict.Element(0), XmlPathRoot.Strict.Element(0), XmlOptions.Strict.Value);
     AssertDiff(diff, new Diff(DiffType.UnexpectedAttribute, XmlPathRoot.Strict.Element(0).Attribute(123), DiffTargets.Actual));
 }
コード例 #34
0
ファイル: SearchOrder.cs プロジェクト: sztomi/sensenet
 internal SearchOrder(NodeAttribute propertyToOrder, OrderDirection direction)
 {
     _propertyToOrder = new PropertyLiteral(propertyToOrder);
     _direction       = direction;
 }
コード例 #35
0
 public void Diff_attributes_with_different_value()
 {
     var actual = new NodeAttribute(123, "planet", "Jupiter", 456);
     var expected = new NodeAttribute(123, "planet", "Saturn", 456);
     var diff = actual.Diff(expected, XmlPathRoot.Strict.Element(0), XmlPathRoot.Strict.Element(0), XmlOptions.Strict.Value);
     AssertDiff(diff, new Diff(DiffType.MismatchedAttribute, XmlPathRoot.Strict.Element(0).Attribute(123), DiffTargets.Both));
 }
コード例 #36
0
ファイル: ObjectParserActor.cs プロジェクト: Sven1106/Portia
        private JToken GetValueForJTokenRecursively(NodeAttribute node, HtmlNode htmlNode) // TODO: see if it is possible to use the same HTMLNode/Htmldocument through out the extractions.
        {
            JToken jToken = "";

            if (node.GetMultipleFromPage)
            {
                JArray jArray = new JArray();
                if (node.Type == NodeType.String || node.Type == NodeType.Number || node.Type == NodeType.Boolean) // basic types
                {
                    HtmlNodeCollection elements = htmlNode.SelectNodes(node.Xpath);
                    if (elements != null)
                    {
                        foreach (var element in elements)
                        {
                            HtmlNodeNavigator navigator = (HtmlNodeNavigator)element.CreateNavigator();
                            if (navigator.Value.Trim() == "")
                            {
                                continue;
                            }
                            jArray.Add(navigator.Value.Trim());
                        }
                        jToken = jArray;
                    }
                }
                else if (node.Type == NodeType.Object && node.Attributes.Count > 0) // complex types
                {
                    JObject            jObject  = new JObject();
                    HtmlNodeCollection elements = htmlNode.SelectNodes(node.Xpath);
                    if (elements != null)
                    {
                        foreach (var element in elements)
                        {
                            foreach (var attribute in node.Attributes)
                            {
                                JToken value = GetValueForJTokenRecursively(attribute, element);
                                if (value.ToString() == "" && attribute.IsRequired)
                                {
                                    return(jToken);
                                }
                                jObject.Add(attribute.Name, value);
                            }
                            jArray.Add(jObject);
                        }
                        jToken = jArray;
                    }
                }
            }
            else
            {
                HtmlNodeNavigator navigator = (HtmlNodeNavigator)htmlNode.CreateNavigator();
                if (node.Type == NodeType.String || node.Type == NodeType.Number || node.Type == NodeType.Boolean) // basic types
                {
                    XPathNavigator nodeFound = navigator.SelectSingleNode(node.Xpath);
                    // Get as Type
                    if (nodeFound != null)
                    {
                        if (nodeFound.Value.Trim() == "")
                        {
                            return(jToken);
                        }
                        jToken = nodeFound.Value.Trim();
                    }
                }
                else if (node.Type == NodeType.Object && node.Attributes.Count > 0) // complex types
                {
                    HtmlNode element = htmlNode.SelectSingleNode(node.Xpath);
                    if (element != null)
                    {
                        JObject jObject = new JObject();
                        foreach (var attribute in node.Attributes)
                        {
                            JToken value = GetValueForJTokenRecursively(attribute, element);
                            if (value.ToString() == "" && attribute.IsRequired)
                            {
                                return(jToken);
                            }
                            jObject.Add(attribute.Name, value);
                        }
                        jToken = jObject;
                    }
                }
            }
            return(jToken);
        }
コード例 #37
0
 public void AreValuesEqual(string othervalue, Options options, bool expected)
 {
     var attribute = new NodeAttribute(123, "planet", "Saturn", 456);
     bool actual = attribute.AreValuesEqual(othervalue, options);
     Assert.AreEqual(expected, actual);
 }
コード例 #38
0
ファイル: Literal.cs プロジェクト: maxpavlov/FlexNet
		public Literal(NodeAttribute nodeAttribute) : base(nodeAttribute) { }
コード例 #39
0
ファイル: Literal.cs プロジェクト: kimduquan/DMIS
 public Literal(NodeAttribute nodeAttribute) : base(nodeAttribute)
 {
 }
コード例 #40
0
ファイル: ReadValueId.cs プロジェクト: madagaga/LibUA
 public ReadValueId(NodeId NodeId, NodeAttribute AttributeId)
     : this(NodeId, AttributeId, null, new QualifiedName(0, null))
 {
 }
コード例 #41
0
ファイル: SnLucCompiler.cs プロジェクト: jhuntsman/FlexNet
 private string CompileNodeAttribute(NodeAttribute attr)
 {
     switch (attr)
     {
         case NodeAttribute.Id: return LucObject.FieldName.NodeId;
         case NodeAttribute.IsDeleted: return LucObject.FieldName.IsDeleted;
         case NodeAttribute.IsInherited: return LucObject.FieldName.IsInherited;
         case NodeAttribute.ParentId: return LucObject.FieldName.ParentId;
         case NodeAttribute.Parent: return LucObject.FieldName.ParentId;
         case NodeAttribute.Name: return LucObject.FieldName.Name;
         case NodeAttribute.Path: return LucObject.FieldName.Path;
         case NodeAttribute.Index: return LucObject.FieldName.Index;
         case NodeAttribute.Locked: return LucObject.FieldName.Locked;
         case NodeAttribute.LockedById: return LucObject.FieldName.LockedById;
         case NodeAttribute.LockedBy: return LucObject.FieldName.LockedById;
         case NodeAttribute.ETag: return LucObject.FieldName.ETag;
         case NodeAttribute.LockType: return LucObject.FieldName.LockType;
         case NodeAttribute.LockTimeout: return LucObject.FieldName.LockTimeout;
         case NodeAttribute.LockDate: return LucObject.FieldName.LockDate;
         case NodeAttribute.LockToken: return LucObject.FieldName.LockToken;
         case NodeAttribute.LastLockUpdate: return LucObject.FieldName.LastLockUpdate;
         case NodeAttribute.MajorVersion: return LucObject.FieldName.MajorNumber;
         case NodeAttribute.MinorVersion: return LucObject.FieldName.MinorNumber;
         case NodeAttribute.CreationDate: return LucObject.FieldName.CreationDate;
         case NodeAttribute.CreatedById: return LucObject.FieldName.CreatedById;
         case NodeAttribute.CreatedBy: return LucObject.FieldName.CreatedById;
         case NodeAttribute.ModificationDate: return LucObject.FieldName.ModificationDate;
         case NodeAttribute.ModifiedById: return LucObject.FieldName.ModifiedById;
         case NodeAttribute.ModifiedBy: return LucObject.FieldName.ModifiedById;
         default:
             throw new NotSupportedException(String.Concat("NodeAttribute attr = ", attr, ")"));
     }
 }
コード例 #42
0
    public void Bind()
    {
        if (component == null)
        {
            return;
        }
        this.name        = component.GetType().Name;
        serializedObject = new SerializedObject(component);
        SerializedProperty prop = serializedObject.GetIterator();

        int count = 0;

        if (prop.NextVisible(true))
        {
            do
            {
                //if (prop.GetType() == typeof(Vector3))
                {
                    if (prop.name == "m_Script")
                    {
                        continue;//TODO: Fix HACK
                    }
                    count++;
                }
            }while (prop.NextVisible(false));
        }
        __input    = new NodePort[count];
        __output   = new NodePort[count];
        __isInput  = new bool[count];
        __isOutput = new bool[count];
        __isShown  = new bool[count];
        properties = new SerializedProperty[count];
        int idx = 0;

        prop = serializedObject.GetIterator();
        if (prop.NextVisible(true))
        {
            do
            {
                if (prop.name == "m_Script")
                {
                    continue;//TODO: Fix HACK
                }

                __input[idx]  = null;
                __output[idx] = null;

                __isInput[idx]  = false;
                __isOutput[idx] = false;
                __isShown[idx]  = true;
                System.Reflection.PropertyInfo info = component.GetType().GetProperty(prop.name);
                if (info != null)
                {
                    object[] attributes = info.GetCustomAttributes(true);
                    foreach (object a in attributes)
                    {
                        NodeAttribute attribute = a as NodeAttribute;
                        if (attribute != null)
                        {
                            if (attribute as NodeAttribute.Input != null)
                            {
                                __isInput[idx] = true;
                            }
                            if (attribute as NodeAttribute.Output != null)
                            {
                                __isOutput[idx] = true;
                            }
                        }
                    }
                }

                properties[idx] = serializedObject.FindProperty(prop.propertyPath);
                __input[idx]    = AddInstanceInput(prop.GetType(), ConnectionType.Override, "-> " + prop.name);
                __output[idx]   = AddInstanceOutput(prop.GetType(), ConnectionType.Multiple, prop.name + " ->");
                ++idx;
            }while (prop.NextVisible(false));
        }
    }