Beispiel #1
0
        private DataRow AddRow(DataTable table, IVariable var)
        {
            DataRow row = table.NewRow();

            row[ColumnNames.NAME]            = var.Name;
            row[ColumnNames.DATA_TYPE]       = var.DataType;
            row[ColumnNames.VARIABLE_SCOPE]  = var.VarType;
            row[ColumnNames.VARIABLE_VALUE]  = var.Expression;
            row[ColumnNames.ADDITIONAL_INFO] = string.Empty;
            row[ColumnNames.PROMPT]          = string.Empty;

            // Data source variables have an extra piece of information: Table name
            if (var is IDataSourceVariable)
            {
                IDataSourceVariable dataSourceVar = var as IDataSourceVariable;
                row[ColumnNames.DATA_TABLE_NAME] = dataSourceVar.TableName;
            }

            // Data field variables know the field type.
            if (var is IDataField)
            {
                IDataField dataField = var as IDataField;
                row[ColumnNames.FIELD_TYPE_ID] = dataField.FieldType;
            }

            table.Rows.Add(row);
            return(row);
        }
Beispiel #2
0
 public TreeNavigator SetValues <T1, T2, T3> (IDataField <T1> column1, T1 value1, IDataField <T2> column2, T2 value2, IDataField <T3> column3, T3 value3)
 {
     SetValue(column1, value1);
     SetValue(column2, value2);
     SetValue(column3, value3);
     return(this);
 }
Beispiel #3
0
		public static void MapNestedArray(this LightDBDefinitionSet defs, IDataField dataField, IDataFieldDefinition fieldDef,
			Dictionary<string, List<SimpleDataColumn>> mappedFields)
		{
			var arrField = (NestedArrayFieldDefinition)fieldDef;
			var arrDataField = (NestedArrayDataField)dataField;

			var defaultTables = defs.EnsureTables(arrField.Table, dataField.DataHolderDefinition);
			var segments = arrField.Segments;

			for (var i = 0; i < segments.Length; i++)
			{
				var segment = segments[i];
				var cols = segment.GetColumns(arrDataField.Length);

				for (var j = 0; j < cols.Length; j++)
				{
					var col = cols[j];
					var arrAccessor = (NestedArrayAccessor)arrDataField.ArrayAccessors[j];

					IDataField fieldAccessor;
					if (!arrAccessor.InnerFields.TryGetValue(segment.Name, out fieldAccessor))
					{
						throw new DataHolderException("NestedArray definition {0} refered to non-existing field {1}", arrDataField,
													  segment);
					}

					AddMapping(defs, defaultTables, col, mappedFields,
						(IFlatDataFieldAccessor)fieldAccessor, fieldAccessor.MappedMember);
				}
			}
		}
        private static Stack <IDataField> GetPath(IDataField source)
        {
            Stack <IDataField> path = new Stack <IDataField>();

            if (source == null)
            {
                return(path);
            }

            var pointer = source;

            while (pointer != null)
            {
                //以下代码是防止死循环的关键代码
                //我们会将当前的pointer与this.MemberField做比较,检查是否为同一个引用点
                //如果是,那么就清理之前的记录的路径path,重新记录
                //这样就可以避免类似ment.parent.parent.parent的死循环了
                if (IsRepeatedReferencePoint(pointer, source))
                {
                    path.Clear();
                }

                path.Push(pointer);
                pointer = pointer.ParentMemberField;
            }
            return(path);
        }
 public ObjectChain(IDataField source)
 {
     _source       = source;
     _path         = GetPath(source);
     this.PathCode = GetPathCode();
     _getPathCode  = LazyIndexer.Init <DataTable, string>(GetPathCodeImpl);
 }
