예제 #1
0
        /// <summary>
        /// Gets an array of objects names for a specific object container
        /// </summary>
        /// <param name="objectType">object type to get its objects</param>
        public string[] ObjectNames(ObjectType objectType)
        {
            string[] result = new string[0];
            if (tree.Nodes.Count == 0)
            {
                return(result);
            }

            Containers          containers = AccessApp.ContainersFactory(tree.Nodes[0].Text);
            ObjectTypeExtension ote        = containers.Find(objectType);

            if (ote != null)
            {
                ContainerNames names      = ote.Container;
                TreeNode[]     matchNodes = tree.Nodes[0].Nodes.Find(names.DisplayPluralName, true);
                if (matchNodes.Length == 1)
                {
                    result = new string[matchNodes[0].Nodes.Count];
                    for (int i = 0; i < matchNodes[0].Nodes.Count; i++)
                    {
                        result[i] = matchNodes[0].Nodes[i].Text;
                    }
                }
            }
            return(result);
        }
예제 #2
0
        public ObjectTypeExtension Create(IDescriptorContext context, ObjectTypeExtensionNode node)
        {
            var preserveSyntaxNodes = context.Options.PreserveSyntaxNodes;

            var typeDefinition = new ObjectTypeDefinition(node.Name.Value);

            typeDefinition.BindTo = node.GetBindingValue();

            foreach (NamedTypeNode typeNode in node.Interfaces)
            {
                typeDefinition.Interfaces.Add(TypeReference.Create(typeNode));
            }

            SdlToTypeSystemHelper.AddDirectives(typeDefinition, node);

            DeclareFields(typeDefinition, node.Fields, preserveSyntaxNodes);

            return(ObjectTypeExtension.CreateUnsafe(typeDefinition));
        }
예제 #3
0
        internal override CommandLine Run()
        {
            if (App == null && Objects.Count > 0)
            {
                InitializeAccessApplication();
            }
            foreach (IObjecOptions currentObject in Objects)
            {
                ObjectTypeExtension ote = App.AllowedContainers.Find(currentObject.ObjectType);

                Console.Write(Properties.Resources.Exporting, ote.FileExtension, currentObject);
                AccessObject accessObject = AccessObject.CreateInstance(App, currentObject.ObjectType, currentObject.ToString());
                accessObject.Options = currentObject.Options;
                string outputFile = Path.Combine(RootPath, ote.Container.InvariantName, currentObject.ToString()) +
                                    String.Concat(".", ote.FileExtension, ".txt");
                accessObject.Save(outputFile);
                Console.WriteLine(Properties.Resources.ColonOk);
            }
            App.Dispose();
            return(this);
        }
예제 #4
0
        //private string GetExtension(string fileName) {
        //    return Path.GetExtension(Path.GetFileNameWithoutExtension(fileName));
        //}

        private void FillContainerFiles(DirectoryInfo di, TreeNode parentNode, List <ObjectTypeExtension> objectTypes)
        {
            string fileExtension = "*";

            if (objectTypes.Count == 1)
            {
                fileExtension = objectTypes[0].FileExtension.ToString();
            }

            foreach (FileInfo fi in di.EnumerateFiles(string.Format("*.{0}.txt", fileExtension)))
            {
                ObjectTypeExtension ote = GetObjectTypeExtension(fi.Name, objectTypes);
                if (ote != null)
                {
                    TreeNode node = new TreeNode(fi.Name);
                    node.Tag              = new ObjectOptions(fi.FullName, ote.ObjectType);
                    node.ImageKey         = ote.FileExtension.ToString();
                    node.SelectedImageKey = ote.FileExtension.ToString();
                    parentNode.Nodes.Add(node);
                }
            }
        }
예제 #5
0
        public void AddType_QueryAndExtensionAreAdded_SchemaIsCreated()
        {
            // arrange
            var queryType = new ObjectType(t => t
                                           .Name("Query")
                                           .Field("foo")
                                           .Resolver("bar"));

            var queryTypeExtension = new ObjectTypeExtension(t => t
                                                             .Name("Query")
                                                             .Field("bar")
                                                             .Resolver("foo"));

            // act
            ISchema schema = SchemaBuilder.New()
                             .AddType(queryType)
                             .AddType(queryTypeExtension)
                             .Create();

            // assert
            ObjectType type = schema.GetType <ObjectType>("Query");

            Assert.True(type.Fields.ContainsField("bar"));
        }
예제 #6
0
            public ValueTask <IReadOnlyCollection <ITypeSystemMember> > CreateTypesAsync(
                IDescriptorContext context,
                CancellationToken cancellationToken)
            {
                var list = new List <ITypeSystemMember>();

                var typeDefinition = new ObjectTypeDefinition("Query");

                typeDefinition.Fields.Add(new(
                                              "hello",
                                              type: TypeReference.Parse("String!"),
                                              pureResolver: _ => "world"));
                list.Add(ObjectType.CreateUnsafe(typeDefinition));

                var typeExtensionDefinition = new ObjectTypeDefinition("Person");

                typeExtensionDefinition.Fields.Add(new(
                                                       "dynamic",
                                                       type: TypeReference.Parse("String!"),
                                                       pureResolver: _ => "value"));
                list.Add(ObjectTypeExtension.CreateUnsafe(typeExtensionDefinition));

                return(new(list));
            }