Exemplo n.º 1
0
            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);
            }
Exemplo n.º 2
0
 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);
     }
 }
Exemplo n.º 3
0
 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
     }));
 }
Exemplo n.º 4
0
 public CorrespondenceFact GetNullInstance()
 {
     return(Tune.GetNullInstance());
 }
Exemplo n.º 5
0
 public CorrespondenceFact GetUnloadedInstance()
 {
     return(Tune.GetUnloadedInstance());
 }
Exemplo n.º 6
0
            public void WriteFactData(CorrespondenceFact obj, BinaryWriter output)
            {
                Tune fact = (Tune)obj;

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