static string[] GetMemberNamesFromMethodCall(MethodCall methodCall)
        {
            List <string> names = new List <string>();

            while (methodCall != null)
            {
                names.Insert(0, methodCall.MethodName);

                SelfReference    selfRef       = methodCall.Target as SelfReference;
                InstanceVariable instance      = methodCall.Target as InstanceVariable;
                LocalVariable    localVariable = methodCall.Target as LocalVariable;
                methodCall = methodCall.Target as MethodCall;
                if (methodCall == null)
                {
                    if (selfRef != null)
                    {
                        names.Insert(0, "self");
                    }
                    else if (instance != null)
                    {
                        names.Insert(0, instance.Name);
                    }
                    else if (localVariable != null)
                    {
                        names.Insert(0, localVariable.Name);
                    }
                }
            }
            return(names.ToArray());
        }
Example #2
0
        private static void SelfReferenceTest()
        {
            var context = new ModelSelfReferences();

            var parentRef = new SelfReference()
            {
                Name = "ParentRef",
            };
            var childRef = new SelfReference()
            {
                Name = "ChildRef",
                ParentSelfReference = parentRef,
            };

            context.SelfReferences.Add(parentRef);
            context.SelfReferences.Add(childRef);
            context.SaveChanges();

            foreach (var s in context.SelfReferences.ToList())
            {
                Console.Write(s.Name + " cu parintele: ");
                if (s.ParentSelfReference != null)
                {
                    Console.WriteLine(s.ParentSelfReference.Name);
                }
                else
                {
                    Console.WriteLine();
                }
            }
        }
Example #3
0
        public virtual ApiSelfReferenceServerResponseModel MapEntityToModel(
            SelfReference item)
        {
            var model = new ApiSelfReferenceServerResponseModel();

            model.SetProperties(item.Id,
                                item.SelfReferenceId,
                                item.SelfReferenceId2);
            if (item.SelfReferenceIdNavigation != null)
            {
                var selfReferenceIdModel = new ApiSelfReferenceServerResponseModel();
                selfReferenceIdModel.SetProperties(
                    item.SelfReferenceIdNavigation.Id,
                    item.SelfReferenceIdNavigation.SelfReferenceId,
                    item.SelfReferenceIdNavigation.SelfReferenceId2);

                model.SetSelfReferenceIdNavigation(selfReferenceIdModel);
            }

            if (item.SelfReferenceId2Navigation != null)
            {
                var selfReferenceId2Model = new ApiSelfReferenceServerResponseModel();
                selfReferenceId2Model.SetProperties(
                    item.SelfReferenceId2Navigation.Id,
                    item.SelfReferenceId2Navigation.SelfReferenceId,
                    item.SelfReferenceId2Navigation.SelfReferenceId2);

                model.SetSelfReferenceId2Navigation(selfReferenceId2Model);
            }

            return(model);
        }
Example #4
0
        public override global::System.Data.DataSet Clone()
        {
            SelfReference cln = ((SelfReference)(base.Clone()));

            cln.InitVars();
            cln.SchemaSerializationMode = this.SchemaSerializationMode;
            return(cln);
        }
Example #5
0
        public override object Visit(SelfReference e)
        {
            Tuple <bool, string> r;

            using (isKindOf.set("R"))
                r = e.R.accept(this) as Tuple <bool, string>;

            return(new SparqlRelatedToVariable(owlNC, activeFreeVarId.get(), activeFreeVarId.get(), r.Item2, r.Item1));
        }
Example #6
0
        public void MapEFToBOList()
        {
            var mapper = new DALSelfReferenceMapper();
            SelfReference entity = new SelfReference();
            entity.SetProperties(1, 1, 1);

            List<BOSelfReference> response = mapper.MapEFToBO(new List<SelfReference>() { entity });

            response.Count.Should().Be(1);
        }
Example #7
0
        public void MapModelToEntity()
        {
            var mapper = new DALSelfReferenceMapper();
            ApiSelfReferenceServerRequestModel model = new ApiSelfReferenceServerRequestModel();

            model.SetProperties(1, 1);
            SelfReference response = mapper.MapModelToEntity(1, model);

            response.SelfReferenceId.Should().Be(1);
            response.SelfReferenceId2.Should().Be(1);
        }
