コード例 #1
0
 public ImmutableObject ToImmutable(ImmutableModel immutableModel)
 {
     if (immutableModel == null)
     {
         throw new ArgumentNullException(nameof(immutableModel));
     }
     return(immutableModel.GetObject(this));
 }
コード例 #2
0
ファイル: MutableModel.cs プロジェクト: Anjireddy4246/meta-cs
 internal MutableModel(GreenModel green, ImmutableModel immutableModel)
 {
     this.id             = green.Id;
     this.group          = null;
     this.green          = green;
     this.updater        = new ThreadLocal <GreenModelUpdater>();
     this.readOnly       = false;
     this.objects        = new ConditionalWeakTable <ObjectId, MutableObject>();
     this.immutableModel = new WeakReference <ImmutableModel>(immutableModel);
 }
コード例 #3
0
ファイル: MutableModel.cs プロジェクト: Anjireddy4246/meta-cs
 internal MutableModel(ModelId id, MutableModelGroup group, bool readOnly, ImmutableModel immutableModel)
 {
     this.id             = id;
     this.group          = group;
     this.green          = null;
     this.updater        = null;
     this.readOnly       = readOnly;
     this.objects        = null;
     this.immutableModel = new WeakReference <ImmutableModel>(immutableModel);
 }
コード例 #4
0
 protected ImmutableObjectBase(ObjectId id, ImmutableModel model)
 {
     if (id == null)
     {
         throw new ArgumentNullException(nameof(id));
     }
     if (model == null)
     {
         throw new ArgumentNullException(nameof(model));
     }
     this.id    = id;
     this.model = model;
 }
コード例 #5
0
 public void AddReference(ImmutableModel reference)
 {
     if (reference.ModelGroup != null)
     {
         GreenModelGroup gmg = reference.ModelGroup.Green;
         foreach (var greenReference in gmg.References)
         {
             this.AddReference(greenReference.Value);
         }
         foreach (var greenModel in gmg.Models)
         {
             this.AddReference(greenModel.Value);
         }
     }
     else
     {
         this.AddReference(reference.Green);
     }
 }
コード例 #6
0
ファイル: MutableModel.cs プロジェクト: Anjireddy4246/meta-cs
        public ImmutableModel ToImmutable(bool evaluateLazyValues = true, CancellationToken cancellationToken = default)
        {
            ImmutableModel result;

            if (this.group != null)
            {
                ImmutableModelGroup immutableGroup = this.group.ToImmutable(evaluateLazyValues, cancellationToken);
                if (immutableGroup != null)
                {
                    if (this.readOnly)
                    {
                        result = immutableGroup.GetReference(this.id);
                    }
                    else
                    {
                        result = immutableGroup.GetModel(this.id);
                    }
                    return(result);
                }
            }
            else
            {
                if (evaluateLazyValues)
                {
                    this.EvaluateLazyValues(cancellationToken);
                }
                GreenModel currentGreen = this.Green;
                if (this.immutableModel.TryGetTarget(out result) && result != null && result.Green == currentGreen)
                {
                    return(result);
                }
                else
                {
                    result = new ImmutableModel(currentGreen, this);
                    Interlocked.Exchange(ref this.immutableModel, new WeakReference <ImmutableModel>(result));
                    return(result);
                }
            }
            return(null);
        }
コード例 #7
0
ファイル: ObjectId.cs プロジェクト: Anjireddy4246/meta-cs
 public abstract ImmutableObjectBase CreateImmutable(ImmutableModel model);
コード例 #8
0
 internal static ImmutableModelList <T> FromGreenSingleValue(object value, ImmutableModel model, ObjectId context)
 {
     return(new ImmutableModelListFromGreenSingle <T>(value, model, context));
 }
コード例 #9
0
 internal static ImmutableModelList <T> FromObjectIdList(ImmutableList <ObjectId> green, ImmutableModel model)
 {
     return(new ImmutableModelListFromObjectIdListImmutable <T>(green, model));
 }
コード例 #10
0
 internal static ImmutableModelList <T> FromGreenList(GreenList green, ImmutableModel model, ObjectId context)
 {
     return(new ImmutableModelListFromGreenListImmutable <T>(green, model, context));
 }
コード例 #11
0
 internal ImmutableModelListFromGreenSingle(object greenValue, ImmutableModel model, ObjectId context)
 {
     this.greenValue = greenValue;
     this.model      = model;
     this.context    = context;
 }
コード例 #12
0
 internal ImmutableModelListFromObjectIdListImmutable(ImmutableList <ObjectId> green, ImmutableModel model)
 {
     this.green = green;
     this.model = model;
 }
コード例 #13
0
 internal ImmutableModelListFromGreenListImmutable(GreenList green, ImmutableModel model, ObjectId context)
 {
     this.green   = green;
     this.model   = model;
     this.context = context;
 }
コード例 #14
0
 public void AddModel(ImmutableModel model)
 {
     // TODO
     throw new NotImplementedException();
 }
コード例 #15
0
 internal ImmutableObjectBase CreateImmutable(ImmutableModel model)
 {
     return(this.CreateObjectId().CreateImmutable(model));
 }
コード例 #16
0
        public ImmutableObject ToImmutable()
        {
            ImmutableModel immutableModel = this.model.ToImmutable();

            return(immutableModel.GetObject(this));
        }