public void LazyAddTest() { var lazyDictionary = new LazyDictionary<string, string>(); lazyDictionary.Add("key", "value"); var initialized = lazyDictionary.IsInitialized; Assert.True(initialized); }
public void LazyAddTest() { var lazyDictionary = new LazyDictionary <string, string>(); lazyDictionary.Add("key", "value"); var initialized = lazyDictionary.IsInitialized; Assert.True(initialized); }
public override LazyDictionary <string, ItemField> GetValue(TypedEntity source) { var d = new LazyDictionary <string, ItemField>(); foreach (var a in source.Attributes) { if (a.Values.Count == 1) { StoreFieldValue(a.AttributeDefinition.AttributeType.SerializationType, FixedAttributeIndexFields.AttributePrefix + a.AttributeDefinition.Alias, a.DynamicValue, d); } else if (a.Values.Count > 1) { //we need to put multiple values in the index with dot notation foreach (var val in a.Values) { var key = FixedAttributeIndexFields.AttributePrefix + a.AttributeDefinition.Alias + "." + val.Key; StoreFieldValue(a.AttributeDefinition.AttributeType.SerializationType, key, val.Value, d); } } //put attribute alias/name/id in there FixedAttributeIndexFields.AddAttributeAlias(d, a); //FixedAttributeIndexFields.AddAttributeName(d, a); FixedAttributeIndexFields.AddAttributeId(d, a); } //Get the parent Id. //TODO: We should support all relation types in some magical way foreach (var r in source.RelationProxies.GetParentRelations(FixedRelationTypes.DefaultRelationType)) { d.AddOrUpdate(FixedIndexedFields.ParentId, new ItemField(r.Item.SourceId.Value.ToString())); } d.AddOrUpdate(FixedIndexedFields.SchemaId, new Lazy <ItemField>(() => new ItemField(source.EntitySchema.Id.Value.ToString())), (k, i) => new Lazy <ItemField>(() => new ItemField(source.EntitySchema.Id.Value.ToString()))); d.Add(FixedIndexedFields.SchemaAlias, new ItemField(source.EntitySchema.Alias)); d.AddOrUpdate(FixedIndexedFields.SchemaName, new ItemField(source.EntitySchema.Name)); d.AddOrUpdate(FixedIndexedFields.SchemaType, new ItemField(source.EntitySchema.SchemaType)); ExamineHelper.SetTimestampsOnEntityAndIndexFields(d, source); return(d); }
public override LazyDictionary <string, ItemField> GetValue(AttributeDefinition source) { //convert the source to a dictionary object ignoring some of its properties var d = source.ToDictionary <AttributeDefinition, object, object>( x => x.Id, x => x.AttributeGroup, x => x.AttributeType, x => x.ConcurrencyToken); var output = new LazyDictionary <string, ItemField>(); foreach (var i in d) { output.Add(i.Key, new ItemField(i.Value)); } ExamineHelper.SetTimestampsOnEntityAndIndexFields(output, source); //add some lazy delegates for the ids of the group/attribute type output.Add(FixedIndexedFields.GroupId, new Lazy <ItemField>(() => new ItemField(source.AttributeGroup.Id.Value))); output.Add(FixedIndexedFields.AttributeTypeId, new Lazy <ItemField>(() => new ItemField(source.AttributeType.Id.Value))); return(output); }
public override LazyDictionary <string, ItemField> GetValue(AttributeType source) { ////TODO: This is purely a hack in order to get the installer working with Examine, its also a required hack until the underlying //// issue is fixed: Currently we need to make sure that the properties of an Attribute type remain constant in the repository unless //// that property is explicitly changed. This is mostly to do with the RenderTypeProvider property as we don't want it to be overwritten //// with a empty value when a system attribute type is committed. //if (!source.Id.IsNullValueOrEmpty()) //{ // var existing = _helper.PerformGet<AttributeType>(true, LuceneIndexer.IndexNodeIdFieldName, source.Id); // var destination = existing.LastOrDefault(); // if (destination != null) // { // //This copies across all changed (Dirty) properties from the source to the destination except for a few of the properties // destination.SetAllChangedProperties<AttributeType, object>(source, // x => x.Id, // x => x.ConcurrencyToken, // x => x.PersistenceMetadata, // x => x.UtcCreated, // x => x.UtcModified, // x => x.UtcStatusChanged); // //now that all properties are updated that have changed, overwrite the 'source' object with the destination so it can be mapped // //to the index fields properly to be stored. // source = destination; // } //} //convert the source to a dictionary object ignoring some of its properties var d = source.ToDictionary <AttributeType, object, object>( x => x.Id, x => x.SerializationType, x => x.ConcurrencyToken); //add the serialization FQN so we can re-create it later d.Add(FixedIndexedFields.SerializationType, source.SerializationType.GetType().FullName); var output = new LazyDictionary <string, ItemField>(); foreach (var i in d) { output.Add(i.Key, new ItemField(i.Value)); } ExamineHelper.SetTimestampsOnEntityAndIndexFields(output, source); return(output); }
public override LazyDictionary <string, ItemField> GetValue(AttributeGroup source) { //convert the source to a dictionary object ignoring some of its properties var d = source.ToDictionary <AttributeGroup, object, object>( x => x.Id, x => x.ConcurrencyToken); var output = new LazyDictionary <string, ItemField>(); foreach (var i in d) { output.Add(i.Key, new ItemField(i.Value)); } ExamineHelper.SetTimestampsOnEntityAndIndexFields(output, source); return(output); }
public override LazyDictionary <string, ItemField> GetValue(IReadonlyRelation <IRelatableEntity, IRelatableEntity> source) { var d = new LazyDictionary <string, ItemField> { { FixedRelationIndexFields.SourceId, new Lazy <ItemField>(() => new ItemField(source.SourceId.Value.ToString())) }, { FixedRelationIndexFields.DestinationId, new Lazy <ItemField>(() => new ItemField(source.DestinationId.Value.ToString())) }, { FixedRelationIndexFields.RelationType, new ItemField(source.Type.RelationName) }, //{FixedRelationIndexFields.RelationSourceType, new ItemField(source.Source.GetType().AssemblyQualifiedName) }, { FixedIndexedFields.Ordinal, new ItemField(source.Ordinal.ToString()) { DataType = FieldDataType.Int } } }; //store the metadata in the same document, but as keyed prefixed items like: // M.MyKey , MyValue foreach (var m in source.MetaData) { d.Add(FixedRelationIndexFields.MetadatumPrefix + m.Key, new ItemField(m.Value)); } return(d); }
//public static void AddAttributeName(LazyDictionary<string, ItemField> d, TypedAttribute ta) //{ // d.Add( // AttributePrefix + ta.AttributeDefinition.Alias + "." + AttributeName, // new ItemField(ta.AttributeDefinition.Name)); //} public static void AddAttributeId(LazyDictionary <string, ItemField> d, TypedAttribute ta) { d.Add(CreateAttributeIdField(ta.AttributeDefinition.Alias), new Lazy <ItemField>(() => new ItemField(ta.Id.Value.ToString()))); //lazy load this id as it might not be set }
/// <summary> /// Adds the attribute alias. /// </summary> /// <param name="d">The d.</param> /// <param name="ta">The ta.</param> public static void AddAttributeAlias(LazyDictionary <string, ItemField> d, TypedAttribute ta) { d.Add(CreateAttributeAliasField(ta.AttributeDefinition.Alias), new ItemField(ta.AttributeDefinition.Alias)); }
//public static void AddAttributeName(LazyDictionary<string, ItemField> d, TypedAttribute ta) //{ // d.Add( // AttributePrefix + ta.AttributeDefinition.Alias + "." + AttributeName, // new ItemField(ta.AttributeDefinition.Name)); //} public static void AddAttributeId(LazyDictionary<string, ItemField> d, TypedAttribute ta) { d.Add(CreateAttributeIdField(ta.AttributeDefinition.Alias), new Lazy<ItemField>(() => new ItemField(ta.Id.Value.ToString()))); //lazy load this id as it might not be set }
/// <summary> /// Adds the attribute alias. /// </summary> /// <param name="d">The d.</param> /// <param name="ta">The ta.</param> public static void AddAttributeAlias(LazyDictionary<string, ItemField> d, TypedAttribute ta) { d.Add(CreateAttributeAliasField(ta.AttributeDefinition.Alias), new ItemField(ta.AttributeDefinition.Alias)); }
public void Add(T hook) { ArgumentHelper.ValidateNotNull <T>(hook, "hook"); _hook.Add(hook); }