/// <summary> /// Validate error at column name /// </summary> /// <param name="columnName"></param> protected void Validate(string columnName) { if (!Validators.ContainsKey(columnName)) { return; } var value = PropertyGetters[columnName]((TViewModel)this); this.ValidateProperty(columnName, value); }
// This is the full-scale table reader, that reads all of the data in a table // T is the type of the row object to be populated // Property getters must be supplied to map property IDs to members of T // // First form takes a node ID for a node in the main node tree public IEnumerable <T> ReadTable <T>(FileStream fs, NID nid, PropertyGetters <T> g, Action <T, UInt32> idGetter = null, Action <T, Property> storeProp = null) where T : new() { BTree <Node> subNodeTree; var rn = ndb.LookupNodeAndReadItsSubNodeBtree(fs, nid, out subNodeTree); return(ReadTableInternal <T>(fs, subNodeTree, rn.DataBid, g, idGetter, storeProp)); }
/// <summary> /// Add error list to field /// </summary> /// <param name="propertyName"></param> /// <param name="errors"></param> public void AddError(string propertyName, IList <string> errors) { Logger.DebugFormat("Add error messages to property [{0}]...", propertyName); if (!PropertyGetters.ContainsKey(propertyName)) { //Logger.DebugFormat($"[{propertyName}] is not existed."); return; } List <string> errorsTmp; if (!this.errorDic.TryGetValue(propertyName, out errorsTmp)) { errorsTmp = new List <string>(errors); this.errorDic.TryAdd(propertyName, errorsTmp); } else { errorsTmp.AddRange(errors); } // Notify error change this.OnNotifyErrorChanged(propertyName); Logger.Debug($"Add error for [{propertyName}] with [{errors}] successfully."); }
// Read the properties in a property context // T is the type of the object to be populated // Property getters must be supplied to map property Ids to members of T // The returned value is the subnode tree, if any, related to the contents of the properties // // First form takes a node ID for a node in the main node tree public BTree <Node> ReadProperties <T>(FileStream fs, NID nid, PropertyGetters <T> g, T target) { BTree <Node> subNodeTree; var rn = ndb.LookupNodeAndReadItsSubNodeBtree(fs, nid, out subNodeTree); ReadPropertiesInternal <T>(fs, subNodeTree, rn.DataBid, g, target); return(subNodeTree); }
public Dictionary <string, object> GetAttributes(object objectGraph, JsonSerializerSettings settings) { if (settings.NullValueHandling == NullValueHandling.Ignore) { return(PropertyGetters .Where(x => x.Value(objectGraph) != null) .ToDictionary(kvp => CamelCaseUtil.ToCamelCase(kvp.Key), kvp => kvp.Value(objectGraph))); } else { return(PropertyGetters.ToDictionary(kvp => CamelCaseUtil.ToCamelCase(kvp.Key), kvp => kvp.Value(objectGraph))); } }
public List <string> GetListOfProductsPrices() { IList <IWebElement> productList = new PropertyGetters(driver).GetWebElements(ShoppingCartDropDownMap.productPriceMap); List <string> productPriceList = new List <string>(); foreach (IWebElement product in productList) { productPriceList.Add(product.Text); } return(productPriceList); }
public List <string> GetNames() { IList <IWebElement> productList = new PropertyGetters(driver) .GetWebElements(ShoppingCartPageMap.productNameMap); List <string> productNameList = new List <string>(); foreach (IWebElement product in productList) { productNameList.Add(product.Text); } return(productNameList); }
/// <summary> /// Called when [view loaded]. /// </summary> /// <param name="view">The view.</param> protected override void OnViewLoaded(object view) { Logger.Debug("OnViewLoaded..."); base.OnViewLoaded(view); Observable.FromEventPattern <PropertyChangedEventHandler, PropertyChangedEventArgs>( h => this.PropertyChanged += h, h => this.PropertyChanged -= h).Where( x => { if (PropertyGetters.ContainsKey(x.EventArgs.PropertyName)) { this.validatorList.Add(x.EventArgs.PropertyName); return(true); } return(false); }).Throttle(TimeSpan.FromSeconds(0.75)).Subscribe(x => this.ValidateLazy()); Logger.Debug("OnViewLoaded..."); }
/// <summary> /// Get error message of property field /// </summary> /// <param name="propertyName"></param> /// <returns></returns> public IEnumerable GetErrors(string propertyName) { if (!string.IsNullOrWhiteSpace(propertyName)) { if (PropertyGetters.ContainsKey(propertyName)) { List <string> errors; if (this.errorDic.TryGetValue(propertyName, out errors) && !errors.IsNullOrEmpty()) { // Realize a list and send to the OnColumnrror() method this.OnProperyErrors(propertyName, errors); foreach (var error in errors) { yield return(error); } } } } yield break; }
// Common implementation of property reading takes a data ID for a block in the main block tree private void ReadPropertiesInternal <T>(FileStream fs, BTree <Node> subNodeTree, UInt64 dataBid, PropertyGetters <T> g, T target) { var blocks = ReadHeapOnNode(fs, dataBid); var h = blocks.First(); if (h.bClientSig != EbType.bTypePC) { throw new XstException("Was expecting a PC"); } // Read the index of properties var props = ReadBTHIndex <PCBTH>(blocks, h.hidUserRoot).ToArray(); foreach (var prop in props) { if (!g.ContainsKey(prop.wPropId)) { continue; } dynamic val = ReadPropertyValue(fs, subNodeTree, blocks, prop); g[prop.wPropId](target, val); } }
private EventPropertyGetter DoResolvePropertyGetter(String propertyExpression, bool allowSimpleProperties) { EventPropertyGetter getter = _propertyGetterCache.Get(propertyExpression); if (getter != null) { return(getter); } if (!allowSimpleProperties) { // see if this is an indexed property int index = ASTUtil.UnescapedIndexOfDot(propertyExpression); if (index == -1) { // parse, can be an indexed property Property property = PropertyParser.ParseAndWalkLaxToSimple(propertyExpression); if (!property.IsDynamic) { if (!(property is IndexedProperty)) { return(null); } var indexedProp = (IndexedProperty)property; getter = PropertyGetters.Get(indexedProp.PropertyNameAtomic); if (null == getter) { return(null); } EventPropertyDescriptor descriptor = PropertyDescriptorMap.Get(indexedProp.PropertyNameAtomic); if (descriptor == null) { return(null); } if (!descriptor.IsIndexed) { return(null); } if (descriptor.PropertyType == typeof(XmlNodeList)) { FragmentFactory fragmentFactory = new FragmentFactoryDOMGetter( EventAdapterService, this, indexedProp.PropertyNameAtomic); return(new XPathPropertyArrayItemGetter(getter, indexedProp.Index, fragmentFactory)); } if (descriptor.PropertyType == typeof(string)) { FragmentFactory fragmentFactory = new FragmentFactoryDOMGetter( EventAdapterService, this, indexedProp.PropertyNameAtomic); return(new XPathPropertyArrayItemGetter(getter, indexedProp.Index, fragmentFactory)); } } } } if (!_isPropertyExpressionXPath) { Property prop = PropertyParser.ParseAndWalkLaxToSimple(propertyExpression); bool isDynamic = prop.IsDynamic; if (!isDynamic) { SchemaItem item = prop.GetPropertyTypeSchema(_schemaModelRoot, EventAdapterService); if (item == null) { return(null); } getter = prop.GetGetterDOM(_schemaModelRoot, EventAdapterService, this, propertyExpression); if (getter == null) { return(null); } Type returnType = SchemaUtil.ToReturnType(item); if ((returnType != typeof(XmlNode)) && (returnType != typeof(XmlNodeList))) { if (!returnType.IsArray) { getter = new DOMConvertingGetter(propertyExpression, (DOMPropertyGetter)getter, returnType); } else { getter = new DOMConvertingArrayGetter((DOMPropertyGetter)getter, returnType.GetElementType()); } } } else { return(prop.GetGetterDOM()); } } else { bool allowFragments = !ConfigurationEventTypeXMLDOM.IsXPathPropertyExpr; getter = SchemaXMLPropertyParser.GetXPathResolution( propertyExpression, NamespaceContext, RootElementName, _rootElementNamespace, _schemaModel, EventAdapterService, this, allowFragments, ConfigurationEventTypeXMLDOM.DefaultNamespace); } _propertyGetterCache.Put(propertyExpression, getter); return(getter); }
public int GetNumberOfProducts() { IList <IWebElement> productList = new PropertyGetters(driver).GetWebElements(ShoppingCartDropDownMap.productNameMap); return(productList.Count); }
// Second form takes a node ID for a node in the supplied sub node tree public IEnumerable <T> ReadTable <T>(FileStream fs, BTree <Node> subNodeTree, NID nid, PropertyGetters <T> g, Action <T, UInt32> idGetter = null, Action <T, Property> storeProp = null) where T : new() { BTree <Node> childSubNodeTree; var rn = ndb.LookupSubNodeAndReadItsSubNodeBtree(fs, subNodeTree, nid, out childSubNodeTree); if (rn == null) { throw new XstException("Node block does not exist"); } return(ReadTableInternal <T>(fs, childSubNodeTree, rn.DataBid, g, idGetter, storeProp)); }
public override string ToQueryPlan() { return(GetType().Name + " streamNum=" + Organization.StreamNum + " propertyGetters=" + PropertyGetters.Render()); }
public void AddPropertyGetter(string key, Expression <Func <TEntity, object> > expression) { PropertyGetters.Add(key, ExpressionUtils.CompileToObjectTypedFunction(expression)); }
// Read the data rows of a table, populating the members of target type T as specified by the supplied property getters, and optionally getting all columns as properties private IEnumerable <T> ReadTableData <T>(FileStream fs, TCINFO t, List <HNDataBlock> blocks, List <RowDataBlock> dataBlocks, TCOLDESC[] cols, List <TCOLDESC> colsToGet, BTree <Node> subNodeTree, TCROWIDUnicode[] indexes, PropertyGetters <T> g, Action <T, UInt32> idGetter, Action <T, Property> storeProp) where T : new() { int rgCEBSize = (int)Math.Ceiling((decimal)t.cCols / 8); int rowsPerBlock; if (ndb.IsUnicode4K) { rowsPerBlock = (ndb.BlockSize4K - Marshal.SizeOf(typeof(BLOCKTRAILERUnicode4K))) / t.rgibTCI_bm; } else if (ndb.IsUnicode) { rowsPerBlock = (ndb.BlockSize - Marshal.SizeOf(typeof(BLOCKTRAILERUnicode))) / t.rgibTCI_bm; } else { rowsPerBlock = (ndb.BlockSize - Marshal.SizeOf(typeof(BLOCKTRAILERANSI))) / t.rgibTCI_bm; } foreach (var index in indexes) { int blockNum = (int)(index.dwRowIndex / rowsPerBlock); if (blockNum >= dataBlocks.Count) { throw new XstException("Data block number out of bounds"); } var db = dataBlocks[blockNum]; long rowOffset = db.Offset + (index.dwRowIndex % rowsPerBlock) * t.rgibTCI_bm; T row = new T(); // Retrieve the node ID that accesses the message if (idGetter != null) { idGetter(row, index.dwRowID); } if (rowOffset + t.rgibTCI_bm > db.Offset + db.Length) { throw new XstException("Out of bounds reading table data"); } // Read the column existence data var rgCEB = Map.MapArray <Byte>(db.Buffer, (int)(rowOffset + t.rgibTCI_1b), rgCEBSize); foreach (var col in colsToGet) { // Check if the column exists if ((rgCEB[col.iBit / 8] & (0x01 << (7 - (col.iBit % 8)))) == 0) { continue; } dynamic val = ReadTableColumnValue(fs, subNodeTree, blocks, db, rowOffset, col); g[col.wPropId](row, val); } // If we were asked for all column values as properties, read them and store them if (storeProp != null) { foreach (var col in cols) { // Check if the column exists if ((rgCEB[col.iBit / 8] & (0x01 << (7 - (col.iBit % 8)))) == 0) { continue; } dynamic val = ReadTableColumnValue(fs, subNodeTree, blocks, db, rowOffset, col); Property p = CreatePropertyObject(fs, col.wPropId, val); storeProp(row, p); } } yield return(row); } yield break; // No more entries }
// Common implementation of table reading takes a data ID for a block in the main block tree private IEnumerable <T> ReadTableInternal <T>(FileStream fs, BTree <Node> subNodeTree, UInt64 dataBid, PropertyGetters <T> g, Action <T, UInt32> idGetter, Action <T, Property> storeProp) where T : new() { var blocks = ReadHeapOnNode(fs, dataBid); var h = blocks.First(); if (h.bClientSig != EbType.bTypeTC) { throw new XstException("Was expecting a table"); } // Read the table information var t = MapType <TCINFO>(blocks, h.hidUserRoot); // Read the column descriptions var cols = MapArray <TCOLDESC>(blocks, h.hidUserRoot, t.cCols, Marshal.SizeOf(typeof(TCINFO))); // Read the row index TCROWIDUnicode[] indexes; if (ndb.IsUnicode) { indexes = ReadBTHIndex <TCROWIDUnicode>(blocks, t.hidRowIndex).ToArray(); } else { // For ANSI, convert the index entries to the slightly more capacious Unicode equivalents indexes = ReadBTHIndex <TCROWIDANSI>(blocks, t.hidRowIndex).Select(e => new TCROWIDUnicode { dwRowID = e.dwRowID, dwRowIndex = e.dwRowIndex }).ToArray(); } // Work out which of the columns are both present in the table and have getters defined var colsToGet = cols.Where(c => g.ContainsKey(c.wPropId)).ToList(); // The data rows may be held in line, or in a sub node if (t.hnidRows.IsHID) { // Data is in line var buf = GetBytesForHNID(fs, blocks, subNodeTree, t.hnidRows); var dataBlocks = new List <RowDataBlock> { new RowDataBlock { Buffer = buf, Offset = 0, Length = buf.Length, } }; return(ReadTableData <T>(fs, t, blocks, dataBlocks, cols, colsToGet, subNodeTree, indexes, g, idGetter, storeProp)); } else if (t.hnidRows.NID.HasValue) { // Don't use GetBytesForHNID in this case, as we need to handle multiple blocks var dataBlocks = ReadSubNodeRowDataBlocks(fs, subNodeTree, t.hnidRows.NID); return(ReadTableData <T>(fs, t, blocks, dataBlocks, cols, colsToGet, subNodeTree, indexes, g, idGetter, storeProp)); } else { return(Enumerable.Empty <T>()); } }
public Dictionary <string, object> GetAttributes(object objectGraph) { return(PropertyGetters.ToDictionary(kvp => CamelCaseUtil.ToCamelCase(kvp.Key), kvp => kvp.Value(objectGraph))); }
// Second form takes a node ID for a node in the supplied sub node tree // An optional switch can be used to indicate that the property values are stored in the child node tree of the supplied node tree public BTree <Node> ReadProperties <T>(FileStream fs, BTree <Node> subNodeTree, NID nid, PropertyGetters <T> g, T target, bool propertyValuesInChildNodeTree = false) { BTree <Node> childSubNodeTree; var rn = ndb.LookupSubNodeAndReadItsSubNodeBtree(fs, subNodeTree, nid, out childSubNodeTree); ReadPropertiesInternal <T>(fs, propertyValuesInChildNodeTree ? childSubNodeTree : subNodeTree, rn.DataBid, g, target); return(childSubNodeTree); }