/// <summary> /// Create a file for the enumeration /// </summary> public string CreateFile(Feature f, string filePath) { string fileName = Util.Util.MakeFriendly(f.Name); // Render as if (f.Annotations != null && f.Annotations.Exists(o => o is RenderAsAnnotation)) { fileName = Util.Util.MakeFriendly((f.Annotations.Find(o => o is RenderAsAnnotation) as RenderAsAnnotation).RenderName); } fileName = Path.ChangeExtension(Path.Combine(Path.Combine(filePath, "vocabulary"), Util.Util.MakeFriendly(fileName)), ".java"); var enu = f as Enumeration; if (!String.IsNullOrEmpty(Datatypes.GetBuiltinVocabulary(enu.Name))) { throw new InvalidOperationException("Enumeration is builtin to core library. Will not render"); } // Is this code system even used? if (!m_markedForUse.Exists(o => o.GetType().Equals(f.GetType()) && o.Name == f.Name)) { if (enu.GetEnumeratedLiterals().Count > RimbaJavaRenderer.MaxLiterals) { throw new InvalidOperationException(String.Format("Enumeration '{2}' too large, enumeration has {0} literals, maximum allowed is {1}", enu.GetEnumeratedLiterals().Count, RimbaJavaRenderer.MaxLiterals, enu.Name)); } else { throw new InvalidOperationException("Enumeration is not used, or is an unbound concept domain!"); } } // First, if the feature is a value set we will always render it if (File.Exists(fileName) && !(f as Enumeration).OwnerRealm.EndsWith(RimbaJavaRenderer.prefRealm)) { throw new InvalidOperationException("Enumeration has already been rendered from the preferred realm. Will not render this feature"); } return(fileName); }
public async Task <IActionResult> Create([Bind("SensorId,Name,Metadata,DataType,CommunicationProtocolId,IpAddress,Port")] SensorCreateViewModel sensorVm) { if (ModelState.IsValid) { Datatypes newDatatype = new Datatypes { Schema = sensorVm.DataType }; _context.Add(newDatatype); await _context.SaveChangesAsync().ConfigureAwait(true); Sensors newSensor = new Sensors { SensorId = sensorVm.SensorId, Name = sensorVm.Name, Metadata = sensorVm.Metadata, CommunicationProtocolId = sensorVm.CommunicationProtocolId, IpAddress = sensorVm.IpAddress, Port = sensorVm.Port, DataTypeId = newDatatype.DataTypeId }; _context.Add(newSensor); await _context.SaveChangesAsync().ConfigureAwait(true); return(RedirectToAction(nameof(Index))); } ViewData["CommunicationProtocolId"] = new SelectList( _context.CommunicationProtocols, "CommunicationProtocolId", "ProtocolName", sensorVm.CommunicationProtocolId); return(View(sensorVm)); }
internal Room(Datatypes.Room room) { wrapper = room; }
internal Message(Datatypes.Message message) { wrapper = message; }
public Profile(Datatypes.Profile profile) { wrapper = profile; }
internal Contact(Datatypes.Contact contact) { wrapper = contact; }
public Column AddDatatypeCandidate(DataType datatype, float confidence) { Datatypes.Add(new DatatypeCandidate(datatype, confidence)); return(this); }
internal Group(Datatypes.Group group) { wrapper = group; }
public void UseAbility(Datatypes.Keys key, bool useControl = false) { _currentUser.Refresh(); Stopwatch timer = new Stopwatch(); timer.Reset(); timer.Start(); Debug.Print("starting ability.."); while ((_currentUser.UsingAbility) && _currentUser.IsCrafting && timer.Elapsed.Seconds < 3) { _currentUser.Refresh(); } while ((_currentUser.UsingAbility == false) && _currentUser.IsCrafting && timer.Elapsed.Seconds < 3) { if (useControl) Utilities.Keyboard.KeyBoardHelper.Ctrl(key); else Utilities.Keyboard.KeyBoardHelper.KeyPress(key); _currentUser.Refresh(); } Debug.Print("Waiting for start: " + timer.Elapsed.Milliseconds.ToString()); timer.Restart(); while ((_currentUser.UsingAbility == true) && _currentUser.IsCrafting && timer.Elapsed.Seconds < 3) { _currentUser.Refresh(); } Debug.Print("Ability Finished: " + timer.Elapsed.Milliseconds.ToString()); Thread.Sleep(300); _currentUser.Refresh(); _craftWindow.Refresh(); }
/// <summary> /// Adds IDatatypeEntity to the graph. /// </summary> /// <param name="datatypeEntity"></param> public void Add(IDatatypeEntity datatypeEntity) { Datatypes.Add(datatypeEntity); }
/// <summary> /// Determine if we'll render this or not /// </summary> public static string WillRender(Enumeration enu) { if (!String.IsNullOrEmpty(Datatypes.GetBuiltinVocabulary(enu.Name))) { return(enu.Name); } // This will check the literal count against bound vocab sets // if the enu is currently a concept domain if (enu is ConceptDomain && (enu as ConceptDomain).ContextBinding != null && (enu as ConceptDomain).ContextBinding.Count == 1) { enu = (enu as ConceptDomain).ContextBinding[0]; } else if (enu is ConceptDomain && (enu as ConceptDomain).ContextBinding != null && (enu as ConceptDomain).ContextBinding.Count > 1) // HACK: If there is more than one context binding create a new value set, clear the binding and then re-bind { // Create the VS ValueSet vsNew = new ValueSet() { Name = String.Format("{0}AutoGen", enu.Name), BusinessName = enu.BusinessName, Documentation = new Documentation() { Description = new List <string>(new string[] { String.Format("Value set has automatically been generated by GPMR to allow binding to ConceptDomain '{0}'", enu.Name) }), Rationale = new List <string>() }, Id = enu.Id, Literals = new List <Enumeration.EnumerationValue>(), MemberOf = enu.MemberOf, OwnerRealm = enu.OwnerRealm }; // Add literals and documentation vsNew.Documentation.Rationale.Add(String.Format("GPMR can normally only redirect context bindings from a concept domain if only 1 is present, however this concept domain has '{0}' present. This value set is a union of content from:", (enu as ConceptDomain).ContextBinding.Count)); foreach (Enumeration vs in (enu as ConceptDomain).ContextBinding) { // If any of the context binding codes are not to be rendered do not render any of them if (WillRender(vs) == String.Empty) { return(String.Empty); } // Output rationale vsNew.Documentation.Rationale.Add(String.Format("<p>- {0} ({1})</p>", vs.Name, vs.EnumerationType)); // Add literals vsNew.Literals.AddRange(vs.GetEnumeratedLiterals()); } // Now fire parse to add to the domain vsNew.FireParsed(); // Replace the context bindings (enu as ConceptDomain).ContextBinding.Clear(); (enu as ConceptDomain).ContextBinding.Add(vsNew); // redirect enu = vsNew; } else if (enu is ConceptDomain) { return(String.Empty); } // Partial enumerations or suppressed enumerations are not to be included if (enu.IsPartial && !RimbaJavaRenderer.RenderPartials) { return(String.Empty); } // Too big if (enu.GetEnumeratedLiterals().Count > RimbaJavaRenderer.MaxLiterals) { return(String.Empty); } // Already has a preferred name? if (enu.Annotations != null && enu.Annotations.Exists(o => o is RenderAsAnnotation)) { return((enu.Annotations.Find(o => o is RenderAsAnnotation) as RenderAsAnnotation).RenderName); } // Already being used if (m_markedForUse.Exists(o => o.Name == enu.Name && o.GetType() == enu.GetType())) { return(enu.Name); } string name = enu.Name; if (enu.GetEnumeratedLiterals().Count > 0 && enu.GetEnumeratedLiterals().FindAll(l => !l.Annotations.Exists(o => o is SuppressBrowseAnnotation)).Count > 0 && (RimbaJavaRenderer.GenerateVocab || (!RimbaJavaRenderer.GenerateVocab && enu is ValueSet))) { // Name collision? Resolve if (enu.MemberOf.Find(o => o.Name == enu.Name && o.GetType() != enu.GetType() && !(o is ConceptDomain)) != null) { if (m_markedForUse.Exists(o => o.Name == enu.Name && o.GetType() != enu.GetType())) { name = String.Format("{0}1", enu.Name); if (enu.Annotations == null) { enu.Annotations = new List <Annotation>(); } enu.Annotations.Add(new RenderAsAnnotation() { RenderName = name }); } } return(name); // don't process } return(String.Empty); }