Beispiel #6
0
 public TreeNavigator SetValues <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> (
     IDataField <T1> column1, T1 value1,
     IDataField <T2> column2, T2 value2,
     IDataField <T3> column3, T3 value3,
     IDataField <T4> column4, T4 value4,
     IDataField <T5> column5, T5 value5,
     IDataField <T6> column6, T6 value6,
     IDataField <T7> column7, T7 value7,
     IDataField <T8> column8, T8 value8,
     IDataField <T9> column9, T9 value9,
     IDataField <T10> column10, T10 value10
     )
 {
     SetValue(column1, value1);
     SetValue(column2, value2);
     SetValue(column3, value3);
     SetValue(column4, value4);
     SetValue(column5, value5);
     SetValue(column6, value6);
     SetValue(column7, value7);
     SetValue(column8, value8);
     SetValue(column9, value9);
     SetValue(column10, value10);
     return(this);
 }
Beispiel #7
0
        public static void MapNestedArray(this LightDBDefinitionSet defs, IDataField dataField,
                                          IDataFieldDefinition fieldDef, Dictionary <string, List <SimpleDataColumn> > mappedFields)
        {
            NestedArrayFieldDefinition arrayFieldDefinition = (NestedArrayFieldDefinition)fieldDef;
            NestedArrayDataField       nestedArrayDataField = (NestedArrayDataField)dataField;

            TableDefinition[] defaultTables =
                defs.EnsureTables(arrayFieldDefinition.Table, dataField.DataHolderDefinition);
            foreach (FlatArrayFieldDefinition segment in arrayFieldDefinition.Segments)
            {
                SimpleFlatFieldDefinition[] columns = segment.GetColumns(nestedArrayDataField.Length);
                for (int index = 0; index < columns.Length; ++index)
                {
                    SimpleFlatFieldDefinition fieldDef1 = columns[index];
                    IDataField dataField1;
                    if (!((NestedArrayAccessor)nestedArrayDataField.ArrayAccessors[index]).InnerFields.TryGetValue(
                            segment.Name, out dataField1))
                    {
                        throw new DataHolderException("NestedArray definition {0} refered to non-existing field {1}",
                                                      (object)nestedArrayDataField, (object)segment);
                    }
                    AddMapping(defs, defaultTables, fieldDef1, mappedFields,
                               (IFlatDataFieldAccessor)dataField1, dataField1.MappedMember);
                }
            }
        }
Beispiel #8
0
        private static string GetFieldSql(IDataField field)
        {
            bool allowNull = field.Tip.IsEmptyable || field.IsAdditional;


            if (field.DbType == DbType.String)
            {
                var maxLength = field.Tip.GetMaxLength();
                var isASCII   = field.Tip.IsASCIIString();
                return(string.Format("[{0}] [{1}]({2}) {3} NULL,", field.Name,
                                     isASCII ? "varchar" : "nvarchar",
                                     maxLength == 0 ? "max" : maxLength.ToString(),
                                     allowNull ? string.Empty : "NOT"));
            }
            else if (field.DbType == DbType.AnsiString)
            {
                var maxLength = field.Tip.GetMaxLength();
                var isASCII   = true;
                return(string.Format("[{0}] [{1}]({2}) {3} NULL,", field.Name,
                                     isASCII ? "varchar" : "nvarchar",
                                     maxLength == 0 ? "max" : maxLength.ToString(),
                                     allowNull ? string.Empty : "NOT"));
            }
            else
            {
                return(string.Format("[{0}] [{1}] {2} NULL,", field.Name,
                                     Util.GetSqlDbTypeString(field.DbType),
                                     allowNull ? string.Empty : "NOT"));
            }
        }
Beispiel #9
0
		public static void MapNestedSimple(this LightDBDefinitionSet defs, IDataField dataField, IDataFieldDefinition fieldDef,
			Dictionary<string, List<SimpleDataColumn>> mappedFields)
		{
			var nestedFieldDefinition = ((INestedFieldDefinition)fieldDef);
			nestedFieldDefinition.EnsureFieldsNotNull(dataField.DataHolderDefinition.Name);
			defs.AddFieldMappings(nestedFieldDefinition.Fields, ((NestedSimpleDataField)dataField).InnerFields, mappedFields);
		}
