Exemple #1
0
        public IEnumerable <MockObject> GetObjects(EtpVersion version, MockGraphContext context, bool?activeStatusFilter = null, DateTime?storeLastWriteFilter = null)
        {
            CheckLocked();

            var uri = context.Uri;

            if (!((version == EtpVersion.v11 && uri.IsEtp11) || (version == EtpVersion.v12 && uri.IsEtp12)))
            {
                yield break;
            }

            IEnumerable <MockObject> objects = null;

            var dataspace = GetDataspace(uri);

            if (dataspace == null)
            {
                if (uri.IsRootUri)
                {
                    objects = Dataspaces.SelectMany(d => d.Objects.Values);
                }
                else
                {
                    yield break;
                }
            }

            if (objects == null)
            {
                if (uri.IsBaseUri)
                {
                    if (uri.IsFamilyVersionUri)
                    {
                        objects = dataspace.Objects.Values.FilterByFamilyAndVersion(uri.DataObjectType);
                    }
                    else
                    {
                        objects = dataspace.Objects.Values;
                    }
                }
                else
                {
                    var @object = GetObject(version, uri);
                    if (@object == null)
                    {
                        yield break;
                    }

                    objects = @object.WalkGraph(context);
                }
            }

            var objectTypes = context.DataObjectTypes;

            foreach (var @object in objects.FilterByType(objectTypes).FilterByActiveStatus(activeStatusFilter).FilterByStoreLastWrite(storeLastWriteFilter))
            {
                yield return(@object);
            }
        }
Exemple #2
0
        public MockDataspace GetDataspace(EtpUri uri)
        {
            CheckLocked();

            var dataspace = uri.Dataspace ?? string.Empty;

            return(Dataspaces.FirstOrDefault(d => string.Equals(d.Name, dataspace, StringComparison.OrdinalIgnoreCase)));
        }
Exemple #3
0
 public void RemoveDataspace(MockDataspace dataspace)
 {
     ExecuteWithLock(() =>
     {
         Dataspaces.Remove(dataspace);
         RefreshAll();
     });
 }
Exemple #4
0
 public void AddDataspace(MockDataspace dataspace)
 {
     ExecuteWithLock(() =>
     {
         Dataspaces.Add(dataspace);
         RefreshAll();
     });
 }