private static SupportType GetSupportType(Type type) { if (SupportedTypes.ContainsKey(type)) { return(SupportType.Basic); } if (type.GetTypeInfo().IsEnum) { return(SupportType.Enum); } if (IsSupportedCollection(type)) { return(SupportType.Collection); } if (IsNullableType(type)) { return(SupportType.Nullable); } if (type.GetTypeInfo().IsClass) { return(SupportType.UserDefined); } return(SupportType.NotSupported); }
public void AddNewField(string name, SupportedTypes type, List <IValidator> validators = null) { validators = validators ?? new List <IValidator>(); _isTableDirty = true; _client.AddField(_dbName, _tableName, name, type, validators); }
private static void CheckFieldType(Type type) { if (!SupportedTypes.Contains(type) && !IsTypeRowList(type)) { throw new InvalidCastException($"Unsupported type: '{type.FullName}'"); } }
public Parameter(ParameterInfo parameter) { ParameterType = parameter.ParameterType; IsOptional = parameter.IsOptional; Name = parameter.Name; IsValidParameterType = SupportedTypes.Contains(ParameterType); }
public void ExtractVariableWorks(object value, object defaultValue, SupportedTypes supportedType, Units unit, object max = null, object min = null) { var variable = new Variable { Name = "Test", Value = value?.ToString(), Default = defaultValue?.ToString(), Max = max?.ToString(), Min = min?.ToString(), Type = supportedType.GetStringValue(), Units = unit.GetStringValue() }; var errorCache = new ErrorCacheMock(); var info = VariableInfo.Extract(variable, "myPackage", errorCache); errorCache.ShouldHaveNoErrors(); info.Ref.VariableName.Should().Be("Test"); info.Ref.PackageId.Should().Be("myPackage"); info.HasErrors.Should().BeFalse(); info.Value.ShouldBeEquivalentTo(value); info.Default.ShouldBeEquivalentTo(defaultValue); info.Min.ShouldBeEquivalentTo(min); info.Max.ShouldBeEquivalentTo(max); info.SupportedType.Should().Be(supportedType); info.Units.Should().Be(unit); }
internal static object InternalGetInstance(SupportedTypes type, int index, ReferenceDepthContext context) { if (!context.IncreamentCounter()) { return null; } if (type == SupportedTypes.Person) { return new Person(index, context); } else if (type == SupportedTypes.Employee) { return new Employee(index, context); } else if (type == SupportedTypes.Address) { return new Address(index, context); } else if (type == SupportedTypes.WorkItem) { return new WorkItem() { EmployeeID = index, IsCompleted = false, NumberOfHours = 100, ID = 25 }; } context.DecrementCounter(); throw new ArgumentException(String.Format("Cannot initialize an instance for {0} type.", type.ToString())); }
internal static object InternalGetInstance(SupportedTypes type, int index, ReferenceDepthContext context) { if (!context.IncreamentCounter()) { return(null); } if (type == SupportedTypes.Person) { return(new Person(index, context)); } else if (type == SupportedTypes.Employee) { return(new Employee(index, context)); } else if (type == SupportedTypes.Address) { return(new Address(index, context)); } else if (type == SupportedTypes.WorkItem) { return(new WorkItem() { EmployeeID = index, IsCompleted = false, NumberOfHours = 100, ID = 25 }); } context.DecrementCounter(); throw new ArgumentException(String.Format("Cannot initialize an instance for {0} type.", type.ToString())); }
protected override void PerformIndexAll(string type) { if (!SupportedTypes.Contains(type)) { return; } var xPath = "//*[(number(@id) > 0 and (@isDoc or @nodeTypeAlias)){0}]"; //we'll add more filters to this below if needed var sb = new StringBuilder(); //create the xpath statement to match node type aliases if specified if (IndexerData.IncludeNodeTypes.Any()) { sb.Append("("); foreach (var field in IndexerData.IncludeNodeTypes) { //this can be used across both schemas const string nodeTypeAlias = "(@nodeTypeAlias='{0}' or (count(@nodeTypeAlias)=0 and name()='{0}'))"; sb.Append(string.Format(nodeTypeAlias, field)); sb.Append(" or "); } sb.Remove(sb.Length - 4, 4); //remove last " or " sb.Append(")"); } //create the xpath statement to match all children of the current node. if (IndexerData.ParentNodeId.HasValue && IndexerData.ParentNodeId.Value > 0) { if (sb.Length > 0) { sb.Append(" and "); } sb.Append("("); sb.Append("contains(@path, '," + IndexerData.ParentNodeId.Value + ",')"); //if the path contains comma - id - comma then the nodes must be a child sb.Append(")"); } //create the full xpath statement to match the appropriate nodes. If there is a filter //then apply it, otherwise just select all nodes. var filter = sb.ToString(); xPath = string.Format(xPath, filter.Length > 0 ? " and " + filter : ""); //raise the event and set the xpath statement to the value returned var args = new IndexingNodesEventArgs(IndexerData, xPath, type); OnNodesIndexing(args); if (args.Cancel) { return; } xPath = args.XPath; DataService.LogService.AddVerboseLog(-1, string.Format("({0}) PerformIndexAll with XPATH: {1}", this.Name, xPath)); AddNodesToQueue(xPath, type); }
/// <summary> /// Instantiates a EntrySelectorDialog WPF dialog /// </summary> /// <param name="owner">WPF owning window. Used for centering. Set to null if the calling window is not WPF based</param> /// <param name="pcc">Package file to load entries from</param> /// <param name="supportedInputTypes">Supported selection types</param> /// <param name="entryPredicate">A predicate to narrow the displayed entries</param> private EntrySelector(Window owner, IMEPackage pcc, SupportedTypes supportedInputTypes, string directionsText = null, Predicate <IEntry> entryPredicate = null) { this.Pcc = pcc; this.SupportedInputTypes = supportedInputTypes; this.DirectionsTextOverride = directionsText; var allEntriesBuilding = new List <object>(); if (SupportedInputTypes.HasFlag(SupportedTypes.Imports)) { for (int i = Pcc.Imports.Count - 1; i >= 0; i--) { if (entryPredicate?.Invoke(Pcc.Imports[i]) ?? true) { allEntriesBuilding.Add(Pcc.Imports[i]); } } } if (SupportedInputTypes.HasFlag(SupportedTypes.Exports)) { foreach (ExportEntry exp in Pcc.Exports) { if (entryPredicate?.Invoke(exp) ?? true) { allEntriesBuilding.Add(exp); } } } AllEntriesList.ReplaceAll(allEntriesBuilding); Owner = owner; DataContext = this; LoadCommands(); InitializeComponent(); EntrySelector_ComboBox.Focus(); }
public virtual int TypeCompliance(Type targetType) { // Determine compliance as inheritance distance var compliance = PerfectMatch; var current = targetType; do { if (SupportedTypes.Contains(current)) { return(compliance); } current = current.BaseType; compliance++; } while (DerivedTypes & current != null); // Use full distance if it is an interface match if (targetType.GetInterfaces().Any(SupportedTypes.Contains)) { return(compliance); } // Otherwise it is no match return(BadCompliance); }
} // constructor public virtual void Init() { PropertyInfo[] propertyInfos = GetType().GetProperties(); foreach (PropertyInfo pi in propertyInfos) { SupportedTypes ignored; bool bInclude = pi.GetGetMethod().IsVirtual&& pi.GetGetMethod().IsPublic&& (pi.GetSetMethod(true) != null) && SupportedTypes.TryParse(pi.PropertyType.Name, out ignored); if (bInclude) { configPropertyInfos.Add(pi.Name, pi); Debug("Configuration property to read from DB: {0}", pi.Name); } // if } // for each property Info("Reading configurations"); try { AConnection oDB = DbConnectionGenerator.Get(this); oDB.ForEachRow((row, bRowsetStart) => { AddSingleConfiguration(row[KeyFieldName].ToString(), row[ValueFieldName].ToString()); return(ActionResult.Continue); }, SpName); } catch (Exception e) { throw new ConfigurationBaseException("Error reading configurations.", e); } // try } // Init
public static T GetEntry <T>(Window owner, IMEPackage pcc, string directionsText = null, Predicate <T> predicate = null) where T : class, IEntry { SupportedTypes supportedInputTypes = SupportedTypes.ExportsAndImports; if (typeof(T) == typeof(ExportEntry)) { supportedInputTypes = SupportedTypes.Exports; } else if (typeof(T) == typeof(ImportEntry)) { supportedInputTypes = SupportedTypes.Imports; } Predicate <IEntry> entryPredicate = null; if (predicate != null) { entryPredicate = entry => predicate((T)entry); } using var dlg = new EntrySelector(owner, pcc, supportedInputTypes, directionsText, entryPredicate); if (dlg.ShowDialog() == true) { return(dlg.ChosenEntry as T); } return(null); }
private static void ValidateSupportedType <T>() { if (!SupportedTypes.Contains(typeof(T))) { throw new NotSupportedException("Parsing to " + typeof(T).ToString() + "is not supported yet"); } }
/// <summary> /// Add an Item to the columnlist /// </summary> /// <param name="attribute"></param> /// <param name="Operation"></param> private void AddSupportedMappingItem(AttributeMetadata attribute, IDTSInput100 input, int Operation) { MappingItem mi; if (SupportedTypes.isValidAttribute(attribute, Operation)) { mi = new MappingItem(); mi.InternalColumnName = attribute.LogicalName; mi.InternalColumnTypeName = attribute.AttributeType.ToString(); mi.InternalColumnType = attribute.AttributeType; mi.isPrimary = attribute.IsPrimaryId.HasValue ? (bool)attribute.IsPrimaryId : false; mi.isRequired = attribute.IsRequiredForForm.HasValue ? (bool)attribute.IsRequiredForForm : false; //Maps by name the Input collection with Dynamics CRM collection foreach (IDTSInputColumn100 inputcol in input.InputColumnCollection) { if (inputcol.Name == attribute.LogicalName) { mi.ExternalColumnName = inputcol.Name; mi.ExternalColumnType = inputcol.DataType; mi.ExternalColumnTypeName = inputcol.DataType.ToString(); } } columnList.Add(mi); } }
/// <summary> /// Serialize a list of supported objects. /// </summary> /// <param name="buffer">The buffer where to serialize the data.</param> /// <param name="start">The start index in the buffer where to serialize the data.</param> /// <param name="list">The list to serialize.</param> /// <returns>The number of serialized bytes.</returns> public uint ToBytes(ref Buffer buffer, uint start, IList list) { uint written; CheckSerializationParameters(buffer, start); // If list is not defined, just write the length = 0 to the stream if (list == null || list.Count <= 0) { written = ToBytes(ref buffer, start, 0u); if (written != uintSize) { throw new FormatException(string.Format("The number of written bytes does not match the expected count. Wrote {0} bytes instead of {1}.", written, uintSize)); } } else { uint type_size; uint list_size = (uint)list.Count; Type[] params_types = GetGenericParametersTypes(list.GetType()); Type element_type = (params_types != null && params_types.Length >= 1 ? params_types[0] : null); // Get the correct type overload to use SupportedTypes type = GetSupportedType(element_type); if (type == SupportedTypes.NONE) { throw new ArgumentException(string.Format("Unsupported list type '{0}'. Either list type or values type are unsupported.", list.GetType()), "list"); } // Write the length of the list in the buffer written = ToBytes(ref buffer, start, list_size); if (written != uintSize) { throw new FormatException(string.Format("The number of written bytes does not match the expected count. Wrote {0} bytes instead of {1}.", written, uintSize)); } // Write the type of the list's elements written += ToBytes(ref buffer, start + written, element_type); if (sizes.TryGetValue(type, out type_size)) // If the type size is not defined, we will need to use on-the-fly buffer resizing, which is less effective. { // Check wether our buffer is large enough to get all data ResizeBuffer(ref buffer, start + written + list_size * type_size); } // Write all data in the buffer for (uint i = 0; i < list_size; ++i) { written += ToBytesWrapper(ref buffer, start + written, list[(int)i], type); } } return(written); }
private static Type ConvertValueType(ValueType itemType) { if (SupportedTypes.TryGetValue(itemType, out var result)) { return(result); } throw new ArgumentOutOfRangeException(nameof(itemType), itemType, "Unsupported type"); }
private static TagValueType?Convert(HackTagValueType?hackValue) { if (!hackValue.HasValue || !SupportedTypes.TryGetValue(hackValue.Value, out var tagValue)) { return(null); } return(tagValue); }
public FieldPrototype(string name, bool isRequired, SupportedTypes type, int?datasetId, IEnumerable <ConstraintPrototype> constraints = null) { Name = name; IsRequired = isRequired; Type = type; DatasetId = datasetId; Constraints = constraints ?? new List <ConstraintPrototype>(); }
public static object GetInstance(SupportedTypes type, int index = 0, int maxReferenceDepth = 7) { if (index > DataSource.MaxIndex) { throw new ArgumentException(String.Format("The max supported index is : {0}", DataSource.MaxIndex)); } return(InternalGetInstance(type, index, new ReferenceDepthContext(maxReferenceDepth))); }
public TokenParser(IEnumerable <TokenType> supportedTypes) { SupportedTypes = supportedTypes.ToArray(); LongestSymbol = SupportedTypes.Select(p => Math.Max( p.EscapeOpen.Length + p.OpenSymbol.Length, p.EscapeClose.Length + p.CloseSymbol.Length)) .Max(); }
public static object GetInstance(SupportedTypes type, int index = 0, int maxReferenceDepth = 7) { if (index > DataSource.MaxIndex) { throw new ArgumentException(String.Format("The max supported index is : {0}", DataSource.MaxIndex)); } return InternalGetInstance(type, index, new ReferenceDepthContext(maxReferenceDepth)); }
/// <summary> /// Deserialize a dictionary of supported objects. /// </summary> /// <param name="buffer">The buffer containing the serialized data.</param> /// <param name="start">The start index in the buffer of the serialized object.</param> /// <param name="dict">The deserialized dictionary.</param> /// <returns>The number of deserialized bytes.</returns> public uint FromBytes(Buffer buffer, uint start, out IDictionary dict) { uint nb_elements; Type key_element_type, value_element_type; CheckDeserializationParameters(buffer, start); uint read = FromBytes(buffer, start, out nb_elements); if (read != uintSize) { throw new FormatException(string.Format("The number of read bytes does not match the expected count. Read {0} bytes instead of {1}.", read, uintSize)); } if (nb_elements > 0) { // Read the type of the dictionary's keys read += FromBytes(buffer, start + read, out key_element_type); if (key_element_type == null) { throw new FormatException("The type of keys in the dictionary is not defined."); } // Read the type of the dictionary's values read += FromBytes(buffer, start + read, out value_element_type); if (value_element_type == null) { throw new FormatException("The type of values in the dictionary is not defined."); } dict = (IDictionary)Activator.CreateInstance(typeof(Dictionary <,>).MakeGenericType(key_element_type, value_element_type), (int)nb_elements); // Get the correct type overloads to use SupportedTypes type_key = GetSupportedType(key_element_type); SupportedTypes type_value = GetSupportedType(value_element_type); object key; object value; for (uint i = 0; i < nb_elements; ++i) { read += FromBytesWrapper(buffer, start + read, out key, type_key); read += FromBytesWrapper(buffer, start + read, out value, type_value); dict.Add(key, value); } } else { dict = null; } return(read); }
/// <summary> /// Helper method to get the correct file extension for the supported type /// (ensuring the correct application opens the poster once downloaded to the Client's browser). /// </summary> /// <param name="type">Output format to get the extension of</param> /// <returns></returns> public static string ToFileExtension(SupportedTypes type) { switch (type) { case SupportedTypes.Bitmap: return "bmp"; case SupportedTypes.Gif: return "gif"; case SupportedTypes.Jpeg: return "jpg"; case SupportedTypes.Png: return "png"; default: throw new ArgumentException(string.Format("{0} is not a supported output format.", type.ToString()) ); } }
/// <summary> /// Helper method to convert the supported output format to the enum .NET expects /// </summary> /// <param name="type">Output format to be converted</param> public static ImageFormat ToImageFormat(SupportedTypes type) { switch (type) { case SupportedTypes.Bitmap: return ImageFormat.Bmp; case SupportedTypes.Gif: return ImageFormat.Gif; case SupportedTypes.Jpeg: return ImageFormat.Jpeg; case SupportedTypes.Png: return ImageFormat.Png; default: throw new ArgumentException(string.Format("{0} is not a supported output format.", type.ToString()) ); } }
private static ColumnType MapFromRawType(Type rawType) { if (IsTypeRowList(rawType)) { return(ColumnType.Data); } var index = SupportedTypes.IndexOf(rawType); return((ColumnType)index); }
public UnionSelectQuery( Func <NpgsqlConnection> getConnection) { _getConnection = getConnection ?? throw new ArgumentNullException(nameof(getConnection)); if (!SupportedTypes.IsSupported <TResult>()) { throw new ArgumentException($"The type '{typeof(TResult).Name}' cannot be used as the result of a Union query.", nameof(TResult)); } }
public static object GetDefaultValue(this SupportedTypes value) { var type = Type.GetType(value.GetAssemblyDescription(Constants.TypeDescription)); if (type.IsValueType) { return(Activator.CreateInstance(type)); } return(null); }
public virtual Content <T> Use(Content <T> source) { var conv = SupportedTypes.Where(t => t.Item1 == source.ContentType); if (conv.Count() > 1 || conv.Count() == 0) { throw new ArgumentException("No unique conversion found"); } return(Use(source, conv.First().Item2)); }
public static object GetTypeInstance(SupportedTypes type, string value) { try { return(_parseStrigns[type](value)); } catch (Exception ex) { throw new InvalidCastException("Unsupported type", ex); } }
} // SupportedTypes /// <summary> /// Converts a string into a supported image type. /// </summary> /// <param name="type">String to convert</param> /// <returns></returns> public static SupportedTypes FromString(string type) { SupportedTypes retVal = SupportedTypes.Jpeg; if (Enum.IsDefined(typeof(SupportedTypes), type)) { retVal = (SupportedTypes)Enum.Parse(typeof(SupportedTypes), type, true); } return(retVal); } // FromString
/// <summary> /// Get the size in bytes of a supported type. /// </summary> /// <param name="type">The type from which to get the size.</param> /// <returns>The number of bytes of the type once serialized, or 0 if unknown.</returns> public static uint Size(SupportedTypes type) { uint size; if (!sizes.TryGetValue(type, out size)) { size = 0; } return(size); }
/// <summary> /// Type compliance is perfect for types without properties, other bad /// </summary> public override int TypeCompliance(Type targetType) { // Determine base properties from supported types var baseProperties = SupportedTypes .SelectMany(t => t.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) .Select(prop => prop.Name).Distinct().ToList(); // Get properties from target type and make sure all are defined by the base class var targetProps = targetType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) .Select(prop => prop.Name).Distinct(); return(targetProps.All(baseProperties.Contains) ? PerfectMatch : BadCompliance); }
private static IClient<Node> GetClient(string url, SupportedTypes type) { switch (type) { case SupportedTypes.Ua: return new UaClient(new Uri(url)); case SupportedTypes.Da: return new DaClient(new Uri(url)); default: throw new ArgumentOutOfRangeException("type"); } }
public static bool IsValid(Type type) { if (type.IsPrimitive) { return(true); } if (type.IsEnum) { return(true); } return(SupportedTypes.Contains(type)); }
public override void ReIndexNode(XElement node, string type) { if (CanInitialize()) { if (!SupportedTypes.Contains(type)) { return; } base.ReIndexNode(node, type); } }
public static CVariable parseAsVariable(string VariableName, string Location, string Path, string Value, SupportedTypes expectedType) { // Here we call Regex.Match. Match match = Regex.Match(VariableName, @"^(.*)\[(\d)*\]$"); // Here we check the Match instance. if (match.Success) { // Finally, we get the Group value and display it. VariableName = match.Groups[1].Value; uint Index; if (match.Groups[2].Value == "") { // When we are referring to complete array, then we use 0 Index = 0; } else { Index = Convert.ToUInt32(match.Groups[2].Value); } CVariable Var = parseAsVariable(VariableName, Location, Path, Value, expectedType); CVariableArray array = new CVariableArray(Var, Index); return array; } switch (expectedType) { case SupportedTypes.BOOLEAN: return new CVariableBool(VariableName, Location, Path, Value); case SupportedTypes.INTEGER: return new CVariableInt(VariableName, Location, Path, Value); case SupportedTypes.REAL: return new CVariableDouble(VariableName, Location, Path, Value); case SupportedTypes.UNSIGNED_INTEGER: return new CVariableUInt(VariableName, Location, Path, Value); default: return null; } }
/// <summary> /// Updates the basic types text to reflect the provided type. /// </summary> /// <param name="type">The type to update the basic types text to.</param> private void UpdateBasicTypesText(SupportedTypes? type) { BasicTypesProgramTextBlock.Inlines.Clear(); BasicTypesDetailsTextBlock.Inlines.Clear(); switch (type) { case SupportedTypes.String: BasicTypesDetailsTextBlock.Inlines.Add(new Run("This is a ")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("string") { FontWeight = FontWeights.Bold }); BasicTypesDetailsTextBlock.Inlines.Add(new Run(" (")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("System.String") { FontFamily = programTextFamily }); BasicTypesDetailsTextBlock.Inlines.Add(new Run("). ")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("Strings are ordered groupings of unicode characters, can be of any length, and are specified by surrounding a group of characters in double quotes (")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("\"") { FontFamily = programTextFamily }); BasicTypesDetailsTextBlock.Inlines.Add(new Run(").")); BasicTypesProgramTextBlock.Inlines.Add(new Run("string") { Foreground = new SolidColorBrush(Colors.Blue) }); BasicTypesProgramTextBlock.Inlines.Add(new Run(" stringVariable = ")); BasicTypesProgramTextBlock.Inlines.Add(new Run(this.BasicTypesValue.Trim()) { Foreground = new SolidColorBrush(Colors.DarkRed) }); BasicTypesProgramTextBlock.Inlines.Add(new Run(";")); break; case SupportedTypes.Boolean: BasicTypesDetailsTextBlock.Inlines.Add(new Run("This is a ")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("bool") { FontWeight = FontWeights.Bold }); BasicTypesDetailsTextBlock.Inlines.Add(new Run(" (")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("System.Boolean") { FontFamily = programTextFamily }); BasicTypesDetailsTextBlock.Inlines.Add(new Run("). ")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("Booleans represent boolean logical quantities - values that are either ")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("true") { FontStyle = FontStyles.Italic }); BasicTypesDetailsTextBlock.Inlines.Add(new Run(" or ")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("false") { FontStyle = FontStyles.Italic }); BasicTypesDetailsTextBlock.Inlines.Add(new Run(".")); BasicTypesProgramTextBlock.Inlines.Add(new Run("bool") { Foreground = new SolidColorBrush(Colors.Blue) }); BasicTypesProgramTextBlock.Inlines.Add(new Run(" booleanVariable = ")); BasicTypesProgramTextBlock.Inlines.Add(new Run(this.BasicTypesValue.Trim()) { Foreground = new SolidColorBrush(Colors.Blue) }); BasicTypesProgramTextBlock.Inlines.Add(new Run(";")); break; case SupportedTypes.Character: BasicTypesDetailsTextBlock.Inlines.Add(new Run("This is a ")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("char") { FontWeight = FontWeights.Bold }); BasicTypesDetailsTextBlock.Inlines.Add(new Run(" (")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("System.Char") { FontFamily = programTextFamily }); BasicTypesDetailsTextBlock.Inlines.Add(new Run("). ")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("Characters are unsigned 16-bit numbers (values between 0 and 65535), with legal values corresponding to the two-byte Unicode character set.")); BasicTypesProgramTextBlock.Inlines.Add(new Run("char") { Foreground = new SolidColorBrush(Colors.Blue) }); BasicTypesProgramTextBlock.Inlines.Add(new Run(" characterVariable = ")); BasicTypesProgramTextBlock.Inlines.Add(new Run(this.BasicTypesValue.Trim()) { Foreground = new SolidColorBrush(Colors.DarkRed) }); BasicTypesProgramTextBlock.Inlines.Add(new Run(";")); break; case SupportedTypes.Integer: BasicTypesDetailsTextBlock.Inlines.Add(new Run("This is an ")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("int") { FontWeight = FontWeights.Bold }); BasicTypesDetailsTextBlock.Inlines.Add(new Run(" (")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("System.Int32") { FontFamily = programTextFamily }); BasicTypesDetailsTextBlock.Inlines.Add(new Run("). ")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("Integers are signed 32-bit integral numbers, and represent values between -2,147,483,648 and 2,147,483,647.")); BasicTypesProgramTextBlock.Inlines.Add(new Run("int") { Foreground = new SolidColorBrush(Colors.Blue) }); BasicTypesProgramTextBlock.Inlines.Add(new Run(" integerVariable = " + this.BasicTypesValue.Trim() + ";")); break; case SupportedTypes.UnsignedInteger: BasicTypesDetailsTextBlock.Inlines.Add(new Run("This is a ")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("uint") { FontWeight = FontWeights.Bold }); BasicTypesDetailsTextBlock.Inlines.Add(new Run(" (")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("System.UInt32") { FontFamily = programTextFamily }); BasicTypesDetailsTextBlock.Inlines.Add(new Run("). ")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("Unsigned integers are unsigned 32-bit integral numbers, and represent values between 0 and 4,294,967,295.")); BasicTypesProgramTextBlock.Inlines.Add(new Run("uint") { Foreground = new SolidColorBrush(Colors.Blue) }); BasicTypesProgramTextBlock.Inlines.Add(new Run(" unsignedIntegerVariable = " + this.BasicTypesValue.Trim() + ";")); break; case SupportedTypes.Long: BasicTypesDetailsTextBlock.Inlines.Add(new Run("This is a ")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("long") { FontWeight = FontWeights.Bold }); BasicTypesDetailsTextBlock.Inlines.Add(new Run(" (")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("System.Int64") { FontFamily = programTextFamily }); BasicTypesDetailsTextBlock.Inlines.Add(new Run("). ")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("Long integers are signed 64-bit integral numbers, and represent values between -9,223,372,036,854,775,808 and 9,223,372,036,854,775,807.")); BasicTypesProgramTextBlock.Inlines.Add(new Run("long") { Foreground = new SolidColorBrush(Colors.Blue) }); BasicTypesProgramTextBlock.Inlines.Add(new Run(" longIntegerVariable = " + this.BasicTypesValue.Trim() + ";")); break; case SupportedTypes.UnsignedLong: BasicTypesDetailsTextBlock.Inlines.Add(new Run("This is a ")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("ulong") { FontWeight = FontWeights.Bold }); BasicTypesDetailsTextBlock.Inlines.Add(new Run(" (")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("System.UInt64") { FontFamily = programTextFamily }); BasicTypesDetailsTextBlock.Inlines.Add(new Run("). ")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("Unsigned long integers are unsigned 64-bit integral numbers, and represent values between 0 and 18,446,744,073,709,551,615.")); BasicTypesProgramTextBlock.Inlines.Add(new Run("ulong") { Foreground = new SolidColorBrush(Colors.Blue) }); BasicTypesProgramTextBlock.Inlines.Add(new Run(" unsignedLongIntegerVariable = " + this.BasicTypesValue.Trim() + ";")); break; case SupportedTypes.SingleFloat: BasicTypesDetailsTextBlock.Inlines.Add(new Run("This is a ")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("float") { FontWeight = FontWeights.Bold }); BasicTypesDetailsTextBlock.Inlines.Add(new Run(" (")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("System.Single") { FontFamily = programTextFamily }); BasicTypesDetailsTextBlock.Inlines.Add(new Run("). ")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("Single-precision floating point numbers are 32 bits in length, and can represent values ranging from approximately 1.5e-45 to 3.4e38 with a precision of 7 digits, as well as the special quantities Not-a-Number (NaN), positive and negative infinity, and positive and negative zero.")); BasicTypesProgramTextBlock.Inlines.Add(new Run("float") { Foreground = new SolidColorBrush(Colors.Blue) }); BasicTypesProgramTextBlock.Inlines.Add(new Run(" singlePrecisionFloatingPointVariable = " + this.BasicTypesValue.Trim() + ";")); break; case SupportedTypes.DoubleFloat: BasicTypesDetailsTextBlock.Inlines.Add(new Run("This is a ")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("double") { FontWeight = FontWeights.Bold }); BasicTypesDetailsTextBlock.Inlines.Add(new Run(" (")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("System.Double") { FontFamily = programTextFamily }); BasicTypesDetailsTextBlock.Inlines.Add(new Run("). ")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("Double-precision floating point numbers are 64 bits in length, and can represent values ranging from approximately 5.0e-324 to 1.7e308 with a precision of 15-16 digits, as well as the special quantities Not-a-Number (NaN), positive and negative infinity, and positive and negative zero.")); BasicTypesProgramTextBlock.Inlines.Add(new Run("double") { Foreground = new SolidColorBrush(Colors.Blue) }); BasicTypesProgramTextBlock.Inlines.Add(new Run(" doublePrecisionFloatingPointVariable = " + this.BasicTypesValue.Trim() + ";")); break; case SupportedTypes.DecimalFloat: BasicTypesDetailsTextBlock.Inlines.Add(new Run("This is a ")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("decimal") { FontWeight = FontWeights.Bold }); BasicTypesDetailsTextBlock.Inlines.Add(new Run(" (")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("System.Decimal") { FontFamily = programTextFamily }); BasicTypesDetailsTextBlock.Inlines.Add(new Run("). ")); BasicTypesDetailsTextBlock.Inlines.Add(new Run("Decimal numbers are 128 bits in length, are used for financial calculations, and can represent values ranging from approximately 1.0e-28 to 7.9e28 with a precision of 28-29 digits. The decimal type does not support signed zeros, infinities, or NaN, and uses banker's rounding to minimize round-off errors.")); BasicTypesProgramTextBlock.Inlines.Add(new Run("decimal") { Foreground = new SolidColorBrush(Colors.Blue) }); BasicTypesProgramTextBlock.Inlines.Add(new Run(" decimalFloatingPointVariable = " + this.BasicTypesValue.Trim() + ";")); break; default: if (this.BasicTypesValue.Trim() != String.Empty) { BasicTypesProgramTextBlock.Inlines.Add(new Run("compiler error") { Foreground = new SolidColorBrush(Colors.Red) }); BasicTypesDetailsTextBlock.Inlines.Add(new Run("The C# compiler does not recognize the provided value as a legal simple type.")); } else { BasicTypesDetailsTextBlock.Inlines.Add(new Run("Enter a value in the box above to see what type the C# compiler interprets the value as.")); } break; } }