Beispiel #10
0
		public static void MapFlatSimple(this LightDBDefinitionSet defs, IDataField dataField, IDataFieldDefinition fieldDef,
			Dictionary<string, List<SimpleDataColumn>> mappedFields)
		{
			var tableField = ((SimpleFlatFieldDefinition)fieldDef);
			AddMapping(defs, defs.GetDefaultTables(dataField.DataHolderDefinition), tableField, mappedFields,
				(FlatSimpleDataField)dataField, dataField.MappedMember);
		}
Beispiel #11
0
 private static DataFieldDefinition CreateFlatSimple(IDataField dataField)
 {
     return(new SimpleFlatFieldDefinition {
         Name = dataField.Name,
         Column = ""
     });
 }
Beispiel #12
0
 public void SetValues <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> (
     int row,
     IDataField <T1> column1, T1 value1,
     IDataField <T2> column2, T2 value2,
     IDataField <T3> column3, T3 value3,
     IDataField <T4> column4, T4 value4,
     IDataField <T5> column5, T5 value5,
     IDataField <T6> column6, T6 value6,
     IDataField <T7> column7, T7 value7,
     IDataField <T8> column8, T8 value8,
     IDataField <T9> column9, T9 value9,
     IDataField <T10> column10, T10 value10
     )
 {
     SetValue(row, column1, value1);
     SetValue(row, column2, value2);
     SetValue(row, column3, value3);
     SetValue(row, column4, value4);
     SetValue(row, column5, value5);
     SetValue(row, column6, value6);
     SetValue(row, column7, value7);
     SetValue(row, column8, value8);
     SetValue(row, column9, value9);
     SetValue(row, column10, value10);
 }
Beispiel #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Sharpend.Xwt.XwtTreeList"/> class.
        /// </summary>
        /// <param name='tree'>
        /// Tree.
        /// </param>
        /// <param name='xml'>
        /// xml definition for the grid or the resource name for the xml
        /// </param>
        /// <param name='isResource'>
        /// if true param xml is a resourcename
        /// </param>
        public XwtTreeList(TreeView tree, String xml, bool isResource = true) : this(tree)
        {
            Fields     = createDataFields(xml, isResource);
            navigators = new Dictionary <TreeNavigator, VirtualGridRow>(100);
            //create the treestore
            IDataField[] df = new IDataField[Fields.Length + 1];
            for (int i = 0; i < Fields.Length; i++)
            {
                df[i] = Fields[i].Field;
            }
            df[Fields.Length] = new DataField <VirtualTreeRow>();
            DataStore         = new TreeStore(df);

            //add columns to the tree
            //foreach (DatafieldContainer dc in Fields)
            for (int i = 0; i < (Fields.Length - 1); i++)
            {
                DatafieldContainer dc = Fields[i];
                Tree.Columns.Add(dc.Title, dc.Field);
                //tree.
                //Tree.Columns.Add(itm);
                //Tree.ButtonPressed += HandleButtonPressed;
            }


            Tree.DataSource = DataStore;
        }
Beispiel #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Sharpend.Xwt.XwtTreeList"/> class.
        /// </summary>
        /// <param name='tree'>
        /// Tree.
        /// </param>
        /// <param name='xml'>
        /// xml definition for the grid or the resource name for the xml
        /// </param>
        /// <param name='isResource'>
        /// if true param xml is a resourcename
        /// </param>
        public XwtTreeList(TreeView tree,String xml, bool isResource=true)
            : this(tree)
        {
            Fields = createDataFields(xml,isResource);
            navigators = new Dictionary<TreeNavigator, VirtualGridRow>(100);
            //create the treestore
            IDataField[] df = new IDataField[Fields.Length+1];
            for (int i=0;i<Fields.Length;i++)
            {
                df[i] = Fields[i].Field;
            }
            df[Fields.Length] = new DataField<VirtualTreeRow>();
            DataStore = new TreeStore(df);

            //add columns to the tree
            //foreach (DatafieldContainer dc in Fields)
            for (int i=0;i<(Fields.Length-1);i++)
            {
                DatafieldContainer dc = Fields[i];
                Tree.Columns.Add(dc.Title,dc.Field);
                //tree.
                //Tree.Columns.Add(itm);
                //Tree.ButtonPressed += HandleButtonPressed;
            }

            Tree.DataSource = DataStore;
        }
