private void XmlStartField(FieldKeyType type, byte[] key, int fieldSize) { string keyValue; if (BlobUtil.IsIntDescriptor(key)) keyValue = Convert.ToString(BitConverter.ToUInt32(key, 0)); else keyValue = Encoding.UTF8.GetString(key); xmlOut.WriteStartElement("field"); xmlOut.WriteAttributeString("key", keyValue); }
private void XmlStartField(FieldKeyType type, byte[] key, int fieldSize) { string keyValue; if (BlobUtil.IsIntDescriptor(key)) { keyValue = Convert.ToString(BitConverter.ToUInt32(key, 0)); } else { keyValue = Encoding.UTF8.GetString(key); } xmlOut.WriteStartElement("field"); xmlOut.WriteAttributeString("key", keyValue); }
private void TypeStartField(FieldKeyType type, byte[] key, int fieldSize) { string keyValue; if (BlobUtil.IsIntDescriptor(key)) { keyValue = Convert.ToString(BitConverter.ToUInt32(key, 0)); } else { keyValue = Encoding.UTF8.GetString(key); } int fieldIndex; ProcessState top = PeekStackTop(); if (top.State == EProcessingState.TopSearch && TestFieldAttributeState(top, keyValue, out fieldIndex)) { PushTypeAttributesToStack(typeof(T), Target); } else if (top.State == EProcessingState.FieldSearch && TestFieldAttributeState(top, keyValue, out fieldIndex)) { PropertyInfo prop = top.Properties[fieldIndex]; BlobFieldAttribute attrib = top.Attributes[fieldIndex]; Type subType = prop.PropertyType; Type genericType; int genericCount; if (subType.IsTypeListOrDictionary(out genericType, out genericCount)) { object subInstance = CacheUtil.FastConstruct(TypedCache, subType); //Activator.CreateInstance(subType); prop.SetValue(top.WorkingType, subInstance, null); PushListTypeAttributesToStack(subInstance, attrib, prop); } else if (attrib.Complex == true) { object subInstance = CacheUtil.FastConstruct(TypedCache, subType); //Activator.CreateInstance(subType); prop.SetValue(top.WorkingType, subInstance, null); PushTypeAttributesToStack(subType, subInstance); } else if (attrib.SubFieldDepth > 0 || attrib.SubFieldKey != null) { PushSubSearchAttributeToStack(top, attrib, prop, top.WorkingType); } else { expectingIndex = fieldIndex; } } else if (top.State == EProcessingState.SubFieldSearch && TestSubFieldAttributeState(top, keyValue, out fieldIndex)) { expectingIndex = fieldIndex; } else if (top.State == EProcessingState.EveryFieldSearch && depth - top.Depth == 1) { PropertyInfo prop = top.Properties[0]; Type subType; int genericCount; bool genericType = prop.PropertyType.IsTypeListOrDictionary(out subType, out genericCount); if (top.Attributes[0].Complex == true && genericType) { object subInstance = CacheUtil.FastConstruct(TypedCache, subType); //Activator.CreateInstance(subType); CacheUtil.HandleAddCall(prop, genericCount, top.WorkingType, keyValue, subInstance); PushTypeAttributesToStack(subType, subInstance); } else if (fieldSize == 0 && genericType) { // key is the actual field. object value = GetDataForProp(key, subType); CacheUtil.HandleAddCall(prop, genericCount, top.WorkingType, expectedKey, value); } else { expectedKey = keyValue; expectingIndex = 0; } } }