Example #1
0
        public CreateTemplateCode CreateNodeTemplate(Guid uid, string name, string description, string key,
                                                     Guid needsInterface,
                                                     Guid providesInterface, bool defaultCreated, bool isReadable, bool isReadableFixed, bool isWriteable,
                                                     bool isWriteableFixed, NodeDataType dataType, int maxInstances, bool isAdapterInterface, bool deleteAble)
        {
            var nodeTemplate = new NodeTemplate {
                ObjId = uid
            };

            nodeTemplate.Name        = name;
            nodeTemplate.Description = description;
            nodeTemplate.Key         = key;
            nodeTemplate.NeedsInterface2InterfacesType   = needsInterface;
            nodeTemplate.ProvidesInterface2InterfaceType = providesInterface;
            nodeTemplate.DefaultCreated     = defaultCreated;
            nodeTemplate.IsReadable         = isReadable;
            nodeTemplate.IsReadableFixed    = isReadableFixed;
            nodeTemplate.IsWriteable        = isWriteable;
            nodeTemplate.IsWriteableFixed   = isWriteableFixed;
            nodeTemplate.This2NodeDataType  = (long)dataType;
            nodeTemplate.MaxInstances       = maxInstances;
            nodeTemplate.IsAdapterInterface = isAdapterInterface;
            nodeTemplate.IsDeleteable       = deleteAble;

            if (!_nodeTemplates.ContainsKey(uid))
            {
                _nodeTemplates.Add(uid, nodeTemplate);
            }

            return(CreateTemplateCode.Created);
        }