Beispiel #15
0
        /// <summary>
        /// 类似List(int)这样的值成员的集合所对应的表
        /// </summary>
        /// <param name="root"></param>
        /// <param name="master"></param>
        /// <param name="memberField"></param>
        /// <param name="objectType"></param>
        /// <returns></returns>
        private static DataTable CreateValueListTable(DataTable root, DataTable master, IDataField memberField, Type objectType)
        {
            var    valueListField = memberField as ValueListField;
            string tableName      = string.Format("{0}_{1}", master.Name, memberField.Name);

            IDataField[] fields        = null;
            var          reflectedType = valueListField.GetReflectedType(); //就算集合的成员类型各自不同,但是他们肯定继承至同一个根类,因此中间表是统一一个类型的

            if (root.IsEqualsOrDerivedOrInherited(master))
            {
                var rootField  = GetForeignKey(master, GeneratedFieldType.RootKey, DbFieldType.NonclusteredIndex);
                var indexField = GeneratedField.CreateOrderIndex(objectType, DbFieldType.NonclusteredIndex);
                var valueField = GeneratedField.CreatePrimitiveValue(reflectedType, valueListField);
                fields = new IDataField[] { rootField, indexField, valueField };
            }
            else
            {
                var rootField   = GetForeignKey(root, GeneratedFieldType.RootKey, DbFieldType.NonclusteredIndex); //中间表中追加根字段,可以有效防止数据重叠
                var masterField = GetForeignKey(master, GeneratedFieldType.MasterKey, DbFieldType.NonclusteredIndex);
                var indexField  = GeneratedField.CreateOrderIndex(objectType, DbFieldType.NonclusteredIndex);
                var valueField  = GeneratedField.CreatePrimitiveValue(reflectedType, valueListField);

                fields = new IDataField[] { rootField, masterField, indexField, valueField };
            }

            var middle = DataTable.CreateMiddle(root,
                                                master,
                                                tableName,
                                                DataTableType.Middle,
                                                fields,
                                                memberField);

            return(middle);
        }
Beispiel #16
0
        private object GetValue(TreeNavigator navigator, IDataField datafield, String typenmae)
        {
            //DataStore.AddNode().SetValue
            MethodInfo method  = typeof(TreeNavigator).GetMethod("GetValue");
            MethodInfo generic = method.MakeGenericMethod(Type.GetType(typenmae));

            return(generic.Invoke(navigator, new object[] { datafield }));
        }
Beispiel #17
0
 /// <summary>Returns null if its a String field</summary>
 /// <param name="field"></param>
 /// <returns></returns>
 public static IBinaryPersistor GetPersistor(IDataField field)
 {
     if (field.DataFieldType == DataFieldType.FlatArray || field.DataFieldType == DataFieldType.NestedArray)
     {
         return(new ArrayPersistor((ArrayDataField)field));
     }
     return(GetPersistorNoArray(field));
 }
Beispiel #18
0
 public LogField(LogGroup group, IDataField field, int id)
 {
     ID = id;
     Name = field.Name;
     Group = group;
     DataSource = field;
     this.ValueType = field.ValueType;
 }
Beispiel #19
0
        public static void MapNestedSimple(this LightDBDefinitionSet defs, IDataField dataField, IDataFieldDefinition fieldDef,
                                           Dictionary <string, List <SimpleDataColumn> > mappedFields)
        {
            var nestedFieldDefinition = ((INestedFieldDefinition)fieldDef);

            nestedFieldDefinition.EnsureFieldsNotNull(dataField.DataHolderDefinition.Name);
            defs.AddFieldMappings(nestedFieldDefinition.Fields, ((NestedSimpleDataField)dataField).InnerFields, mappedFields);
        }
Beispiel #20
0
        public static void MapFlatSimple(this LightDBDefinitionSet defs, IDataField dataField, IDataFieldDefinition fieldDef,
                                         Dictionary <string, List <SimpleDataColumn> > mappedFields)
        {
            var tableField = ((SimpleFlatFieldDefinition)fieldDef);

            AddMapping(defs, defs.GetDefaultTables(dataField.DataHolderDefinition), tableField, mappedFields,
                       (FlatSimpleDataField)dataField, dataField.MappedMember);
        }
