public CorrespondenceFact CreateFact(FactMemento memento)
            {
                Tune newFact = new Tune(memento);

                // Create a memory stream from the memento data.
                using (MemoryStream data = new MemoryStream(memento.Data))
                {
                    using (BinaryReader output = new BinaryReader(data))
                    {
                        newFact._name = (string)_fieldSerializerByType[typeof(string)].ReadData(output);
                    }
                }

                return(newFact);
            }
 public Tune Ensure()
 {
     if (_loadedTask != null)
     {
         ManualResetEvent loaded = new ManualResetEvent(false);
         Tune             fact   = null;
         _loadedTask.ContinueWith(delegate(Task <CorrespondenceFact> t)
         {
             fact = (Tune)t.Result;
             loaded.Set();
         });
         loaded.WaitOne();
         return(fact);
     }
     else
     {
         return(this);
     }
 }
 public void RegisterAllFactTypes(Community community, IDictionary <Type, IFieldSerializer> fieldSerializerByType)
 {
     community.AddType(
         Individual._correspondenceFactType,
         new Individual.CorrespondenceFactFactory(fieldSerializerByType),
         new FactMetadata(new List <CorrespondenceFactType> {
         Individual._correspondenceFactType
     }));
     community.AddQuery(
         Individual._correspondenceFactType,
         Individual.GetQueryName().QueryDefinition);
     community.AddQuery(
         Individual._correspondenceFactType,
         Individual.GetQueryTunes().QueryDefinition);
     community.AddType(
         Individual__name._correspondenceFactType,
         new Individual__name.CorrespondenceFactFactory(fieldSerializerByType),
         new FactMetadata(new List <CorrespondenceFactType> {
         Individual__name._correspondenceFactType
     }));
     community.AddQuery(
         Individual__name._correspondenceFactType,
         Individual__name.GetQueryIsCurrent().QueryDefinition);
     community.AddType(
         Tune._correspondenceFactType,
         new Tune.CorrespondenceFactFactory(fieldSerializerByType),
         new FactMetadata(new List <CorrespondenceFactType> {
         Tune._correspondenceFactType
     }));
     community.AddQuery(
         Tune._correspondenceFactType,
         Tune.GetQueryIndividuals().QueryDefinition);
     community.AddType(
         Like._correspondenceFactType,
         new Like.CorrespondenceFactFactory(fieldSerializerByType),
         new FactMetadata(new List <CorrespondenceFactType> {
         Like._correspondenceFactType
     }));
 }
 public CorrespondenceFact GetNullInstance()
 {
     return(Tune.GetNullInstance());
 }
 public CorrespondenceFact GetUnloadedInstance()
 {
     return(Tune.GetUnloadedInstance());
 }
            public void WriteFactData(CorrespondenceFact obj, BinaryWriter output)
            {
                Tune fact = (Tune)obj;

                _fieldSerializerByType[typeof(string)].WriteData(output, fact._name);
            }