Example #8
0
        public virtual BOSelfReference MapEFToBO(
            SelfReference ef)
        {
            var bo = new BOSelfReference();

            bo.SetProperties(
                ef.Id,
                ef.SelfReferenceId,
                ef.SelfReferenceId2);
            return(bo);
        }
Example #9
0
        public virtual SelfReference MapBOToEF(
            BOSelfReference bo)
        {
            SelfReference efSelfReference = new SelfReference();

            efSelfReference.SetProperties(
                bo.Id,
                bo.SelfReferenceId,
                bo.SelfReferenceId2);
            return(efSelfReference);
        }
Example #10
0
        public void MapBOToEF()
        {
            var mapper = new DALSelfReferenceMapper();
            var bo = new BOSelfReference();
            bo.SetProperties(1, 1, 1);

            SelfReference response = mapper.MapBOToEF(bo);

            response.Id.Should().Be(1);
            response.SelfReferenceId.Should().Be(1);
            response.SelfReferenceId2.Should().Be(1);
        }
Example #11
0
        public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs)
        {
            SelfReference ds = new SelfReference();

            global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
            global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
            global::System.Xml.Schema.XmlSchemaAny         any      = new global::System.Xml.Schema.XmlSchemaAny();
            any.Namespace = ds.Namespace;
            sequence.Items.Add(any);
            type.Particle = sequence;
            global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
            if (xs.Contains(dsSchema.TargetNamespace))
            {
                global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                try {
                    global::System.Xml.Schema.XmlSchema schema = null;
                    dsSchema.Write(s1);
                    for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                    {
                        schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                        s2.SetLength(0);
                        schema.Write(s2);
                        if ((s1.Length == s2.Length))
                        {
                            s1.Position = 0;
                            s2.Position = 0;
                            for (; ((s1.Position != s1.Length) &&
                                    (s1.ReadByte() == s2.ReadByte()));)
                            {
                                ;
                            }
                            if ((s1.Position == s1.Length))
                            {
                                return(type);
                            }
                        }
                    }
                }
                finally {
                    if ((s1 != null))
                    {
                        s1.Close();
                    }
                    if ((s2 != null))
                    {
                        s2.Close();
                    }
                }
            }
            xs.Add(dsSchema);
            return(type);
        }
Example #12
0
 private void InsertData1()
 {
     using (var context = new ModelSelfRefrences())
     {
         var selfreference = new SelfReference
         {
             Name = "Test"
         };
         context.SelfReferences.Add(selfreference);
         context.SaveChanges();
     }
 }
Example #13
0
        public void MapEntityToModel()
        {
            var           mapper = new DALSelfReferenceMapper();
            SelfReference item   = new SelfReference();

            item.SetProperties(1, 1, 1);
            ApiSelfReferenceServerResponseModel response = mapper.MapEntityToModel(item);

            response.Id.Should().Be(1);
            response.SelfReferenceId.Should().Be(1);
            response.SelfReferenceId2.Should().Be(1);
        }
Example #14
0
        public void MapEFToBO()
        {
            var mapper = new DALSelfReferenceMapper();
            SelfReference entity = new SelfReference();
            entity.SetProperties(1, 1, 1);

            BOSelfReference response = mapper.MapEFToBO(entity);

            response.Id.Should().Be(1);
            response.SelfReferenceId.Should().Be(1);
            response.SelfReferenceId2.Should().Be(1);
        }
Example #15
0
        public void MapEntityToModelList()
        {
            var           mapper = new DALSelfReferenceMapper();
            SelfReference item   = new SelfReference();

            item.SetProperties(1, 1, 1);
            List <ApiSelfReferenceServerResponseModel> response = mapper.MapEntityToModel(new List <SelfReference>()
            {
                { item }
            });

            response.Count.Should().Be(1);
        }
Example #16
0
        public virtual async Task <ApiSelfReferenceServerResponseModel> Get(int id)
        {
            SelfReference record = await this.SelfReferenceRepository.Get(id);

            if (record == null)
            {
                return(null);
            }
            else
            {
                return(this.DalSelfReferenceMapper.MapEntityToModel(record));
            }
        }
        public void SelfReferenceNotProduceInfiniteLoop()
        {
            //Arrange
            SelfReference aReference = new SelfReference();
            SelfReference bReference = new SelfReference();

            //Act
            aReference.Value = bReference;
            bReference.Value = aReference;

            //Assert
            Assert.NotEqual(aReference, bReference);
        }