Beispiel #21
0
 private static DataFieldDefinition CreateFlatArray(IDataField dataField)
 {
     return(new FlatArrayFieldDefinition {
         Name = dataField.Name,
         Offset = 1,
         Pattern = ""
     });
 }
Beispiel #22
0
 public LogField(LogGroup group, IDataField field, int id)
 {
     ID             = id;
     Name           = field.Name;
     Group          = group;
     DataSource     = field;
     this.ValueType = field.ValueType;
 }
Beispiel #23
0
 static object GetValue(ICellDataSource source, IDataField field)
 {
     if (field == null)
     {
         return(null);
     }
     return(source.GetValue(field));
 }
Beispiel #24
0
 public object GetValue(IDataField field)
 {
     if (currentElement.DataContext == null)
     {
         return(null);
     }
     return(((ValuesContainer)currentElement.DataContext)[field.Index]);
 }
Beispiel #25
0
        private static DataFieldDefinition CreateFlatSimple(IDataField dataField)
        {
            SimpleFlatFieldDefinition flatFieldDefinition = new SimpleFlatFieldDefinition();

            flatFieldDefinition.Name   = dataField.Name;
            flatFieldDefinition.Column = "";
            return((DataFieldDefinition)flatFieldDefinition);
        }
Beispiel #26
0
        public static void MapFlatSimple(this LightDBDefinitionSet defs, IDataField dataField,
                                         IDataFieldDefinition fieldDef, Dictionary <string, List <SimpleDataColumn> > mappedFields)
        {
            SimpleFlatFieldDefinition fieldDef1 = (SimpleFlatFieldDefinition)fieldDef;

            LightDBMgr.AddMapping(defs, defs.GetDefaultTables(dataField.DataHolderDefinition), fieldDef1, mappedFields,
                                  (IFlatDataFieldAccessor)dataField, dataField.MappedMember);
        }
Beispiel #27
0
        private static DataTable Create(DataTable root, DataTable master,
                                        Type objectType, bool isSnapshot, DataTableType tableType,
                                        IEnumerable <IDataField> objectFields, IDataField memberField)
        {
            var tableName = GetTableName(objectType, isSnapshot);

            return(Create(root, master, objectType, isSnapshot, tableType, tableName, objectFields, memberField));
        }
Beispiel #28
0
 /// <summary>
 /// 创建中间表
 /// </summary>
 /// <param name="root"></param>
 /// <param name="master"></param>
 /// <param name="tableName"></param>
 /// <param name="tableType"></param>
 /// <param name="isMultiple"></param>
 /// <param name="objectFields"></param>
 /// <param name="memberField"></param>
 /// <returns></returns>
 private static DataTable CreateMiddle(DataTable root, DataTable master,
                                       string tableName,
                                       DataTableType tableType,
                                       IEnumerable <IDataField> objectFields, IDataField memberField)
 {
     // memberField.GetPropertyType()就是集合类型,中间表的objectType是集合类型
     return(Create(root, master, memberField.GetPropertyType(), master.IsSnapshot, tableType, tableName, objectFields, memberField));
 }
 public void AddChild(IDataField field)
 {
     if (_childs == null)
     {
         _childs = new List <IDataField>();
     }
     _childs.Add(field);
     field.ParentMemberField = this;
 }
Beispiel #30
0
        public static void MapNestedSimple(this LightDBDefinitionSet defs, IDataField dataField,
                                           IDataFieldDefinition fieldDef, Dictionary <string, List <SimpleDataColumn> > mappedFields)
        {
            INestedFieldDefinition field = (INestedFieldDefinition)fieldDef;

            field.EnsureFieldsNotNull(dataField.DataHolderDefinition.Name);
            defs.AddFieldMappings((IEnumerable <IDataFieldDefinition>)field.Fields,
                                  (IDictionary <string, IDataField>)((NestedDataField)dataField).InnerFields, mappedFields);
        }
