internal static T GetField <T>(INode_Accessor accessor, string fieldName, int field_name_idx)
        {
            uint member_id;
            int  field_divider_idx = fieldName.IndexOf('.', field_name_idx);

            if (-1 != field_divider_idx)
            {
                string member_name_string = fieldName.Substring(field_name_idx, field_divider_idx - field_name_idx);
                if (!FieldLookupTable_INode.TryGetValue(member_name_string, out member_id))
                {
                    Throw.undefined_field();
                }
                switch (member_id)
                {
                default:
                    Throw.member_access_on_non_struct__field(member_name_string);
                    break;
                }
            }
            fieldName = fieldName.Substring(field_name_idx);
            if (!FieldLookupTable_INode.TryGetValue(fieldName, out member_id))
            {
                Throw.undefined_field();
            }
            switch (member_id)
            {
            case 0:
                return(TypeConverter <T> .ConvertFrom_NodeType(accessor.TypeOfNode));

                break;

            case 1:
                return(TypeConverter <T> .ConvertFrom_long(accessor.GraphParent));

                break;

            case 2:
                return(TypeConverter <T> .ConvertFrom_string(accessor.GraphUri));

                break;

            case 3:
                return(TypeConverter <T> .ConvertFrom_long(accessor.HashCode));

                break;
            }
            /* Should not reach here */
            throw new Exception("Internal error T5008");
        }
Пример #2
0
        internal unsafe Triple_Accessor(byte *_CellPtr

                                        , ResizeFunctionDelegate func
                                        )
        {
            m_ptr = _CellPtr;

            ResizeFunction             = func;
            SubjectNode_Accessor_Field = new INode_Accessor(null,
                                                            (ptr, ptr_offset, delta) =>
            {
                int substructure_offset = (int)(ptr - this.m_ptr);
                this.m_ptr = this.ResizeFunction(this.m_ptr, ptr_offset + substructure_offset, delta);
                return(this.m_ptr + substructure_offset);
            });        PredicateNode_Accessor_Field = new INode_Accessor(null,
                                                                         (ptr, ptr_offset, delta) =>
            {
                int substructure_offset = (int)(ptr - this.m_ptr);
                this.m_ptr = this.ResizeFunction(this.m_ptr, ptr_offset + substructure_offset, delta);
                return(this.m_ptr + substructure_offset);
            });        ObjectNode_Accessor_Field = new INode_Accessor(null,
                                                                      (ptr, ptr_offset, delta) =>
            {
                int substructure_offset = (int)(ptr - this.m_ptr);
                this.m_ptr = this.ResizeFunction(this.m_ptr, ptr_offset + substructure_offset, delta);
                return(this.m_ptr + substructure_offset);
            });        Url_Accessor_Field = new StringAccessor(null,
                                                               (ptr, ptr_offset, delta) =>
            {
                int substructure_offset = (int)(ptr - this.m_ptr);
                this.m_ptr = this.ResizeFunction(this.m_ptr, ptr_offset + substructure_offset, delta);
                return(this.m_ptr + substructure_offset);
            });        Nodes_Accessor_Field = new INode_AccessorListAccessor(null,
                                                                             (ptr, ptr_offset, delta) =>
            {
                int substructure_offset = (int)(ptr - this.m_ptr);
                this.m_ptr = this.ResizeFunction(this.m_ptr, ptr_offset + substructure_offset, delta);
                return(this.m_ptr + substructure_offset);
            });
        }
        internal static void SetField <T>(INode_Accessor accessor, string fieldName, int field_name_idx, T value)
        {
            uint member_id;
            int  field_divider_idx = fieldName.IndexOf('.', field_name_idx);

            if (-1 != field_divider_idx)
            {
                string member_name_string = fieldName.Substring(field_name_idx, field_divider_idx - field_name_idx);
                if (!FieldLookupTable_INode.TryGetValue(member_name_string, out member_id))
                {
                    Throw.undefined_field();
                }
                switch (member_id)
                {
                default:
                    Throw.member_access_on_non_struct__field(member_name_string);
                    break;
                }
                return;
            }
            fieldName = fieldName.Substring(field_name_idx);
            if (!FieldLookupTable_INode.TryGetValue(fieldName, out member_id))
            {
                Throw.undefined_field();
            }
            switch (member_id)
            {
            case 0:
            {
                NodeType conversion_result = TypeConverter <T> .ConvertTo_NodeType(value);

                {
                    accessor.TypeOfNode = conversion_result;
                }

                break;
            }

            case 1:
            {
                long conversion_result = TypeConverter <T> .ConvertTo_long(value);

                {
                    accessor.GraphParent = conversion_result;
                }

                break;
            }

            case 2:
            {
                string conversion_result = TypeConverter <T> .ConvertTo_string(value);

                {
                    accessor.GraphUri = conversion_result;
                }

                break;
            }

            case 3:
            {
                long conversion_result = TypeConverter <T> .ConvertTo_long(value);

                {
                    accessor.HashCode = conversion_result;
                }

                break;
            }
            }
        }