Example #18
0
        public virtual SelfReference MapModelToEntity(
            int id,
            ApiSelfReferenceServerRequestModel model
            )
        {
            SelfReference item = new SelfReference();

            item.SetProperties(
                id,
                model.SelfReferenceId,
                model.SelfReferenceId2);
            return(item);
        }
Example #19
0
        public virtual async Task <CreateResponse <ApiSelfReferenceServerResponseModel> > Create(
            ApiSelfReferenceServerRequestModel model)
        {
            CreateResponse <ApiSelfReferenceServerResponseModel> response = ValidationResponseFactory <ApiSelfReferenceServerResponseModel> .CreateResponse(await this.SelfReferenceModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                SelfReference record = this.DalSelfReferenceMapper.MapModelToEntity(default(int), model);
                record = await this.SelfReferenceRepository.Create(record);

                response.SetRecord(this.DalSelfReferenceMapper.MapEntityToModel(record));
                await this.mediator.Publish(new SelfReferenceCreatedNotification(response.Record));
            }

            return(response);
        }
Example #20
0
        public async void Get_ShouldReturnRecords()
        {
            var mock   = new ServiceMockFacade <ISelfReferenceService, ISelfReferenceRepository>();
            var record = new SelfReference();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(record));
            var service = new SelfReferenceService(mock.LoggerMock.Object,
                                                   mock.MediatorMock.Object,
                                                   mock.RepositoryMock.Object,
                                                   mock.ModelValidatorMockFactory.SelfReferenceModelValidatorMock.Object,
                                                   mock.DALMapperMockFactory.DALSelfReferenceMapperMock);

            ApiSelfReferenceServerResponseModel response = await service.Get(default(int));

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
Example #21
0
        public override string ToString()
        {
            if (SelfReference.Equals(default(ClrReference)))
            {
                return(ToStringNoReference());
            }

            var    clrObject = SelfReference.Object;
            string val       = (clrObject.Type.ElementType == ClrElementType.String && !IsAlreadyVisited)
                ? clrObject.GetStringValue() : "";

            if (SelfReference.Field != null)
            {
                val += $" Field: {SelfReference.Field.Name}";
            }

            return($"Address: 0x{clrObject.Address:X16} Type: {clrObject.Type.Name} Visited: {IsAlreadyVisited} {val}");
        }
 protected bool DetailTargetScopeMatched(Microsoft.ReportingServices.ReportIntermediateFormat.DataRegion dataRegionDef, IReference <IScope> outerScope, bool isColumnAxis, int index)
 {
     if (m_odpContext.RuntimeSortFilterInfo != null)
     {
         IReference <RuntimeSortFilterEventInfo> reference = m_odpContext.RuntimeSortFilterInfo[index];
         using (reference.PinValue())
         {
             RuntimeSortFilterEventInfo runtimeSortFilterEventInfo = reference.Value();
             if (runtimeSortFilterEventInfo != null)
             {
                 List <IReference <RuntimeDataRegionObj> > list = null;
                 List <int> list2 = null;
                 int        num   = -1;
                 if (isColumnAxis)
                 {
                     list  = runtimeSortFilterEventInfo.DetailColScopes;
                     list2 = runtimeSortFilterEventInfo.DetailColScopeIndices;
                     num   = dataRegionDef.CurrentColDetailIndex;
                 }
                 else
                 {
                     list  = runtimeSortFilterEventInfo.DetailRowScopes;
                     list2 = runtimeSortFilterEventInfo.DetailRowScopeIndices;
                     num   = dataRegionDef.CurrentRowDetailIndex;
                 }
                 if (list != null)
                 {
                     for (int i = 0; i < list.Count; i++)
                     {
                         if (SelfReference.Equals(list[i]) && num == list2[i])
                         {
                             return(true);
                         }
                     }
                 }
             }
         }
     }
     return(false);
 }