Beispiel #31
0
 /// <summary>
 /// Gets the value of a field
 /// </summary>
 /// <returns>The value.</returns>
 /// <param name="field">Field.</param>
 /// <param name="defaultValue">Default value to be returned if the field has no value</param>
 /// <typeparam name="T">Type of the value</typeparam>
 protected T GetValue <T> (IDataField <T> field, T defaultValue = default(T))
 {
     if (DataSource != null && field != null)
     {
         var result = DataSource.GetValue(field);
         return(result == null || result == DBNull.Value ? defaultValue : (T)result);
     }
     return(defaultValue);
 }
Beispiel #32
0
        private static DataFieldDefinition CreateFlatArray(IDataField dataField)
        {
            FlatArrayFieldDefinition arrayFieldDefinition = new FlatArrayFieldDefinition();

            arrayFieldDefinition.Name    = dataField.Name;
            arrayFieldDefinition.Offset  = 1;
            arrayFieldDefinition.Pattern = "";
            return((DataFieldDefinition)arrayFieldDefinition);
        }
Beispiel #33
0
        //private static void ClearIndex(DataTable table)
        //{
        //    lock (_runtimeIndexs)
        //    {
        //        _runtimeIndexs.Add(table);
        //    }
        //}

        #endregion

        #region 构建时索引,主要用于防止循环引用导致的死循环

        private static DataTable GetBuildtimeIndex(IDataField memberField, string rootTableName, string tableName)
        {
            string    key   = GetUniqueKey(memberField, rootTableName, tableName);
            DataTable table = null;

            if (_buildtimeIndex.TryGetValue(key, out table))
            {
                return(table);
            }
            return(null);
        }
Beispiel #34
0
 /// <summary>
 /// 是否为重复引用点
 /// </summary>
 /// <param name="a"></param>
 /// <param name="b"></param>
 /// <returns></returns>
 private static bool IsRepeatedReferencePoint(IDataField a, IDataField b)
 {
     if (a == b)
     {
         return(false);        //a == b表示两者是同一个field,但不是重复的引用点
     }
     //如果成员字段对应的属性名、成员字段对应的表名、成员字段所在的表的名称相同,那么我们认为是同一个引用点
     return(a.GetPropertyName() == b.GetPropertyName() &&
            a.TableName == b.TableName &&
            a.MasterTableName == b.MasterTableName);
 }
Beispiel #35
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="memberField">表所属的成员字段</param>
        /// <param name="tableName"></param>
        /// <returns></returns>
        private static string GetUniqueKey(IDataField memberField, string rootTableName, string tableName)
        {
            if (memberField == null)
            {
                return(tableName);                     //这肯定是根
            }
            var chain = new ObjectChain(memberField);

            //由于不同类型的表名不同,所以没有加入对象名称作为计算结果
            //由于isSnapshot的值不同表名也不同,所以没有加入对象名称作为计算结果
            return(string.Format("{0}_{1}+{2}", rootTableName, chain.PathCode, tableName));
        }
Beispiel #36
0
		public static void MapFlatArray(this LightDBDefinitionSet defs, IDataField dataField, IDataFieldDefinition fieldDef,
			Dictionary<string, List<SimpleDataColumn>> mappedFields)
		{
			var arrFieldDef = (FlatArrayFieldDefinition)fieldDef;
			var arrDataField = (FlatArrayDataField)dataField;

			var defaultTables = defs.EnsureTables(arrFieldDef.Table, dataField.DataHolderDefinition);
			var cols = arrFieldDef.GetColumns(arrDataField.Length);
			var accessors = arrDataField.ArrayAccessors;
			for (var i = 0; i < cols.Length; i++)
			{
				var col = cols[i];
				AddMapping(defs, defaultTables, col, mappedFields, (IFlatDataFieldAccessor)accessors[i], dataField.MappedMember);
			}
		}