Example #2
0
        /// <summary>Snippet for InsertAsync</summary>
        public async Task InsertAsync()
        {
            // Snippet: InsertAsync(string, string, NodeTemplate, CallSettings)
            // Additional: InsertAsync(string, string, NodeTemplate, CancellationToken)
            // Create client
            NodeTemplatesClient nodeTemplatesClient = await NodeTemplatesClient.CreateAsync();

            // Initialize request argument(s)
            string       project = "";
            string       region  = "";
            NodeTemplate nodeTemplateResource = new NodeTemplate();
            // Make the request
            lro::Operation <Operation, Operation> response = await nodeTemplatesClient.InsertAsync(project, region, nodeTemplateResource);

            // Poll until the returned long-running operation is complete
            lro::Operation <Operation, Operation> completedResponse = await response.PollUntilCompletedAsync();

            // Retrieve the operation result
            Operation result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            lro::Operation <Operation, Operation> retrievedResponse = await nodeTemplatesClient.PollOnceInsertAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                Operation retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
Example #3
0
        public async Task <IActionResult> PutNodeTemplate(Guid id, NodeTemplate nodeTemplate)
        {
            if (id != nodeTemplate.Id)
            {
                return(BadRequest());
            }

            _context.Entry(nodeTemplate).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!NodeTemplateExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public CreateTemplateCode CreateNodeTemplate(Guid uid, string name, string description, string key, Guid needsInterface, Guid providesInterface,
                                                     bool defaultCreated, bool isReadable, bool isReadableFixed, bool isWriteable, bool isWriteableFixed, Base.Templates.NodeDataType dataType,
                                                     int maxInstances, bool isAdapterInterface, bool deleteAble)
        {
            var nodeTemplate = new NodeTemplate
            {
                ObjId       = uid,
                Name        = name,
                Description = description,
                Key         = key,
                This2DefaultMobileVisuTemplate =
                    VisuMobileObjectTemplateTypeAttribute.GetFromEnum(VisuMobileObjectTemplateTypes.Label),
                NeedsInterface2InterfacesType   = needsInterface,
                ProvidesInterface2InterfaceType = providesInterface,
                DefaultCreated     = defaultCreated,
                IsReadable         = isReadable,
                IsReadableFixed    = isReadableFixed,
                IsWriteable        = isWriteable,
                IsWriteableFixed   = isWriteableFixed,
                This2NodeDataType  = (long)dataType,
                MaxInstances       = maxInstances,
                IsAdapterInterface = isAdapterInterface,
                IsDeleteable       = deleteAble
            };



            _nodeTemplates.Add(uid, nodeTemplate);
            return(CreateTemplateCode.Created);
        }
Example #5
0
        private GraphNode CreateNode(NodeTemplate template)
        {
            //  Create the node type
            GraphNode node = new GraphNode(template.Title.Last(), template.UXMLPath, template.USSPath, template.RuntimeNodeType, m_edgeConnectorListener, null);
            //var runtimeNodeInstance = Activator.CreateInstance(template.RuntimeNodeType);

            var fieldTemplate = m_fieldProvider.GetNodeFieldTemplateByType(template.RuntimeNodeType);

            foreach (var input in fieldTemplate.InputPorts)
            {
                node.AddSlot(input.CreateCopy());
            }

            foreach (var output in fieldTemplate.OutputPorts)
            {
                node.AddSlot(output.CreateCopy());
            }

            foreach (var property in fieldTemplate.Properties)
            {
                node.AddProperty(new VisualProperty(property.FieldType, node.RuntimeInstance));
            }

            node.BindPortsAndProperties();
            return(node);
        }
Example #6
0
        public GraphNode CreateNode(SerializedNode serializedNode)
        {
            Type         runtimeNodeType = serializedNode.NodeRuntimeType;
            NodeTemplate nodeTemplate    = m_nodeProvider.GetTemplateFromRuntimeType(runtimeNodeType);
            GraphNode    node            = new GraphNode(nodeTemplate.Title.Last(), nodeTemplate.UXMLPath, nodeTemplate.USSPath, runtimeNodeType, m_edgeConnectorListener, serializedNode);

            node.Position = serializedNode.EditorPosition;

            var fieldTemplate = m_fieldProvider.GetNodeFieldTemplateByType(runtimeNodeType);

            for (int j = 0; j < serializedNode.SerializedPorts.Count; j++)
            {
                var sPort = serializedNode.SerializedPorts[j];
                var port  = new PortDescription(sPort.Guid, sPort.DisplayName, sPort.PortType, sPort.Direction, sPort.AllowMultipleConnections, sPort.AddIdenticalPortOnConnect);
                node.AddSlot(port, false);
            }

            foreach (var property in fieldTemplate.Properties)
            {
                node.AddProperty(new VisualProperty(property.FieldType, node.RuntimeInstance));
            }

            node.BindPortsAndProperties();

            return(node);
        }
Example #7
0
        public async Task <ActionResult <NodeTemplate> > PostNodeTemplate(NodeTemplate nodeTemplate)
        {
            _context.NodesCatalog.Add(nodeTemplate);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetNodeTemplate", new { id = nodeTemplate.Id }, nodeTemplate));
        }
        public static NodeInstance CreateNodeInstanceFromTemplate(NodeTemplate template)
        {
            var instance = new NodeInstance
            {
                ObjId       = Guid.NewGuid(),
                Name        = template.Name,
                Description = template.Description,
                This2NodeTemplateNavigation = template,
                This2NodeTemplate           = template.ObjId,
                IsWriteable = template.IsWriteable,
                IsReadable  = template.IsReadable
            };

            foreach (var prop in template.PropertyTemplate)
            {
                var propertyInstance = new PropertyInstance
                {
                    ObjId = Guid.NewGuid(),
                    This2NodeInstanceNavigation     = instance,
                    This2PropertyTemplateNavigation = prop,
                    This2PropertyTemplate           = prop.ObjId,
                    Value = prop.DefaultValue
                };
                instance.PropertyInstance.Add(propertyInstance);
            }

            return(instance);
        }
 void StartPlacing(int unitIndex)
 {
     isPlacing = true;
     currentUnit = unitIndex;
     placeholder = Instantiate(units[currentUnit]);
     placeholder.enabled = true;
     placeholder.GetComponent<TurretNode>().enabled = false;
 }
        /// <summary>
        /// Creates test configuration
        /// </summary>
        /// <param name="repo">The package repository</param>
        /// <returns>The configuration</returns>
        private Configuration CreateConfiguration(IPackageRepository repo)
        {
            var template = new NodeTemplate
            {
                Code           = "node",
                Configuration  = "{}",
                ContainerTypes = new[] { "node" }.ToList(),
                Name = "node",
                PackageRequirements =
                    new[]
                {
                    new NodeTemplate.PackageRequirement(
                        "KlusterKite.NodeManager",
                        null)
                }.ToList()
            };

            var migrator = new MigratorTemplate
            {
                Code                = "migrator",
                Configuration       = "{}",
                Name                = "migrator",
                PackageRequirements =
                    new[]
                {
                    new NodeTemplate.PackageRequirement(
                        "KlusterKite.NodeManager.Tests",
                        null),
                    new NodeTemplate.PackageRequirement(
                        "Akka.Logger.Serilog",
                        null),
                }.ToList()
            };

            var packageDescriptions = repo.SearchAsync(string.Empty, true).GetAwaiter().GetResult()
                                      .Select(p => p.Identity).Select(
                p => new PackageDescription {
                Id = p.Id, Version = p.Version.ToString()
            }).ToList();

            var configurationSettings =
                new ConfigurationSettings
            {
                NodeTemplates = new[] { template }.ToList(),
                MigratorTemplates = new[] { migrator }.ToList(),
                Packages = packageDescriptions,
                NugetFeed = "http://nuget/",
                SeedAddresses = new[] { "http://seed" }.ToList()
            };

            var configuration = new Configuration {
                Settings = configurationSettings
            };

            return(configuration);
        }
Example #11
0
        public ManifestCaptureGraphInstance(NodeTemplate singleNodeGraph)
        {
            node     = singleNodeGraph;
            instance = node.CreateInstance();

            var connectionMapper = new ConnectionMapper(instance, this);

            node.Inputs(connectionMapper, instance);
            node.Outputs(connectionMapper, instance);
        }
Example #12
0
 // 指定した枝数を持つノードをカウントする
 public static int CountNodeType(NodeTemplate[] TempList, int BranchNum)
 {
     int ret = 0;
     foreach(var it in TempList) {
         if(it.LinkNum == BranchNum) {
             ret++;
         }
     }
     return ret;
 }
 void InitGrid(int rows, int cols)
 {
     m_nodeMap = new NodeTemplate[rows, cols];
     for (int row = 0; row < rows; ++row)
     {
         for (int col = 0; col < cols; ++col)
         {
             m_nodeMap[row, col] = new NodeTemplate();
         }
     }
 }
Example #14
0
        private ICollection <NodeTemplate> GetDefaultChildNodeTemplates(NodeTemplate nodeTemplate)
        {
            var templates = Db.NodeTemplates
                            .Include(a => a.This2NodeDataTypeNavigation)
                            .Include(a => a.NeedsInterface2InterfacesTypeNavigation)
                            .Include(a => a.ProvidesInterface2InterfaceTypeNavigation)
                            .Include(a => a.PropertyTemplate).ThenInclude(b => b.This2PropertyTypeNavigation)
                            .Where(a => a.DefaultCreated & a.NeedsInterface2InterfacesType == nodeTemplate.ProvidesInterface2InterfaceType).ToList();

            return(templates);
        }
Example #15
0
 // 指定した枝数を持つノードのX番目を取得する
 public static NodeTemplate GetTempFromBranchIndex(NodeTemplate[] TempList, int BranchNum, int Index)
 {
     foreach(var it in TempList) {
         if(it.LinkNum == BranchNum) {
             if(Index <= 0) {
                 return it;
             }
             Index--;
         }
     }
     return null;
 }
Example #16
0
        public CreateTemplateCode CreateNodeTemplate(Guid uid, string name, string description, string key,
                                                     Guid needsInterface,
                                                     Guid providesInterface, bool defaultCreated, bool isReadable, bool isReadableFixed, bool isWriteable,
                                                     bool isWriteableFixed, Base.Templates.NodeDataType dataType, int maxInstances, bool isAdapterInterface, bool deleteAble)
        {
            try
            {
                var nodeTemplate = Db.NodeTemplates.SingleOrDefault(p => p.ObjId == uid);
                var retValue     = CreateTemplateCode.Updated;

                bool isNewObject = false;
                if (nodeTemplate == null)
                {
                    isNewObject        = true;
                    nodeTemplate       = new NodeTemplate();
                    nodeTemplate.ObjId = uid;
                    retValue           = CreateTemplateCode.Created;
                }

                nodeTemplate.Name        = name;
                nodeTemplate.Description = description;
                nodeTemplate.Key         = key;
                nodeTemplate.This2DefaultMobileVisuTemplate  = VisuMobileObjectTemplateTypeAttribute.GetFromEnum(VisuMobileObjectTemplateTypes.Label);
                nodeTemplate.NeedsInterface2InterfacesType   = needsInterface;
                nodeTemplate.ProvidesInterface2InterfaceType = providesInterface;
                nodeTemplate.DefaultCreated     = defaultCreated;
                nodeTemplate.IsReadable         = isReadable;
                nodeTemplate.IsReadableFixed    = isReadableFixed;
                nodeTemplate.IsWriteable        = isWriteable;
                nodeTemplate.IsWriteableFixed   = isWriteableFixed;
                nodeTemplate.This2NodeDataType  = (long)dataType;
                nodeTemplate.MaxInstances       = maxInstances;
                nodeTemplate.IsAdapterInterface = isAdapterInterface;
                nodeTemplate.IsDeleteable       = deleteAble;

                if (isNewObject)
                {
                    Db.NodeTemplates.Add(nodeTemplate);
                }
                else
                {
                    Db.NodeTemplates.Update(nodeTemplate);
                }

                return(retValue);
            }
            catch (Exception e)
            {
                SystemLogger.Instance.LogError($"Could not create node template {uid}-{name}.{key} {e}");

                throw;
            }
        }
        public void TestConfigurationCompatibilityConfigurationsSet()
        {
            this.CreateTestDatabase();

            var template1 = new NodeTemplate
            {
                Code                = "template1",
                Configuration       = "1",
                PackageRequirements = this.GetPackageRequirements("p1; p2")
            };

            var template2 = new NodeTemplate
            {
                Code                = "template2",
                Configuration       = "2",
                PackageRequirements = this.GetPackageRequirements("p2; p3")
            };

            var configuration = new Configuration
            {
                MinorVersion = 1,
                Name         = "1",
                State        = EnConfigurationState.Active,
                Settings     =
                    new ConfigurationSettings
                {
                    NodeTemplates =
                        this.GetList(template1, template2),
                    Packages = this.CreatePackages(
                        "p1;0.0.1",
                        "p2;0.0.1",
                        "p3;0.0.1")
                }
            };

            using (var context = this.CreateContext())
            {
                // facepalm - https://github.com/aspnet/EntityFramework/issues/6872
                var ids = context.Configurations.Select(r => r.Id).OrderByDescending(id => id).ToList();

                var compatibleTemplates = configuration.GetCompatibleTemplates(context)
                                          .OrderByDescending(t => t.CompatibleConfigurationId).ThenBy(o => o.TemplateCode).ToList();
                Assert.Equal(2, compatibleTemplates.Count);
                Assert.Equal("template1", compatibleTemplates.Select(t => t.TemplateCode).First());

                this.output.WriteLine($"Database configuration ids: {string.Join(", ", ids)}");
                this.output.WriteLine(
                    $"Compatible templates configuration ids: {string.Join(", ", compatibleTemplates.Select(t => t.CompatibleConfigurationId))}");

                Assert.Equal(ids[0], compatibleTemplates.Select(t => t.CompatibleConfigurationId).First());
                Assert.Equal(ids[1], compatibleTemplates.Select(t => t.CompatibleConfigurationId).Skip(1).First());
            }
        }
Example #18
0
 /// <summary>Snippet for Get</summary>
 public void Get()
 {
     // Snippet: Get(string, string, string, CallSettings)
     // Create client
     NodeTemplatesClient nodeTemplatesClient = NodeTemplatesClient.Create();
     // Initialize request argument(s)
     string project      = "";
     string region       = "";
     string nodeTemplate = "";
     // Make the request
     NodeTemplate response = nodeTemplatesClient.Get(project, region, nodeTemplate);
     // End snippet
 }
Example #19
0
 /// <summary>Snippet for Insert</summary>
 public void Insert()
 {
     // Snippet: Insert(string, string, NodeTemplate, CallSettings)
     // Create client
     NodeTemplatesClient nodeTemplatesClient = NodeTemplatesClient.Create();
     // Initialize request argument(s)
     string       project = "";
     string       region  = "";
     NodeTemplate nodeTemplateResource = new NodeTemplate();
     // Make the request
     Operation response = nodeTemplatesClient.Insert(project, region, nodeTemplateResource);
     // End snippet
 }
Example #20
0
        public NodeInstance CreateNodeInstance(NodeTemplate template)
        {
            var node = NodeInstanceFactory.CreateNodeInstanceFromTemplate(template);

            var childrens = GetDefaultChildNodeTemplates(template);

            foreach (var child in childrens)
            {
                node.InverseThis2ParentNodeInstanceNavigation.Add(CreateNodeInstance(child));
            }

            return(node);
        }
        /// <summary>
        /// Creates the default configuration
        /// </summary>
        /// <param name="packages">The list of defined packages to override</param>
        /// <param name="templatePackageRequirements">The template package requirements</param>
        /// <returns>The configuration</returns>
        internal static Configuration CreateConfiguration(string[] packages = null, string[] templatePackageRequirements = null)
        {
            if (packages == null)
            {
                packages = new[] { "p1 1.0.0", "p2 1.0.0", "dp1 1.0.0", "dp2 1.0.0", "KlusterKite.NodeManager.Migrator.Executor 1.0.0" };
            }

            if (templatePackageRequirements == null)
            {
                templatePackageRequirements = new[] { "p1", "p2 1.0.0" };
            }

            var packageDescriptions = new List <PackageDescription>(CreatePackageDescriptions(packages));

            var nodeTemplates = new List <NodeTemplate>();
            var t1            = new NodeTemplate
            {
                Code                = "t1",
                Configuration       = "t1",
                PackageRequirements = CreatePackageRequirement(templatePackageRequirements),
                ContainerTypes      = new List <string> {
                    "test"
                }
            };

            nodeTemplates.Add(t1);

            var migratorTemplates = new List <MigratorTemplate>();
            var m1 = new MigratorTemplate
            {
                Code                = "m1",
                Configuration       = "m1",
                PackageRequirements =
                    CreatePackageRequirement(templatePackageRequirements)
            };

            migratorTemplates.Add(m1);

            var configurationSettings =
                new ConfigurationSettings
            {
                Packages          = packageDescriptions,
                NodeTemplates     = nodeTemplates,
                MigratorTemplates = migratorTemplates
            };

            return(new Configuration {
                Settings = configurationSettings
            });
        }
        public async stt::Task GetRequestObjectAsync()
        {
            moq::Mock <NodeTemplates.NodeTemplatesClient> mockGrpcClient = new moq::Mock <NodeTemplates.NodeTemplatesClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForRegionOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetNodeTemplateRequest request = new GetNodeTemplateRequest
            {
                Region       = "regionedb20d96",
                Project      = "projectaa6ff846",
                NodeTemplate = "node_template118e38ae",
            };
            NodeTemplate expectedResponse = new NodeTemplate
            {
                Id   = 11672635353343658936UL,
                Kind = "kindf7aa39d9",
                Name = "name1c9368b0",
                CreationTimestamp = "creation_timestamp235e59a1",
                Disks             = { new LocalDisk(), },
                Region            = "regionedb20d96",
                Status            = NodeTemplate.Types.Status.Ready,
                ServerBinding     = new ServerBinding(),
                CpuOvercommitType = NodeTemplate.Types.CpuOvercommitType.UndefinedCpuOvercommitType,
                Accelerators      =
                {
                    new AcceleratorConfig(),
                },
                StatusMessage       = "status_message2c618f86",
                NodeTypeFlexibility = new NodeTemplateNodeTypeFlexibility(),
                NodeAffinityLabels  =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                Description = "description2cf9da67",
                SelfLink    = "self_link7e87f12d",
                NodeType    = "node_type98c685da",
            };

            mockGrpcClient.Setup(x => x.GetAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <NodeTemplate>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            NodeTemplatesClient client = new NodeTemplatesClientImpl(mockGrpcClient.Object, null);
            NodeTemplate        responseCallSettings = await client.GetAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            NodeTemplate responseCancellationToken = await client.GetAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Example #23
0
        /// <summary>Snippet for InsertAsync</summary>
        public async Task InsertAsync()
        {
            // Snippet: InsertAsync(string, string, NodeTemplate, CallSettings)
            // Additional: InsertAsync(string, string, NodeTemplate, CancellationToken)
            // Create client
            NodeTemplatesClient nodeTemplatesClient = await NodeTemplatesClient.CreateAsync();

            // Initialize request argument(s)
            string       project = "";
            string       region  = "";
            NodeTemplate nodeTemplateResource = new NodeTemplate();
            // Make the request
            Operation response = await nodeTemplatesClient.InsertAsync(project, region, nodeTemplateResource);

            // End snippet
        }
Example #24
0
        /// <summary>Snippet for GetAsync</summary>
        public async Task GetAsync()
        {
            // Snippet: GetAsync(string, string, string, CallSettings)
            // Additional: GetAsync(string, string, string, CancellationToken)
            // Create client
            NodeTemplatesClient nodeTemplatesClient = await NodeTemplatesClient.CreateAsync();

            // Initialize request argument(s)
            string project      = "";
            string region       = "";
            string nodeTemplate = "";
            // Make the request
            NodeTemplate response = await nodeTemplatesClient.GetAsync(project, region, nodeTemplate);

            // End snippet
        }
Example #25
0
 /// <summary>Snippet for Get</summary>
 public void GetRequestObject()
 {
     // Snippet: Get(GetNodeTemplateRequest, CallSettings)
     // Create client
     NodeTemplatesClient nodeTemplatesClient = NodeTemplatesClient.Create();
     // Initialize request argument(s)
     GetNodeTemplateRequest request = new GetNodeTemplateRequest
     {
         Region       = "",
         Project      = "",
         NodeTemplate = "",
     };
     // Make the request
     NodeTemplate response = nodeTemplatesClient.Get(request);
     // End snippet
 }
        public void GetRequestObject()
        {
            moq::Mock <NodeTemplates.NodeTemplatesClient> mockGrpcClient = new moq::Mock <NodeTemplates.NodeTemplatesClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForRegionOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetNodeTemplateRequest request = new GetNodeTemplateRequest
            {
                Region       = "regionedb20d96",
                Project      = "projectaa6ff846",
                NodeTemplate = "node_template118e38ae",
            };
            NodeTemplate expectedResponse = new NodeTemplate
            {
                Id   = 11672635353343658936UL,
                Kind = "kindf7aa39d9",
                Name = "name1c9368b0",
                CreationTimestamp = "creation_timestamp235e59a1",
                Disks             = { new LocalDisk(), },
                Region            = "regionedb20d96",
                Status            = "status5444cb9a",
                ServerBinding     = new ServerBinding(),
                CpuOvercommitType = "cpu_overcommit_type8fdfbfa8",
                Accelerators      =
                {
                    new AcceleratorConfig(),
                },
                StatusMessage       = "status_message2c618f86",
                NodeTypeFlexibility = new NodeTemplateNodeTypeFlexibility(),
                NodeAffinityLabels  =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                Description = "description2cf9da67",
                SelfLink    = "self_link7e87f12d",
                NodeType    = "node_type98c685da",
            };

            mockGrpcClient.Setup(x => x.Get(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            NodeTemplatesClient client   = new NodeTemplatesClientImpl(mockGrpcClient.Object, null);
            NodeTemplate        response = client.Get(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Example #27
0
        /// <summary>Snippet for GetAsync</summary>
        public async Task GetRequestObjectAsync()
        {
            // Snippet: GetAsync(GetNodeTemplateRequest, CallSettings)
            // Additional: GetAsync(GetNodeTemplateRequest, CancellationToken)
            // Create client
            NodeTemplatesClient nodeTemplatesClient = await NodeTemplatesClient.CreateAsync();

            // Initialize request argument(s)
            GetNodeTemplateRequest request = new GetNodeTemplateRequest
            {
                Region       = "",
                Project      = "",
                NodeTemplate = "",
            };
            // Make the request
            NodeTemplate response = await nodeTemplatesClient.GetAsync(request);

            // End snippet
        }
 public void Run(Options options)
 {
     _grammar = Utils.LoadGrammar(options.Grammar);
     Directory.CreateDirectory(options.Output);
     foreach (var instruction in _grammar.Instructions)
     {
         var spirvInstruction = instruction.Value;
         if (spirvInstruction.Kind != InstructionKind.Type)
         {
             var text = new NodeTemplate(spirvInstruction).TransformText();
             Utils.SaveText(Path.Combine(options.Output, spirvInstruction.Name.Substring(2) + ".cs"), text);
             Console.WriteLine($"                case Op.{spirvInstruction.Name}: return new {spirvInstruction.Name.Substring(2)}();");
         }
         else
         {
             var text = new TypeTemplate(spirvInstruction).TransformText();
             Utils.SaveText(Path.Combine(options.Output, spirvInstruction.Name.Substring(2) + ".cs"), text);
             //Console.WriteLine($"                case Op.{spirvInstruction.Name}: return new {spirvInstruction.Name.Substring(2)}();");
         }
     }
 }
Example #29
0
 /// <summary>
 /// 获取树的长度
 /// </summary>
 /// <returns></returns>
 public float GetTreeHeight()
 {
     return(m_RootTreeNode != null?m_RootTreeNode.GetItemCount() * NodeTemplate.GetComponent <RectTransform>().sizeDelta.y : 0);
 }
Example #30
0
 private void Awake()
 {
     NodeTemplate = transform.Find("NodeTemplate").gameObject;
     NodeTemplate.GetComponent <RectTransform>().anchoredPosition = new Vector2(10000, 10000);
 }
        protected void ButtonSelectNodeTemplate_Click(object sender, EventArgs e)
        {
            //int idx = 0;
            //CheckBox label = (CheckBox)accordion.FindControl("chk_1_0");
            //label.Text = "After Click I am changed!";

            List<NodeTemplate> nTemplate = new List<NodeTemplate>();
            NodeTemplate nodeTmp;

            //IHubContext _nodetemplate = GlobalHost.ConnectionManager.GetHubContext<ShapeShare>();
            //_nodetemplate.Clients.All.emptyNodeItems();
            for (int x = 0; x < accordion.Controls.Count / 2; x++)
            //foreach (var control in accordion.Controls)
            {
                //   if (control is CheckBox)
                //((CheckBox)control).Text = "After Click I am changed!"
                CheckBox chk = (CheckBox)accordion.FindControl("chk_1_" + x);
                TextBox txt = (TextBox)accordion.FindControl("txt_1_" + x);
                GridView grd = (GridView)accordion.FindControl("grd_1_" + x);
                //control.Text = "After Click I am changed!";
                //Control ctl = accordion.Controls[x];
                if (((CheckBox)chk).Checked)
                {
                    var chkValue = chk.Attributes["value"] != null ? chk.Attributes["value"].ToString() : "";

                    nodeTmp = new NodeTemplate(txt.Text, chkValue.ToString(), chk.Text, DataTableToJSON((DataTable)grd.DataSource));
                    //_nodetemplate.Clients.All.addNodeItems(chkValue.ToString(), txt.Text, chk.Text);
                    //_nodetemplate.Clients.All.setTemplateData("template-" + chkValue.ToString(), DataTableToJSON((DataTable)grd.DataSource));
                    nTemplate.Add(nodeTmp);
                    //coding here
                    //Literal1.Text += ((TextBox)txt).Text;
                }
                //if (ctl is TextBox)
                //{
                //   Literal1.Text = ((TextBox)ctl).ID;
                //}
                //else if (ctl is CheckBox)
                //{
                //    Response.Write(" Checked : "
                //        + ((CheckBox)ctl).Checked.ToString() + " | "
                //        + Request.Form["chk" + idx.ToString()] + " ");
                //    idx++;
                //}
            }
            //Session["nodeTemplate"] = nTemplate;
            //if (nTemplate.Count > 0)
            //{

            //}
            //
            //ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "tmp", "<script type='text/javascript'>alert('" + hfNodeValue.Value + "');</script>", false);
            if (hfNodeValue.Value != "")
            {
                //選擇的Tree NodeID
                string strNodeID = hfNodeValue.Value;
                string StrQuery;
                StrQuery = @"Delete From ConceptMap_SelectedTemplate Where ORCSGroupID = '" + strNodeID + "'";
                execquery(StrQuery);
                //迴圈執行檢查被勾選Template的內容
                foreach (NodeTemplate varTemplate in nTemplate)
                {
                    StrQuery = @"INSERT INTO ConceptMap_SelectedTemplate(ORCSGroupID, TemplateID, TemplateColor) VALUES ('"
                               + strNodeID + "', '" + varTemplate.templateID + "', '" + varTemplate.color + "');";
                    execquery(StrQuery);
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "tmp", "<script type='text/javascript'>alert('請先選擇群組!');</script>", false);
            }
                //    Application["nodeTemplate"] = nTemplate;
            //Literal1.Text = accordion.Controls.Count.ToString();

            //foreach (var control in form1.Controls)
            //{
            //    if (control is CheckBox)
            //    {
            //        if (((CheckBox)control).Checked)
            //        {
            //            //update
            //            Literal1.Text += ((CheckBox)control).Text;
            //        }
            //        else
            //        {
            //            //update another
            //        }
            //    }
            //}
        }
        protected void ButtonSaveNodeTemplate_Click(object sender, EventArgs e)
        {
            //int idx = 0;
            //CheckBox label = (CheckBox)accordion.FindControl("chk_1_0");
            //label.Text = "After Click I am changed!";

            List<NodeTemplate> nTemplate = new List<NodeTemplate>();
            NodeTemplate nodeTmp;

            IHubContext _nodetemplate = GlobalHost.ConnectionManager.GetHubContext<ShapeShare>();
            _nodetemplate.Clients.All.emptyNodeItems();
            for (int x = 0; x < accordion.Controls.Count / 2; x++)
            //foreach (var control in accordion.Controls)
            {
                //   if (control is CheckBox)
                //((CheckBox)control).Text = "After Click I am changed!"
                CheckBox chk = (CheckBox)accordion.FindControl("chk_1_" + x);
                TextBox txt = (TextBox)accordion.FindControl("txt_1_" + x);
                //control.Text = "After Click I am changed!";
                //Control ctl = accordion.Controls[x];
                if (((CheckBox)chk).Checked)
                {
                    var chkValue = chk.Attributes["value"] != null ? chk.Attributes["value"].ToString() : "";

                    nodeTmp = new NodeTemplate(txt.Text, chkValue.ToString());

                    _nodetemplate.Clients.All.addNodeItems(chkValue.ToString(), txt.Text, chk.Text);

                    nTemplate.Add(nodeTmp);
                    //coding here
                    //Literal1.Text += ((TextBox)txt).Text;
                }
                //if (ctl is TextBox)
                //{
                //   Literal1.Text = ((TextBox)ctl).ID;
                //}
                //else if (ctl is CheckBox)
                //{
                //    Response.Write(" Checked : "
                //        + ((CheckBox)ctl).Checked.ToString() + " | "
                //        + Request.Form["chk" + idx.ToString()] + " ");
                //    idx++;
                //}
            }
            //Session["nodeTemplate"] = nTemplate;
            Application["nodeTemplate"] = nTemplate;
            //Literal1.Text = accordion.Controls.Count.ToString();

            //foreach (var control in form1.Controls)
            //{
            //    if (control is CheckBox)
            //    {
            //        if (((CheckBox)control).Checked)
            //        {
            //            //update
            //            Literal1.Text += ((CheckBox)control).Text;
            //        }
            //        else
            //        {
            //            //update another
            //        }
            //    }
            //}
        }
        protected virtual void InitializeItem(SiteMapNodeItem item)
        {
            switch (item.ItemType)
            {
            case SiteMapNodeItemType.Root:
                if (RootNodeTemplate != null)
                {
                    item.ApplyStyle(NodeStyle);
                    item.ApplyStyle(RootNodeStyle);
                    RootNodeTemplate.InstantiateIn(item);
                }
                else if (NodeTemplate != null)
                {
                    item.ApplyStyle(NodeStyle);
                    item.ApplyStyle(RootNodeStyle);
                    NodeTemplate.InstantiateIn(item);
                }
                else
                {
                    WebControl c = CreateHyperLink(item);
                    c.ApplyStyle(NodeStyle);
                    c.ApplyStyle(RootNodeStyle);
                    item.Controls.Add(c);
                }
                break;

            case SiteMapNodeItemType.Current:
                if (CurrentNodeTemplate != null)
                {
                    item.ApplyStyle(NodeStyle);
                    item.ApplyStyle(CurrentNodeStyle);
                    CurrentNodeTemplate.InstantiateIn(item);
                }
                else if (NodeTemplate != null)
                {
                    item.ApplyStyle(NodeStyle);
                    item.ApplyStyle(CurrentNodeStyle);
                    NodeTemplate.InstantiateIn(item);
                }
                else if (RenderCurrentNodeAsLink)
                {
                    HyperLink c = CreateHyperLink(item);
                    c.ApplyStyle(NodeStyle);
                    c.ApplyStyle(CurrentNodeStyle);
                    item.Controls.Add(c);
                }
                else
                {
                    Literal c = CreateLiteral(item);
                    item.ApplyStyle(NodeStyle);
                    item.ApplyStyle(CurrentNodeStyle);
                    item.Controls.Add(c);
                }
                break;

            case SiteMapNodeItemType.Parent:
                if (NodeTemplate != null)
                {
                    item.ApplyStyle(NodeStyle);
                    NodeTemplate.InstantiateIn(item);
                }
                else
                {
                    WebControl c = CreateHyperLink(item);
                    c.ApplyStyle(NodeStyle);
                    item.Controls.Add(c);
                }
                break;

            case SiteMapNodeItemType.PathSeparator:
                if (PathSeparatorTemplate != null)
                {
                    item.ApplyStyle(PathSeparatorStyle);
                    PathSeparatorTemplate.InstantiateIn(item);
                }
                else
                {
                    Literal h = new Literal();
                    h.Text = HttpUtility.HtmlEncode(PathSeparator);
                    item.ApplyStyle(PathSeparatorStyle);
                    item.Controls.Add(h);
                }
                break;
            }
        }
 public NodeInstance CreateNodeInstance(NodeTemplate template)
 {
     return(null);
 }
Example #35
0
File: Node.cs Project: GotoK/H401
    //ノードにタイプ・テクスチャ・道ビット
    public void SetNodeType(NodeTemplate type, int Rot = -1)
    {
        NodeDebugLog += "SetNodeType. TempID : " + type.ID + "\n";
        // 使用したテンプレを記憶
        Temp = type;

        //テクスチャを設定
        SpriteRenderer.sprite = nodeControllerScript.GetSprite(Temp.SpriteIdx);
        NodeMask.SetSprite(nodeControllerScript.GetMaskSprite(Temp.MaskIdx));

        //ランダムに回転
        int RotI = RandomEx.RangeforInt(0, 5);
        RotCounter = (Rot == -1 ? RotI : Rot);

        // 色をリセット
        ChangeEmissionColor(0);
    }
Example #36
0
 FinNode(Node tgt)
 {
     ID = tgt.NodeID;
     Rot = tgt.RotCounter;
     Temp = tgt.Temp;
 }
        /// <summary>
        /// Creates the database with test data
        /// </summary>
        private void CreateTestDatabase()
        {
            var configurationContext = this.CreateContext();

            configurationContext.ResetValueGenerators();
            configurationContext.Database.EnsureDeleted();
            var template1 = new NodeTemplate
            {
                Code                = "template1",
                Configuration       = "1",
                PackageRequirements = this.GetPackageRequirements("p1; p2")
            };

            var template2 = new NodeTemplate
            {
                Code                = "template2",
                Configuration       = "1",
                PackageRequirements = this.GetPackageRequirements("p2; p3")
            };

            using (var context = this.CreateContext())
            {
                var configuration1 = new Configuration
                {
                    MinorVersion = 1,
                    Name         = "1",
                    State        = EnConfigurationState.Obsolete,
                    Settings     =
                        new ConfigurationSettings
                    {
                        NodeTemplates =
                            this.GetList(template1, template2),
                        Packages = this.CreatePackages(
                            "p1;0.0.1",
                            "p2;0.0.1",
                            "p3;0.0.1")
                    }
                };
                context.Configurations.Add(configuration1);
                context.SaveChanges();
            }

            using (var context = this.CreateContext())
            {
                var oldConfiguration    = context.Configurations.First();
                var activeConfiguration = new Configuration
                {
                    MinorVersion = 2,
                    Name         = "active",
                    State        = EnConfigurationState.Active,
                    Settings     =
                        new ConfigurationSettings
                    {
                        NodeTemplates =
                            this.GetList(
                                template1,
                                template2),
                        Packages = this.CreatePackages(
                            "p1;0.0.1",
                            "p2;0.0.1",
                            "p3;0.0.1")
                    }
                };

                context.Configurations.Add(activeConfiguration);
                activeConfiguration.CompatibleTemplatesBackward = new List <CompatibleTemplate>();
                activeConfiguration.CompatibleTemplatesBackward.Add(
                    new CompatibleTemplate {
                    CompatibleConfigurationId = oldConfiguration.Id, TemplateCode = template1.Code
                });
                activeConfiguration.CompatibleTemplatesBackward.Add(
                    new CompatibleTemplate {
                    CompatibleConfigurationId = oldConfiguration.Id, TemplateCode = template2.Code
                });
                context.SaveChanges();
            }
        }
Example #38
0
 public static void AllCalc(NodeTemplate[] TempList)
 {
     foreach(var it in TempList) {
         it.Calc();
     }
 }
Example #39
0
 // 指定した枝数を持つノードをランダムで選ぶ
 public static NodeTemplate GetTempFromBranchRandom(NodeTemplate[] TempList, int BranchNum)
 {
     return GetTempFromBranchIndex(TempList, BranchNum, Mathf.FloorToInt(Random.Range(0f, CountNodeType(TempList, BranchNum))));
 }