Example #23
0
        public virtual async Task <UpdateResponse <ApiSelfReferenceServerResponseModel> > Update(
            int id,
            ApiSelfReferenceServerRequestModel model)
        {
            var validationResult = await this.SelfReferenceModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                SelfReference record = this.DalSelfReferenceMapper.MapModelToEntity(id, model);
                await this.SelfReferenceRepository.Update(record);

                record = await this.SelfReferenceRepository.Get(id);

                ApiSelfReferenceServerResponseModel apiModel = this.DalSelfReferenceMapper.MapEntityToModel(record);
                await this.mediator.Publish(new SelfReferenceUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiSelfReferenceServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiSelfReferenceServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Example #24
0
 public object Visit(SelfReference e)
 {
     return(SELFREF(e.R));
 }
 /// <param name="out"> Defaults to <see cref="SelfReference.Allow"/>. </param>
 public static bool TryGetSelfReference(this ResourceType @this, out SelfReference @out) => TryGetMeta(@this, NapBuiltInMeta.SelfReference, out @out, SelfReference.Allow);
 object Deserialize(SelfReference selfRef)
 {
     return(componentCreator.RootComponent);
 }
        public void SelfReferenceNotProduceInfiniteLoop()
        {
            //Arrange
            SelfReference aReference = new SelfReference();
            SelfReference bReference = new SelfReference();

            //Act
            aReference.Value = bReference;
            bReference.Value = aReference;

            //Assert

            Assert.AreNotEqual(aReference, bReference);
        }
 public static string[] GetMemberNames(SelfReference selfRef)
 {
     return(new string[] { "self" });
 }
Example #29
0
        public Result OpenFileSystemWithPatch(out ReferenceCountedDisposable <IFileSystemSf> fileSystem,
                                              ProgramId programId, FileSystemProxyType fsType)
        {
            UnsafeHelpers.SkipParamInit(out fileSystem);

            const StorageType storageFlag = StorageType.All;

            using var scopedLayoutType = new ScopedStorageLayoutTypeSetter(storageFlag);

            // Get the program info for the caller and verify permissions
            Result rc = GetProgramInfo(out ProgramInfo callerProgramInfo);

            if (rc.IsFailure())
            {
                return(rc);
            }

            if (fsType != FileSystemProxyType.Manual)
            {
                if (fsType == FileSystemProxyType.Logo || fsType == FileSystemProxyType.Control)
                {
                    return(ResultFs.NotImplemented.Log());
                }
                else
                {
                    return(ResultFs.InvalidArgument.Log());
                }
            }

            Accessibility accessibility =
                callerProgramInfo.AccessControl.GetAccessibilityFor(AccessibilityType.MountContentManual);

            if (!accessibility.CanRead)
            {
                return(ResultFs.PermissionDenied.Log());
            }

            // Get the program info for the owner of the file system being opened
            rc = GetProgramInfoByProgramId(out ProgramInfo ownerProgramInfo, programId.Value);
            if (rc.IsFailure())
            {
                return(rc);
            }

            // Try to find the path to the original version of the file system
            Result originalResult = ServiceImpl.ResolveApplicationHtmlDocumentPath(out Path originalPath,
                                                                                   new Ncm.ApplicationId(programId.Value), ownerProgramInfo.StorageId);

            // The file system might have a patch version with no original version, so continue if not found
            if (originalResult.IsFailure() && !ResultLr.HtmlDocumentNotFound.Includes(originalResult))
            {
                return(originalResult);
            }

            // Use a separate bool because ref structs can't be used as type parameters
            bool           originalPathNormalizerHasValue = false;
            PathNormalizer originalPathNormalizer         = default;

            // Normalize the original version path if found
            if (originalResult.IsSuccess())
            {
                originalPathNormalizer = new PathNormalizer(originalPath, GetPathNormalizerOptions(originalPath));
                if (originalPathNormalizer.Result.IsFailure())
                {
                    return(originalPathNormalizer.Result);
                }

                originalPathNormalizerHasValue = true;
            }

            // Try to find the path to the patch file system
            Result patchResult = ServiceImpl.ResolveRegisteredHtmlDocumentPath(out Path patchPath, programId.Value);

            ReferenceCountedDisposable <IFileSystem> tempFileSystem = null;
            ReferenceCountedDisposable <IRomFileSystemAccessFailureManager> accessFailureManager = null;

            try
            {
                if (ResultLr.HtmlDocumentNotFound.Includes(patchResult))
                {
                    // There must either be an original version or patch version of the file system being opened
                    if (originalResult.IsFailure())
                    {
                        return(originalResult);
                    }

                    Assert.True(originalPathNormalizerHasValue);

                    // There is an original version and no patch version. Open the original directly
                    rc = ServiceImpl.OpenFileSystem(out tempFileSystem, originalPathNormalizer.Path, fsType, programId.Value);
                    if (rc.IsFailure())
                    {
                        return(rc);
                    }
                }
                else
                {
                    // Get the normalized path to the original file system
                    U8Span normalizedOriginalPath;
                    if (originalPathNormalizerHasValue)
                    {
                        normalizedOriginalPath = originalPathNormalizer.Path;
                    }
                    else
                    {
                        normalizedOriginalPath = U8Span.Empty;
                    }

                    // Normalize the path to the patch file system
                    var patchPathNormalizer = new PathNormalizer(patchPath, GetPathNormalizerOptions(patchPath));
                    if (patchPathNormalizer.Result.IsFailure())
                    {
                        return(patchPathNormalizer.Result);
                    }

                    if (patchResult.IsFailure())
                    {
                        return(patchResult);
                    }

                    U8Span normalizedPatchPath = patchPathNormalizer.Path;

                    // Open the file system using both the original and patch versions
                    rc = ServiceImpl.OpenFileSystemWithPatch(out tempFileSystem, normalizedOriginalPath,
                                                             normalizedPatchPath, fsType, programId.Value);
                    if (rc.IsFailure())
                    {
                        return(rc);
                    }
                }

                // Add all the file system wrappers
                tempFileSystem = StorageLayoutTypeSetFileSystem.CreateShared(ref tempFileSystem, storageFlag);
                tempFileSystem = AsynchronousAccessFileSystem.CreateShared(ref tempFileSystem);

                accessFailureManager = SelfReference.AddReference <IRomFileSystemAccessFailureManager>();
                tempFileSystem       = DeepRetryFileSystem.CreateShared(ref tempFileSystem, ref accessFailureManager);

                fileSystem = FileSystemInterfaceAdapter.CreateShared(ref tempFileSystem);
                return(Result.Success);
            }
            finally
            {
                tempFileSystem?.Dispose();
                accessFailureManager?.Dispose();
            }
        }
Example #30
0
            public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs)
            {
                global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
                global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
                SelfReference ds = new SelfReference();

                global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
                any1.Namespace       = "http://www.w3.org/2001/XMLSchema";
                any1.MinOccurs       = new decimal(0);
                any1.MaxOccurs       = decimal.MaxValue;
                any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any1);
                global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
                any2.Namespace       = "urn:schemas-microsoft-com:xml-diffgram-v1";
                any2.MinOccurs       = new decimal(1);
                any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any2);
                global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute1.Name       = "namespace";
                attribute1.FixedValue = ds.Namespace;
                type.Attributes.Add(attribute1);
                global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute2.Name       = "tableTypeName";
                attribute2.FixedValue = "SelfReferenceDataTable";
                type.Attributes.Add(attribute2);
                type.Particle = sequence;
                global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
                if (xs.Contains(dsSchema.TargetNamespace))
                {
                    global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                    global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                    try {
                        global::System.Xml.Schema.XmlSchema schema = null;
                        dsSchema.Write(s1);
                        for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                        {
                            schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                            s2.SetLength(0);
                            schema.Write(s2);
                            if ((s1.Length == s2.Length))
                            {
                                s1.Position = 0;
                                s2.Position = 0;
                                for (; ((s1.Position != s1.Length) &&
                                        (s1.ReadByte() == s2.ReadByte()));)
                                {
                                    ;
                                }
                                if ((s1.Position == s1.Length))
                                {
                                    return(type);
                                }
                            }
                        }
                    }
                    finally {
                        if ((s1 != null))
                        {
                            s1.Close();
                        }
                        if ((s2 != null))
                        {
                            s2.Close();
                        }
                    }
                }
                xs.Add(dsSchema);
                return(type);
            }