Beispiel #37
0
		private static DataFieldDefinition CreatedNestedSimple(IDataField dataField)
		{
			var nestedField = (NestedSimpleDataField)dataField;
			var fields = new DataFieldDefinition[nestedField.InnerFields.Count];
			int i = 0;
			foreach (var innerField in nestedField.InnerFields.Values)
			{
				fields[i++] = DataFieldCreators[(int)innerField.DataFieldType](innerField);
			}

			return new NestedSimpleFieldDefinition {
				Name = dataField.Name,
				Fields = fields
			};
		}
Beispiel #38
0
		private static DataFieldDefinition CreateFlatArray(IDataField dataField)
		{
			return new FlatArrayFieldDefinition {
				Name = dataField.Name,
				Offset = 1,
				Pattern = ""
			};
		}
Beispiel #39
0
		private static DataFieldDefinition CreateNestedArray(IDataField dataField)
		{
			var arrField = (NestedArrayDataField)dataField;
			var innerFields = ((NestedArrayAccessor[])arrField.ArrayAccessors)[0].InnerFields;
			var segments = new FlatArrayFieldDefinition[innerFields.Count];
			int i = 0;
			foreach (var innerField in innerFields.Values)
			{
				var segment = new FlatArrayFieldDefinition {
					Name = innerField.Name,
					Offset = 1,
					Pattern = ""
				};
				segments[i++] = segment;
			}
			return new NestedArrayFieldDefinition {
				Name = dataField.Name,
				Segments = segments
			};
		}
Beispiel #40
0
 public object GetValue(IDataField field)
 {
     return treeModel.GetValue (iter, field.Index);
 }
Beispiel #41
0
 public CheckBoxCellView(IDataField<bool> field)
 {
     ActiveField = field;
 }
 public override void Observe()
 {
     _dataField = Mapper.Map<IEnumerable<IRespondWithBmwFinance>, DataField>(LightstoneBmwFinanceResponseMother.Response.Finances);            
 }
 public override void Observe()
 {
     _dataField = Mapper.Map<IEnumerable<IRespondWithPriceModel>, DataField>(LightstoneAutoResponseMother.Response.VehicleValuation.Prices);
 }
Beispiel #44
0
 /// <summary>
 /// Saves the status of the tree
 /// </summary>
 /// <returns>
 /// A status object
 /// </returns>
 /// <param name='idField'>
 /// Field to be used to identify each row
 /// </param>
 /// <remarks>
 /// The status information includes node expansion and selection status. The returned object
 /// can be used to restore the status by calling RestoreStatus.
 /// The provided field is used to generate an identifier for each row. When restoring the
 /// status, those ids are used to find matching rows.
 /// </remarks>
 public TreeViewStatus SaveStatus(IDataField idField)
 {
     return new TreeViewStatus (this, idField.Index);
 }
Beispiel #45
0
 public void SetValue(IDataField field, object value)
 {
     source.SetValue (tablePosition.Position, field.Index, value);
 }
Beispiel #46
0
 public TextCellView(IDataField textField)
 {
     TextField = textField;
 }
Beispiel #47
0
        /// <summary>
        /// creates a xwt datastore
        /// </summary>
        /// <returns>
        /// The data store.
        /// </returns>
        private TreeStore CreateDataStore()
        {
            IDataField[] fields = new IDataField[HeaderColumns.Count];

            int i=0;
            foreach (VirtualGridHeaderColumn col in HeaderColumns)
            {
                String tp = "String";

                if (!String.IsNullOrEmpty(col.ColumnType))
                {
                    tp = col.ColumnType;
                }

                fields[i] = createDataField(tp);
                i++;
            }

            return new TreeStore(fields);
        }
 public override void Observe()
 {
     _dataField = Mapper.Map<IRespondWithValuation, DataField>(LightstoneAutoResponseMother.Response.VehicleValuation);
 }
Beispiel #49
0
		/// <summary>
		/// Returns null if its a String field
		/// </summary>
		/// <param name="field"></param>
		/// <returns></returns>
		public static IBinaryPersistor GetPersistor(IDataField field)
		{
			if (field.DataFieldType == DataFieldType.FlatArray ||
					field.DataFieldType == DataFieldType.NestedArray)
			{
				return new ArrayPersistor((ArrayDataField)field);
			}
			else
			{
				return GetPersistorNoArray(field);
			}
		}
Beispiel #50
0
		private static DataFieldDefinition CreateFlatSimple(IDataField dataField)
		{
			return new SimpleFlatFieldDefinition {
				Name = dataField.Name,
				Column = ""
			};
		}
 public override void Observe()
 {
     _dataField = Mapper.Map<IEnumerable<IRespondWithEzScore>, DataField>(PCubedEzScoreResponseMother.Response.EzScoreRecords);
 }
Beispiel #52
0
		public static IBinaryPersistor GetPersistorNoArray(IDataField field)
		{
			var type = field.MappedMember.GetActualType();
			if (field is INestedDataField)
			{
				// nested
				return new NestedPersistor((INestedDataField)field);
			}
			else
			{
				// simple
				var persistor = GetSimplePersistor(type);
				if (persistor == null)
				{
					throw new DataHolderException("Simple Type did not have a binary Persistor: " + type.FullName);
				}
				return persistor;
			}
		}
Beispiel #53
0
 object ICellDataSource.GetValue(IDataField field)
 {
     return source.GetValue (tablePosition.Position, field.Index);
 }
Beispiel #54
0
 public DatafieldContainer(IDataField field, String title, String typename)
 {
     Field = field;
     Title = title;
     Typename = typename;
 }
        internal void AddFieldMapping(IEnumerable<IDataFieldDefinition> fieldDefs,
            IDataField dataField, Dictionary<string, List<SimpleDataColumn>> mappedFields)
        {
            var fieldDef = fieldDefs.Where(def =>
                def.Name.Equals(dataField.Name, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();

            if (fieldDef == null)
            {
                var type = dataField.MappedMember.DeclaringType.Name;
                LightDBMgr.OnInvalidData("DataField \"" + dataField + "\" in Type " +
                    type + " (DataHolder: {0}) is not mapped.", dataField.DataHolderDefinition);
                return;
            }
            else if (fieldDef.DataFieldType != dataField.DataFieldType)
            {
                var type = dataField.MappedMember.DeclaringType.FullName;
                throw new DataHolderException("DataField \"" + dataField + "\" in Type " + type + " is {0}, but was defined as: {1}",
                    dataField.DataFieldType, fieldDef.DataFieldType);
            }

            LightDBMgr.DataFieldHandlers[(int)dataField.DataFieldType](this, dataField, fieldDef, mappedFields);
        }
Beispiel #56
0
 public ComboBoxCellView(IDataField<string> field)
 {
     SelectedTextField = field;
 }
Beispiel #57
0
 public void CreateTable(string tableName, IDataField[] fields)
 {
     if (fields.Length > 0) {
         bool localConnection = false;
         if (ConnectionState == System.Data.ConnectionState.Closed) {
             localConnection = true;
             OpenConnection();
         }
         try {
             string command = "CREATE TABLE " + tableName + " (" + fields[0].Name + " " + fields[0].Type;
             for (int i = 1; i < fields.Length; i++) {
                 command += ", " + fields[i].Name + " " + fields[i].Type;
             }
             command += ")";
             using (SQLiteCommand comm = new SQLiteCommand(command, connection)) {
                 comm.ExecuteNonQuery();
             }
         } finally {
             if (localConnection) {
                 CloseConnection();
             }
         }
     }
 }
Beispiel #58
0
        private object GetValue(TreeNavigator navigator, IDataField datafield, String typenmae)
        {
            //DataStore.AddNode().SetValue
            MethodInfo method = typeof(TreeNavigator).GetMethod("GetValue");
            MethodInfo generic = method.MakeGenericMethod(Type.GetType(typenmae));

            return (generic.Invoke(navigator,new object[] {datafield}));
        }
Beispiel #59
0
 public object GetValue(IDataField field)
 {
     return CellUtil.GetModelValue (TreeModel, CurrentIter, field.Index);
 }
 public object GetValue(IDataField field)
 {
     return CellUtil.GetModelValue (treeModel, iter, field.Index);
 }